The Assist bot's builder allows you to make extensive API calls to any external/internal 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 to creating a new API:
- The '+ New API' button will allow you to configure a new API call
Configuring the API:
Name: Give your API call a suitable name.
URL/JS function name: Provide the Callback URL here. The content picker option [+] in this field will allow you to append values from the conversations to the callback URL.
- Method: Configure the type of API call you’re looking to make - GET, PUT, POST, DELETE, or a JS function and then pass the payload accordingly. You can also configure a larger payload content in an expandable text editor that will format JSON automatically when pasted into it. For example, to create a ticket in your Freshdesk account, pass the email, priority, status, subject, and description in JSON. You can also make use of placeholders using the + icon on the bottom right.
Add Headers: You can authorize your APIs in this field, and also pass any additional parameters as headers in this section.
Test: To make sure the API call has been configured correctly, you can perform a sample test run, pass test values for the dynamic fields you have configured in the payload (for PUT, POST, and JSON methods) and verify the response headers.
Add the required response parameters: Attributes from the response headers can be referenced in any dialog in the chatbot conversation.
For example, if you want to display the status ID of an order, the ID field from the headers can be added to this field and be used in the consequent dialogs.
If an array of elements are needed, square brackets should be appended to that field, for the below example: data.id, data.name
For a particular element in an array, using the index number will display the corresponding value in that field: data.id will display the second value in the field, from the above example: 60002
API list page:
From the API library list page, you can search for the APIs you’ve configured using its name. 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 API was created and when it was last modified. Clicking the ‘more’ icon against an API will allow you to edit or delete it.
A quick guide to using the APIs: