Set the API in the Bot

How to Add the API in Function Call

Function- API Addition

To utilize function call functionality, you need to enable the function.

  1. Condition 1 -It should be enabled

You can create the function in two ways:

  • Adding it manually.

  • Utilizing the Import curl functionality.


Using import curl Functionality

​Paste the copied curl into Windows after selecting the import curl button.


Add Manually 

 Add the URL: In this, you have to select which type of API you are using- GET, POST, PUT or DELETE.

  1. Now Add Header Key:

You can add the header key for three purposes:

Identification: For identifying purposes like content type

Authorization: For authorization purposes like Awthkey or JWT

Data Input: For the type of data you will accept, like JSON


​ 3.  Add Key Value:

           In Key Value you have to provide the value for the header key, you have set.  

           Like: Header Key: Content-Type, Header Key Value: Application/JSON. 

       

           4.In Request Body:


  • In the case of the request body of the function use ‘$’ to use session data.


How to send QUERY PARAMETERS in URL

Only applicable for GET API

Whatever parameters you want to add, just add that parameter in the request body in JSON format- Don't define the content type in the header.



To use the API response 


6. In Get Response

When you click on this button- Whatever you have filled in the API, The API will be hit with all the inserted data that you have filled in. According to that data, the API will respond and Showcase the API result.


You can select the API keys from the API result for further use in other sections of the intents.


After adding the API you have to select the API template in the Function Call section of the Bot


  • Success Response: What response do you want to send to the customer in case the API hit is successful 

Here you can define the variables with the help of

    ‘{‘ = for slots

    ‘[‘ = for sessions

    ‘$‘ = for response key


  •  Failure Response

Here you can define the variables with the help of:

    ‘{‘ = for slots

    ‘[‘ = for sessions


Special Characters Usage in the Bot 

User Input Uses:

With curly brackets ({XXXX}), the user input values can be utilized in the user input’s confirmation response or decline response, function call’s success response or failure response, and closing response sections of the current intention's bot.


User Input- Confirmation response


Functions Call - Success and Failure Response


Use of Session Data

  1. To use the session data you have to insert ‘[’ - Then a dropdown list will open with all the session data. In the case of the request body of the function use ‘$’ to use session data.

  2. Session data contains:

    1. Client Information- name, number, and email address

    2. User Inputs

    3. Function Variables

  3. You cannot access the session data in the client query. 


Examples:How to use the session data in Request body



How to use the session data in other sections of the intent except client query


How to define variables in the request body of the function

Use “##VAR{Any number}##”  to insert variables 

For Eg. “Name”: ##VAR1##


NOTE: In ##VAR##,  ‘VAR’ must be in Capital and as well as it should be in between inverted commas, Otherwise the bot will treat this as a normal sentence.