Skip to content

API Intent

Introduction

When you need your chatbot to connect with a 3rd party service you can use API integration element inside your bot builder. Example: If you have a CRM you want to integrate with chatbot or you want to pull data from an existing client/employee database or you want to add new records to a database. We can send data collected in a bot to external appsor servers, orbring data from outside sources (e.g. API, CRM...etc) to the bot.

The API element has 3 sections:

  • Header
  • Body
  • Response

The Header section is where you can set the following:

  1. API Name- Give a name to your API element to distinguish it from other API elements in the bot by defining the use case or what the API does. Example: Show available SKU or Check customer identification etc.

    API Name

  2. The URL(endpoint) and the HTTP method used (GET, POST) of the external API. The URL must be in one of the following formats:

    • https://www.domain.com
    • https://domain.com
    • https://domain.com?param1=value&param2=value
    • https://domain.com/parametername1/parametervalue

    Methods

    Tip

    • Use GET to check, validate or fetch data from database.
    • Use POST to enter new records in Database.
  3. Customizable Headers (optional) based on your API: Headers in HTTP requests are commonly used for authorization, specifying content type etc. You can set headers as key-value pairs. For example: Key= authorization, Value=token.

    Headers

    Note

    We support Json type format only.

Request

The Request section allows you to send data to the API which is validated and accordingly bot response is defined later.

  • Define the Parameter name say- as per your API example: name, customer id etc
  • Parameter type: either text or numeric,
  • Finally choose how you will send this value to the API. There are 2 ways

    • Send value from Tag: Choose a tag name which stores the user response to a question asked by the bot before
    • Send custom value: Fixed custom message for API for desired response

    Request

Test

Test your API response to see if it is working and use the same response parameters in the next section. Success or error response can be checked here to see if API is working as expected.

Test

Response

This is where we define the output/results expected from our external API. All API response parameters that need to be used are defined here.

  • Example: If API response has 1 parameter “colour” that defines all the available colours of shoes. Under Response Parameter enterresponse.colour. Under Response Redirection add all expected values like – Black, Blue, White and more.
  • Response Redirection allows every expected value to have a unique flow.

    Note

    Only in case of a single response parameter, we can make multiple expected values.

Output Type

Points to Remember:

  1. You cannot use a Gobackto element pointing towards an API element.
  2. If you delete API element, all elements connected to it on the right will get removed.

Sample Use cases

Case 1: Display employee name (Static result)

Response Type

{
    "name":"palak",
    "email":"palak@gmail.com",
    "mobile":"1234567890"
}

If you want bot to display name, define response parameter as below:

response

  • As name will be fixed there is no redirection
  • Choose Static output as Message and define the bot response as {response.name}

response

Case 2: Display all varieties of shoes by brand name available in inventory (Dynamic result in Array format)

Response Type

{
    "brand name":
 [
  {
    "name":nike,
    "price":3000
    },
  {
    "name":under armour,
    "price":4000
    },
  {
    "name":adidas,
    "price":3500
   }
    ]
}

If you wish to use parameter brand name and display the various brand names of available shoes via bot, define it in the response section as below response.brandname[].name.

Note

Response redirection is off as we are expecting API to show real time dynamic values.

response

Remember:

  • For a Website chatbot dynamic elements supported are Options and carousel.
  • For a WhatsApp chatbot dynamic elements supported are Options, List Message, Reply Button.

Note

Bot will display all brand names and the respective value of the option chosen by user can be used in the bot flow later.

response

If you want to showcase all brand names in an MCQ format choose output as Option or WhatsApp List (if API gives only 10 responses).

Under options, you will see response.brandname[].name. Add response.brandname[].priceunder value. Option name is displayed and price will be the value sent.