Logo

API Function calling

With the API function calling capability, ConnectPlex ChatBots can respond by calling external API’s set up in advance. Our AI chatbot platform allows developers to integrate external web services, APIs, and data sources using API Function Calling. On the ConnectPlex Dashboard, you can set up these API’s and incorporate it into your AI chatbot directly.

  • A user can enter a prompt in the chat interface, for example, ask "What's the weather in New Jersey today?"
  • The ConnectPlex ChatBot AI engine analyzes the semantic meaning of the user's question and matches with descriptions of the functions to determine which function should be used.
  • For the user prompt example provided in step 1, the function get_city_weather is triggered because a user asked for the current weather of a city.
  • The ConnectPlex ChatBot AI engine also extracts relevant parameters from the user prompt, such as city name, and passes it to the API Manager.

Example

{
"role": "assistant",
"content": null,
"function_call": {
  "name": "get_city_weather",
  "argument": "{\"city\": \"New Jersey\"}"
  }
}

  • Then, the API takes the function name and its parameters to make the API call as per the developer’s API function definition.
  • The output of this API call is sent back to the ConnectPlex ChatBot AI engine to craft a more natural, personalized response for the user.
  • How function calls work

    This section further explains how a function call works with the ConnectPlex ChatBot server, the AI engine, and API calls. This document provides detailed instructions on how to use this service, including defining and configuring API functions that your chatbot can call automatically.

  • Getting Started

    To integrate an external API, developers need to sign up with the ConnectPlex developer platform. They can then manage their API function definitions from the Developer API link in the side menu.


Below are the details required for setting up a new API function call.

1. API Function Name

  • Field: Name for this API function call.
  • Description: A unique name following typical function naming conventions (e.g., get_local_weather).
  • Example: get_local_weather

2. Function Description

  • Field: Detailed description of the function
  • Description: A clear and concise description of what the API function does. This will be used by AI to determine when to call this function.
  • Example: Gets the weather for the provided location name.

3. API Endpoint URL

  • Field: API Endpoint URL
  • Description: The URL of the API endpoint you wish to call.
  • Example: https://api.weather.com/

4. HTTP Method

  • Field: HTTP Method
  • Description: The HTTP method used to make the API call to the endpoint.
  • Options: GET, POST, PUT, DELETE

5. Request Parameters

  • Field: Request Parameters
  • Description: Define the parameters required for the API call. Each parameter should include a name, type, description, and whether it is required.
  • Parameter Name: The name of the parameter (e.g., cityName).
  • Parameter Data Type: The data type of the parameter (e.g., String, Integer).
  • Parameter Test Value: Parameter Value for which the test needs to run.
  • Required: A checkbox indicating if the parameter is mandatory.
  • HTTP Param Type: The place where the parameter value is to placed in the HTTP Request (e.g., QueryString, URL Path, Body (form), Header)
  • Parameter Description: A description of the parameter’s purpose.

To add more parameters, click on the add button


Submitting the Form

Once all fields are completed

  • Click the Test button to test the API call configuration
  • Click Save to save the new API function.

Example Configuration

Here is an example of a completed form for a weather API function

  • Name for this API function call: get_local_weather
  • Detailed description of the function: Gets the weather for the provided location name.
  • API Endpoint URL: https://api.weather.com/
  • HTTP Method: GET
  • Request Parameters:
  • Name: cityName
  • Data Type: String
  • Test Value: New York
  • Required: Checked
  • HTTP Param Type: QueryString
  • Description: Name of the city for which weather information is required

Tips for Creating API Functions

  • Ensure the function name is unique and descriptive.
  • Provide a detailed description to help the AI model understand the function’s purpose.
  • Verify the API endpoint URL is correct and accessible.
  • Clearly define each parameter and its necessity.

Troubleshooting

  • If the API function is not working as expected, recheck the endpoint URL and parameters.
  • Use the Test button to debug and verify your configurations before saving.

Incorporate it into your AI chatbot

Using the API Function Calls you created above, you can directly incorporate it into your AI chatbot.

  • On ConnectPlex Dashboard, go to ChatBots > Manage ChatBots and either click on an existing bot or create a new personalised bot. For more information on how to create a new bot, see this page.
  • In the bot detail page, you can select and add a function using the “Add API Function” button at the bottom of the form.

By following the above steps, you can successfully integrate external APIs with your chatbot, enhancing its capabilities and providing a richer user experience. For further assistance please contact our support team.