The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Max Dore
ServiceNow Employee
ServiceNow Employee

AI Agent Studio allows developers to build AI Agents that execute tasks by orchestrating internal workflows and external integrations. This guide will use HRSD as an example and use the “Benefits Enrollment Retriever” AI Agent to explain where each component fits and how you could use your own integration.

 

 

Overview

  • AI Agent Script Tool
    A Script Tool named Look up benefit enrollments includes the iGatewayInputs object:

    const iGatewayInputs = {
      user: userGr,
      feature_name: 'benefits_management',
      service_name: 'get_benefits',
      payload: inputs.payload
    };
    

 

  • Calling Integration Gateway Subflow
    The same script later uses:

    integrationGatewayOutput = sn_fd.FlowAPI.getRunner()
      .subflow('sn_hr_integr_fw.integration_gateway')
      .inForeground()
      .withInputs(iGatewayInputs)
      .run();
    

    This triggers the Integration Gateway subflow, which handles requests for all defined feature/service combinations.

    script.png

 

  • Decision Table Routing
    Step 2 of the Integration Gateway references the Integration Provider Mapping Decision Table. Based on feature_name, service_name, and user, the correct integration subflow is chosen—here, Oracle HCM – Look up benefit enrollments.step 2.png

 

  • Decision Table
  • With this information, the Decision Table can indicate which Subflow to use. In our case of the AI Agent "Benefits enrollment retriever" it is the 'Oracle HCM - Look up benefits enrollments' Subflow.

          DT.png

 

 

  • Specific API Call
    The selected subflow, determined by the Decision Table, contains an Action configured via Integration Hub to make the external API call (HTTP method, URL, authentication, query parameters, and response handling among others).

          subflow.png                             Action.png

 

Custom Integration map

Your integration may be vastly different and for other uses, but to replicate the process of the AI Agent above, follow these steps:

Step Description
1. Decision Table Entry In the Integration Provider Mapping table, add a mapping from your custom feature_name + service_name to a new subflow. Mirror the structure of existing entries.
2. Create Subflow Duplicate an existing subflow (e.g., Oracle HCM - Look up benefits enrollments), rename it, and configure I/O variables for user, payload, and expected outputs. Ensure all outputs are strings for compatibility.
3. Create Action In Integration Hub, configure a new Action: define the external endpoint (REST, SOAP), method, authentication credentials, request parameters, and transform the response into a structured output.
4. Script Tool Setup In AI Agent Studio, define a Script Tool that uses iGatewayInputs, calls the Integration Gateway, and returns the call results (use an existing Script as a guide for the rest of the code).
5. Assemble AI Agent In AI Agent Studio, create an AI Agent that includes your Script Tool and defines conversational logic to invoke it appropriately.
6. Test Agent Use AI Agent Studio’s testing capabilities to simulate user interactions and verify correct integration handling.

 

Best Practices

  • Consistent Naming
    Keep feature_name and service_name conventions clean and maintainable for routing clarity.

  • Supervised Execution
    Mark critical tools as supervised in AI Agent Studio. This allows manual approval before execution, ensuring control over data access and platform changes.

  • Output Formatting
    Return all outputs as strings, this avoids parsing issues and maintains agent performance.

  • Agent Isolation
    When duplicating AI Agents for variations, ensure that each agent’s tool references are independently defined, this preserves distinct versioning and prevents unintended overlaps or shared dependencies.

 

Why This Architecture Works

  • Modular Design
    The Integration Gateway supports multiple features without duplicated code.

  • Scalable Approach
    New integrations can be added easily by replicating the proven pattern.

  • Governance-Aware
    All actions run through authenticated and logged flows, facilitating auditability and control.

  • Clear Routing Logic
    The Decision Table provides a central, understandable mapping of features to providers and subflows.

 

Built-in AI Agents Example Set

Out of the box, the HRSD product provides several AI Agents, such as:

  • Tuition reimbursement

  • Time-off balance retrieval

  • Feedback lookups

  • Request time off

 

Conclusion

ServiceNow empowers you to integrate any external system and to put them to use with the AI Agent Studio. The possibilities are vast and can be done without much effort. I hope this guide has encouraged you to take the next step forward and give it a try in your instance!

Version history
Last update:
‎07-11-2025 08:56 AM
Updated by:
Contributors