AI Agent | Train Your Chatbot to Mix Human-Like Behaviors with Strong Action-Taking Abilities

Learn how to train your chatbot to mix human-like behaviors with strong action-taking abilities.

Botsonic's AI Agent feature enables you to enhance your chatbot by adding new abilities and integrating human-like behaviors with strong action-taking capabilities. This allows your chatbot to not only respond intelligently but also perform specific tasks, such as booking tickets, providing a more dynamic and interactive user experience.

Access the AI Agent Page

  1. Open the bot you want to work on.
  2. On the left-hand side menu, click on "AI Agent".

Understanding Behaviors and Abilities

There are 2 elements to train your bot to mix human-like behaviors with strong action-taking abilities:

  • Behaviours - a "behavior" refers to the predefined actions or responses that the AI agent performs when interacting with users, based on specific triggers or inputs.
  • Abilities - an "ability" is a predefined action or function that the chatbot can perform, such as making API calls, interacting with external systems, or referencing specific documents, to enhance its responses and capabilities during user interactions.

Create a Behavior

  1. On the chatbot's AI Agent Page, click on the "Behaviors" tab.
    • This will take you to the Behavior Manager page, which you can think of as your bot's brain.
    • The Behavior Manager is where you shape how the bot behaves, allowing you to set up different responses for different situations during a chat.
  2. Click on "Add New Behavior".

  1. Give this behavior a name, e.g., "Order Cancellation."
  2. Describe the trigger condition. When should this behavior be triggered? Eg. "when a user wants to cancel an order."

  1. Provide the bot with some training phrases. Training phrases are example phrases for what end-users might type or say. Botsonic will use these phrases to train the bot, so we suggest having at least 5 phrases for better output. Here are some example phrases for a trigger condition to "cancel an order"
    • I want to cancel my order
    • I no longer need the item I ordered, cancel it
    • Cancel my last order
    • I need to cancel my purchase
    • Can you help me cancel my order?

  1. Give the bot instructions on how to behave in the given scenario. For example:
    • Always start by asking for the order ID for the order they wish to cancel if they haven’t mentioned it in the chat.
    • As a fallback, if no order ID was provided, ask the user for their email address, then list all the orders and ask them to choose the order they wish to cancel.
    • Always confirm the cancellation first before actually canceling.

  1. Link "Abilities". The bot can interact with other systems outside of your bot. For example, you might make an API call or trigger a human handoff. We refer to these interactions as “Abilities.” An example ability is an API call to "cancel an order".
    • Ensure that an "ability" has been created, then click [Link Abilities]
    • Select the ability/s required to perform the task
    • Click [confirm]

Create an Ability

  1. On the Bot's AI Agent Page, click on the [Abilities] tab
  2. Click [Add Abilities]

  1. Enter Ability Name. In the "Ability Name" field, enter a concise and descriptive name for your new ability. For example, "Book Ticket." This reference helps you identify the ability later.

  1. Select Type of Ability. You have two types of abilities you can add:
    • a custom API or
    • a knowledge base

  1. Provide a Description. In the "Description" field, explain what the ability does. For example, "This API helps with ticket booking on behalf of the user." This description helps you and others understand the purpose of the ability at a glance.

Custom API

Adding new abilities can significantly improve the user experience by automating processes such as ticket booking, data retrieval, and more.

1. List Inputs

List out all the necessary inputs that your API needs to be triggered successfully.

  1. Click on "Add Input"

  2. Select an input type and define parameters:

    • String: This input type is used for text-based data. For example, you might have an input called "destination" for an airline ticket booking API.
    • Number: This input type is used for numerical data. For example, you might have an input called "number of tickets" to specify how many tickets are being booked.
    • Boolean: This input type is used for true/false values. For example, you might have an input called "is child" to indicate if the ticket is for a child.
    • Enum: This input type is used for predefined options. For example, you might have an input called "class" with options like "economy," "business," and "premium economy."

Example for Booking Tickets:

destinationStringThe destination for the ticket booking.
number of ticketsNumberThe number of tickets to be booked.
is childBooleanIndicates if the ticket is for a child.
classEnumThe class of the ticket.
Options: economy, business, premium economy

  • The AI will gather these inputs either from the previous conversation context or by asking relevant questions to the user. This ensures that all necessary information is collected before triggering the API.
  • For example, if the user has already mentioned the destination in a previous conversation, the AI will use that information. If not, it will prompt the user to provide the destination.

2. Make Custom API

To ensure that the chatbot can correctly send requests and receive responses from the external system, define the API Endpoint by specifying the URL and method type for the API your chatbot will interact with.

  1. Paste the URL: Enter your API's URL in the "URL" field.
  2. Select the Method Type: POST, GET, PUT, PATCH, DELETE.

3. Authentication

Authentication ensures that only authorized users can access the API, providing an additional layer of security. Select the type of authentication required for your API:

  • None: Choose this if your API is public and does not require any authentication.
  • API Key: If your API requires an API key, select this option then enter the API key in the provided field, then select the authentication type:
    • Basic Auth: This type of authentication requires a username and password. The credentials are encoded and sent in the request header.
    • Bearer Token: This method uses a token that is sent in the authorization header. The token is usually prefixed with the word "Bearer".
    • Custom Auth: If your API requires a custom authentication method, you can specify the custom header and its value.

4. Header Key

The header key allows you to add custom headers to your API requests. These headers can be used for various purposes, such as identifying the source of the request or passing additional information required by the API.

  • You can add any constant type headers that your API requires.
  • For example, you might want to add a header to identify that the request is coming from Botsonic. You could add a header like "x-from" with a static value of "botsonic-chatbot". This helps you recognize on your end that the request is coming from Botsonic.

5. Pick Outputs

Pick specific outputs from the API response that you want to expose to the chatbot. Instead of using all the data returned by the API, you can choose only the relevant pieces of information. This helps in filtering out unnecessary information and focusing only on what is relevant.

For example, if your ticket booking API returns 20 different parameters, but you only need the ticket URL, you can specify that using a JMESPath.

  1. Enter parameter key: Choose the specific outputs you want to expose.
  2. Configure JMESPath: Use JMESPath to filter and extract the desired data from the API response. For example, if you only need the ticket URL, you can configure a JMESPath to extract just that. To learn more, go to

6. Configure Response Caching

Response caching helps optimize the number of requests made to your API by storing the response for a specified duration. This is particularly useful for APIs where the response does not change frequently within a chat session.

Example Scenario: Imagine you have an API that provides flight details. The flight details for a specific flight number are unlikely to change within a short period. By caching the response, you can avoid making multiple API calls for the same flight details within a single chat session, thereby reducing the load on your API and improving performance.

Select a caching option:

  • No Cache: The API response is not cached. Every time the API is called, a new request is made, and a fresh response is fetched. This is suitable for APIs where the response data changes frequently and needs to be up-to-date with every request.
  • Till End of Session: The API response is cached for the duration of the chat session. Once the response is cached, subsequent requests within the same session will use the cached response instead of making a new API call. This is ideal for APIs where the response data remains consistent within a chat session. For example, flight details, weather information, or static content that does not change frequently.

Knowledge Base

If you're adding a knowledge base as an Ability type, you can add sources like PDFs, Word documents, text files, or even a website URL.