In this project, I created an AI-driven incident classification agent that integrates ServiceNow with the OpenAI API. The tool automatically categorizes incidents, helping IT teams reduce repetitive work and maintain consistent labeling. Below is the full workflow with examples.


Step 1: Submitting a New Incident

Users begin by creating a new incident in ServiceNow. For example, the ticket below was submitted with the description:
“My laptop is having trouble turning on.”

Incident Creation Form
The ServiceNow form where users report issues.


Step 2: New Ticket Appears Without a Category

When first submitted, incidents often lack a proper category. This is where the AI agent takes over.

Unclassified Incident
The incident appears in ServiceNow with no assigned category or the default Inquiry / Help. At this stage, it is pending AI classification.


Step 3: Python Script Runs Classification

I built a Python script to connect with ServiceNow via its REST API. Each incident’s description is passed to the OpenAI API, which predicts the appropriate category.

Python Classification Script
Console output showing the script classifying incidents into Hardware, Software, and Database categories.

Handling Duplicate Processing

Early in development, the script kept reprocessing the same old incidents. To fix this, I:

  • Sorted incidents by newest first so only recent tickets were pulled.
  • Checked work notes for an AI comment ([AI_AGENT] Classified as…) and skipped those incidents.
  • Added filtering logic to query only unclassified tickets.

This made sure agents only worked on truly new cases.


Step 4: AI Classification Applied in ServiceNow

Once processed, the AI writes the predicted category back into ServiceNow and documents its action with a work note. In the example, the system classified the ticket as Hardware.

AI Classified Incident
The incident is updated with category “Hardware,” and the work notes show [AI_AGENT] Classified this as Hardware.


Outcome & Learnings

Through this project, I gained practical experience in:

  • Python scripting for workflow automation
  • ServiceNow REST API integration with secure environment variables
  • Prompt engineering and validation for text classification
  • Filtering and optimization to avoid redundant API calls
  • Embedding AI into IT Service Management to streamline operations

This project demonstrated how modern AI models can integrate directly into enterprise systems, saving time for support teams and improving classification consistency.