Agent by itself is good at making decisions and analyzing data. But LLMs naturally can't go and interact with databases and applications.. yet ;)
In order for Agent to interact with external systems we will add necessary Tools:
Retrieve Incident details. The data that we want the Agent to analyze is inside ServiceNow and we need to retrieve it.
Update Incident details. After categorization, we need to update Incident data in ServiceNow.
There are various kinds of Tools - Integration Service activities, RPA Processes, Agents.
One of the tools we will need is based on Integration Service - find "Search Incidents by Incident Number" in ServiceNow catalog. This tool will look up Incident Details by Incident Number.
We also need to specify the ServiceNow Connection the tool is going to use. Select the Shared ServiceNow Connection from the ServiceNow Incidents folder.
Note: Incident in ServiceNow has ID (unique identifier string like "36155.....53afb2") and Number (user friendly name like "INC0111888").
Next, let's add the UpdateServiceNowIncident RPA Process tool same way. An existing RPA process should be already published to Orchestrator in folder "ServiceNow Incidents".
Add the tool, description and arguments descriptions.
Assignee : Assignee Email address
Incident ID : The ID of ServiceNow Incident, do not use Incident Number here
Category : The Category of ServiceNow Incident
Subcategory : The Subcategory of ServiceNow Incident
This tool is going to be used by the agent to update the ServiceNow incidents, after categorization is done.
Let's change agent's structure. Remove all input arguments of the Agent and add new Argument instead:
IncidentNumber : ServiceNow Incident Number
With the tools we added, Agent will be able to retrieve necessary descriptions whenever needed from ServiceNow directly.
Update the User Prompt accordingly:
Analyze and categorize the following ServiceNow incident:
Incident Short Description: {{IncidentShortDescription}}
Incident Description: {{IncidentDescription}}
Incident Number: {{IncidentNumber}}
Determine the appropriate category, subcategory, and assignee email for this incident based on the provided information.
Next, we need to explain to the Agent what these tools are for and when to use them.
You are a ServiceNow Incidents categorization agent, an AI assistant tasked with managing newly created ServiceNow incidents. Your primary responsibility is to analyze incident details and determine the correct Category, Subcategory, and Assignee email address for each incident.
# Retrieve Incident details
- Use Search Incidents tool.
- Use IncidentNumber as Input.
- If ticket already has an Assignee, then stop processing.
# Categorize the incident
...
# Once categories have been established, determine the on-duty Assignee email address who handles this type of requests by calling Assignee Lookup automation.
# If Category, Subcategory and Assignee have been successfully established, update the ticket by running UpdateServiceNowIncident tool.
# If Category, Subcategory or Assignee can not be established, do nothing.
# Summarize the actions taken.
...
With this setup we should have given agent necessary instructions, related tools, and context for analysis. Time to give it a try using some ServiceNow incidents!
Open Ticket Management App, update Tag with your name and click "Generate". You should see tickets generated with this Tag within last 2 days, if any. If you have no new tickets, feel free to generate few, but don't forget to set your name as Tag before hitting "Generate".
You can use Incident Number from the Ticket Number column of the first list as Agent's input. After processing, categorized Incidents will move to the bottom list.
Full execution trail looks well, Agent runs necessary tools in the right sequence, and results are correct. Outstanding!
Investigate the execution. Every step has details and you can trace the logic of each step. You can check the ticket status as well - it has been updated in ServiceNow. Our "Happy Path" is ready.
There always will be cases where agent will not know what to do. Maybe ticket will not contain enough details for classification, or there are more than one possible category. In this case, Agent should involve a Human.
Let's add an escalation path - we will create an Action Center task for every Incident that can't be classified.
Let's explore the escalation App "ServiceNow Agent Escalation App" from the "ServiceNow Incidents" folder and briefly go through it, understanding how it works.
Add the Escalation to the Agent as per the screenshot:
Prompt: Use this when you can not establish category and subcategory of the Incident based on Description and Short Description
in_Reasoning : Briefly explain the steps taken up until escalation
Outcome behavior:
Submit - Continue
Stop execution - End
System Prompt Should be updated accordingly:
# Categorize the incident.
- Determine the Incident Category and Subcategory based on Description and Short Description from Categorization Information Context.
- Context contains table with only possible Category-Subcategory pairs. Do not mix Category-Subcategory pairs if specific pair is not present in the context.
- Pick the Category-Subcategory pair that aligns well with Incident Descriptions.
- If you are not sure or no category pair is a clear match, return "Unknown" as category.
# Once categories have been established, determine the on-duty Assignee email address who handles this type of requests by calling Assignee Lookup automation.
# If Category, Subcategory and Assignee have been successfully established, update the ticket by running UpdateServiceNowIncident tool.
# If Category, Subcategory or Assignee can not be established, do nothing.
# Categorize the incident.
- Determine the Incident Category and Subcategory based on Description and Short Description from Categorization Information Context.
- Context contains table with only possible Category-Subcategory pairs. Do not mix Category-Subcategory pairs if specific pair is not present in the context.
- Pick the Category-Subcategory pair that aligns well with Incident Descriptions.
- If you are not sure or no category pair is a clear match, use escalation.
# Once categories have been established, determine the on-duty Assignee email address who handles this type of requests by calling Assignee Lookup automation.
# If Category, Subcategory and Assignee have been successfully established, update the ticket by running UpdateServiceNowIncident tool.
# If Category, Subcategory or Assignee can not be established, use the Escalation.
- If Category and Subcategory have been selected by the user as part of escalation, look up Assignee based on selected Category and Subcategory, and then update ticket. Only use email addresses retrieved from the lookup tool, do not generate email addresses.
Now use any incident that Agent was unable to classify before in order to trigger an escalation. Good example is this one:
Short Description: I would like to talk with a manager
Description: Every time I reach out to this team, the response time is really long, seriously affecting my productivity. I would like to talk with a manager please.
Definitely there is no way to map this text to any category, so Agent should escalate. And it does!
(Hint: If it doesn't - validate your prompt once again to include escalation instructions)
Guess, which parameter affects Agent's confidence when assigning categories? Try to tune it and see if incidents that were successfully categorized previously can lead to Escalation. Hint: it's the Context settings.
As you remember, a process in Orchestrator (whether agentic or robotic) can be triggered from another robot, via Orchestrator triggers (schedule/queue items/external API calls), by Integration Service events, from Apps, or even by an Agent. So, yes - Agent can start another Agent, if necessary.
Congratulations and well done! Agent is now ready to use, so you have completed your first Agent with UiPath Agent Builder!