API Tool in AI Agent

Updated 

The API Tool allows an AI Agent to interact with external systems by making API calls. You can configure this tool to send inputs, receive outputs, and handle errors during execution.

Steps to Configure API Tool

Follow the steps below to configure the Update Properties Tool in AI Agent Studio:

1. Access the Update Properties Tool

  • Navigate to AI Agent Studio from the Sprinklr Launchpad.

  • Select the AI Agent you want to configure.

  • Expand the Build section and open Tools.

  • Click + Add Tool and select API Tool from the list.


2. Define Basic Details

  • Name: Enter a unique name to identify the tool.

  • Description: Provide a brief description of the tool’s purpose.

3. Configure Setup Function

  • In the Setup Functions field, select an API and API Endpoint based on the chosen action.

  • In the Input Variables field, define necessary input variables in API Input and map the input to specific variables in Value to Send to API.

  • Enter the Output Variable to store the information retrieved from the API.

  • Enter the Error Variable to capture any error messages from the API.

  • Enter the Adapt Response and Adapted Response Variable:

    • Adapt Response: Allows users to write Groovy code to parse, update, or format API responses and store the result in an Adapted Response Variable for later use.

    • Adapted Response Variable: Stores the modified API output for reuse in the dialogue flow.

  • Enter the Gen AI Output: Allows users to write Groovy code to parse, update, or format the API response before it is sent to OpenAI for publishing. The modified output is what gets published. Groovy code should be written inside ${}.

  • Click Save to add the API tool to your AI Agent.

Use Case of API Tool

Configuring a Customer Credit Card Inquiry API

For example, there is a user who needs to configure and use the API to retrieve credit card information, and an API backend system that provides the credit card inquiry functionality.

Prerequisites

  • The user has access to the API documentation.

  • The user possesses a valid API key.

  • The user has a customer credit card number to input.

Process Flow

  • The user accesses the configuration interface and selects the "Customer Credit Card Inquiry API" from the drop-down menu.

  • The user selects an endpoint from the available options:

    • Get Credit Card Balance

    • Get Credit Card Summary

    • Get Credit Card Transactions

  • The user inputs the necessary variables:

    • Credit Card Number: Entered in a designated input field.

    • API Key: Entered for authentication.

  • The system maps the inputs to variables for processing.

  • The user specifies an output variable name (such as creditCardOutput) to store the retrieved information.

  • The user defines an error variable name (such as error) to capture any error messages from the API.

  • The user decides whether to pass the raw output data to the system for further processing.

  • If desired, the user configures a process output box to transform API responses into a human-readable format.

  • The user submits the configuration and triggers the API call with the provided inputs.

  • The system receives the API response, which is either:

    • Successful: The output variable is populated with credit card information.

    • Error: The error variable contains details about the issue.