The bot builder allows you to make extensive API calls to any external system to fetch or push data and have it displayed as part of the bot conversation. What’s more, as Admins, you do not have to pass the parameters each time you trigger an API call from a dialog, instead, be able to reuse them from a previous or any other dialog, and also modify them quite easily by configuring all of them in the API Library.
Every single API call that needs to be made from a dialog can be configured in the API library and can be invoked by choosing the 'Trigger API' option from the Actions tab for the required dialog.
A quick guide in creating a new API:
- Login to your bot builder as an Admin.
- Select the required bot from the bots list for which the API call will be made. The API library of one bot cannot be used in the other.
- Click on 'API library' from the top nav of that bot.
- The 'Add New' option allows you to create a new API call.
Configuring the API parameters:
> Name and URL: Give your API call a Name and provide the Callback URL. The + option in the URL field will allow you to append values from the conversations to the callback URL.
> Authenticate Remote Request: The next step would be to authenticate the request. Enter the auth key in case you want to authenticate the request or choose ‘No authentication’. Since we do not have basic or other authentication types, the same can be passed as headers in the next step.
> Add Headers: Include any additional params as headers in this section. This is an optional section.
> Select Action Type: Configure the type of API call you’re looking to make - Get, Put, Post, or Delete and then pass the payload accordingly. For example, to create a ticket in your Freshdesk account, pass the email, priority, status, subject, and description in JSON. The + option will enable you to fetch values from the conversation.
> Test Sample Response: To make sure the API call has been configured correctly, you can perform a sample test and look at the response headers.
> Configure Desired Response Parameters: A few attributes from the response headers can be saved and displayed to the customer.
For example, if you want to display the ticket ID once it's created, the ID field from the headers can be captured in the 'Add Response Parameters' field and be used in the next dialogs.
If an array of elements are needed, square brackets should be appended to that field: cc_emails.
For a particular element in an array, using the index number will display the corresponding value in that field: cc_emails will display the second value in the field.
From the API library list page, you can search for the APIs you’ve configured using its name or the ID. The listed APIs will tell you the type of action the API has been set up to perform - GET or POST etc, show when the call was created and when it was last modified. Clicking the ‘more’ icon against an API will allow you to edit or delete it.