Building an AI-Powered Reporting Widget in ServiceNow
Being a ServiceNow developer, creating reports can be easy. But for IT support desk agents, managers, or end users, it’s often a challenge. I frequently receive requests from non-technical teams to create or modify reports. That made me think: why not automate this entire process using AI?
The Idea
Let AI handle the reporting. Just describe what you want — like "Show open incidents by priority" — and get a live, interactive chart in seconds. No GlideRecord, no filters, no field selections. Just a prompt.
Architecture Overview
- Portal Widget UI: Captures prompt and chart type
- Client Controller: Sends data to Scripted REST API
- Scripted REST API: Prepares prompt & sends request to OpenAI
- Chart Renderer: Parses response JSON and draws chart on canvas
The First Version
I built a basic ServiceNow portal widget that:
- Takes a natural language prompt from the user
- Sends it to OpenAI's GPT-4 using a Scripted REST API
- Gets back structured chart data (labels, datasets, chart type)
- Renders the chart using Chart.js inside the widget
Supported chart types: Bar, Pie, Line
This turned out to be surprisingly effective for quick, visual reporting.
What Makes It Smart?
- Pulls table & field info dynamically
- Uses system property to store OpenAI API key (
ai.report.openai.key
) - Completely configurable and extendable
Demo:
Output:
Why This Matters
This removes a huge burden from developers and empowers non-technical users to build insights instantly. No more back-and-forth with IT. Just results.
Future Improvements I am working on
- Smart filters (like date range, priority, state)
- Export to PDF/CSV
- Saving & sharing reports with other users
- Adding these reports to the Dashboard using a single click
Let me know if you'd like the code or want to collaborate on the advanced version.
Check the code here GITHUB
If you have any issues or query, feel free to reach out - Linkedin
0 Comments