AI Agent Studio: How to Fetch Dynamic Incident Fields Based on User Prompts in Now Assist?

Nikhil_Khndelwl
Tera Contributor

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!

 

khandelwal0_0-1792654541957.png

 

2 REPLIES 2

yashkamde
Giga Sage

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.

sanjaygupta
Tera Guru
The Record Operation tool requires you to configure the fields that it will return in advance. The Returned fields setting defines which Incident fields are available in the tool's output, while Max records returned controls the maximum number of matching records retrieved.

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.