API Functions enable GenerativeAgent to call your existing APIs to fetch data or perform actions. They are the most common function type for integrating with backend systems and allow your agent to interact with your existing infrastructure without requiring additional development work. By using an API Function, you can:
  • Connect to your existing APIs without creating new simplified interfaces
  • Fetch real-time data from your backend systems
  • Perform actions like creating records, updating accounts, or processing transactions
  • Leverage your current infrastructure without additional development
To create an API function:
  1. Create a function
  2. Select an API connection
  3. Specify name and purpose
  4. Configure optional settings
  5. Use the function in a task

Step 1: Create a New Function

Navigate to the Functions page and click “Create Function.”
  1. Select “Connect to an API” and click “Next: Choose an API”

Step 2: Select an API Connection

Under “Choose an API”:
  1. Select one of your existing API connections
  2. Click “Next: Function details”
If you don’t have any API connections yet, you’ll need to create one first or create a Mock API Function.

Step 3: Specify the Name and Purpose of the Function

  • Function Name: Provide a concise, unique name, using underscores (e.g., get_account_balance). By default, the function name will be the same as the API connection name.
  • Function Purpose: Briefly describe what the function does (e.g., “Retrieves the current account balance for a customer”).
    • GenerativeAgent uses this description to determine if/when it should call the function.
Click “Create Function” to create the function. You’ll be taken to the function detail page where you can configure additional settings.

Step 4: Configure Optional Settings

After creating the function, you can configure additional fields to enhance the function’s behavior:
  • Message before sending: Display a message to the user before calling the API
  • Confirmation message: Show confirmation after successful API calls
  • Reference variables: The API function response will be part of the conversation context for GenerativeAgent to reference, but you can optionally specify a specific field as a reference variable to either reference it in a Conditional Template, or for it to be included when a System Transfer Function is called.
The function detail page shows the function configuration and any available API endpoints.
The function will call the real API during interactions. Make sure your API connection is properly configured and accessible.

Step 5: Using the API Function in a Task

Once you have created your API function, you must add the function to the task’s list of available functions for GenerativeAgent to use it. GenerativeAgent will call the function when it determines the API call is needed to complete the task. Here’s how the function works within a task and conversation flow:
  1. GenerativeAgent analyzes the user’s request and determines if an API call is needed
  2. (Optional) A “Message before Sending” can be displayed to the user
  3. GenerativeAgent calls the API function with the appropriate parameters
  4. The API response is processed and can be used to generate a response to the user
  5. (Optional) A “Confirmation Message” can be displayed after successful API calls
# Objective
Help a customer check their account balance and recent transactions.

# Context
- Customer wants to know their current balance
- They may also want to see recent transactions

# Instructions
1. **Gather Account Information:**
   - Ask for the customer's account number or phone number
   - Store "account_number" once provided

2. **Check Account Balance:**
   - Call the `get_account_balance` function with the account number
   - Display the current balance to the customer

3. **Show Recent Transactions (if requested):**
   - If the customer asks about recent activity, call the `get_recent_transactions` function
   - Display the transaction history in a user-friendly format

Next Steps