AI Agent Studio: How to Fetch Dynamic Incident Fields Based on User Prompts in Now Assist?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Everyone,
I am trying to build my first AI Agent using AI Agent Studio in ServiceNow. My objective is to fetch incident details through the Now Assist chatbox, based on what the user asks in the prompt.
For example, the user might ask for the priority of an incident, a summary of its description, work notes, assignment group, or any other field.
To achieve this, I am creating a tool and selecting Record Operation as the tool type, with the following configuration:
- Table: Incident
- Operation: Look up records
However, I am required to specify two fields: Max records returned and Returned fields.
I am unsure how to configure these fields because I want the agent to retrieve the relevant incident information dynamically based on the user's question, rather than specifying a fixed list of fields in advance.
For example, if the user asks for the priority, the agent should return the priority; if the user asks for work notes, it should return the work notes.
How can I achieve this dynamic behavior using the Record Operation tool? If this tool does not support it, what would be the recommended approach in AI Agent Studio?
Any guidance or examples would be greatly appreciated.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Nikhil_Khndelwl ,
Record Operation tool requires you to define the Returned fields in advance, so it doesn't dynamically select fields based on the user's question.
However in Returned fields - Include the commonly required incident fields,
and Max records returned - records returned (e.g. 1)
Also as per you requirement check below the Output transformation strategy options. Selecting Custom allows you to provide instructions to format the output according to the user's request.
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
The tool does not dynamically change its returned fields based on the user's prompt. Therefore, selecting only the fields requested at runtime is not directly supported through this configuration.
You can configure it in the following way:
Set Max records returned to 1 if the incident number uniquely identifies the record.
Add the fields you expect the agent to retrieve, such as number, short_description, description, priority, state, assignment_group, and work_notes.
Configure the incident number as an input and use it in the lookup condition.
If you need greater flexibility, consider using the Script tool in AI Agent Studio. ServiceNow documents that scripts can use scriptable APIs and back-end integrations to support AI agents. You can use this approach to retrieve fields based on an input supplied by the agent, subject to appropriate field validation and access controls.
You can refer to these official ServiceNow documentation pages:
The Record Operation approach is suitable when you have a predefined set of fields. For runtime field selection, evaluate a Script tool instead.