We have recently refreshed our branding across our offerings and changed the names of our pricing plans. If you have signed up before Aug 9, 2021, please click Previous plans to view your applicable plans.
We assure you that this change will not impact your product experience, and no action is required on your part.
You can make extensive API calls to any external system to fetch or push data and display the data to your customer while they interact with the bot. You can configure them once in the API library and reuse them in any of your dialogs in that bot.
TABLE OF CONTENTS
A quick guide in creating a new API:
- Go to Bots from the left pane.
- Create a new bot or select the bot you want to edit.
- Navigate to Flows > Configure > API library.
- 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 endpoint URL here. The content picker option [+] in this field will allow you to append placeholder values like customer input, other API responses, default parameters, etc.
- 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. 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 that you have correctly configured the API call, you can perform a sample test run by checking the Run Test checkbox, 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: You can reference any attributes from the response headers from any bot dialog. For example, if you want to display the ticket ID once it’s created, the headers ID field can be added to this field and be used in the consequent dialogs.
If an array of elements are needed, append square brackets to that field. For example:
For a particular element in an array, using the index number will display the corresponding value in that field: data.id will show the second value in the field, from the above example: 60002
API list page:
You can access the API library from Flows > Configure > API library. On this page, you can see the list of APIs that you have configured. Apart from this, the page will also:
- Lets you search for the APIs that you have configured
- Show you the type of actions set up for the API to perform (GET, POST, etc.)
- Display when you created the API and when it was last modified.
You can edit or delete each API — or create a new API from this page.
A quick guide to using the APIs
You can add an API’s response through a message, action, or even using a condition.
- Using Message to add an API response:
Type out the message or the question to be displayed to the customer. Click on the + icon to access placeholders. In this case, pick APIs. You’ll see the list of all the APIs configured under the API library for that bot. Choose the required API to append it to the text box.
For example: If you are creating a ticket for the customer interaction with the bot conversation, you can set up a create ticket API call. You can then reference the ticket ID from the response parameters.
- Under Actions:
Create a new action in the dialog, set the Action type to Trigger API, and then select the required API from the list of all the APIs configured under that bot’s API library.
You can insert the Trigger API action anywhere in the flow. If you need to trigger the API before a message, create the Trigger API action before it. Similarly, if you need to trigger the API after a message, create the Trigger API action after it.
- Under Conditions:
Open the Conditions tab for the required dialog > click on + icon to access placeholders > choose APIs from the drop-down. You will see the list of all the APIs configured under the API library for that bot. Select the required API call and then proceed to choose the response value. You can use the API’s response both in the body of the condition and in the condition’s value section.
For example: In the case of a simple subscription flow, you can get the status of the payment from the API response and redirect customers to a different dialog/flow if the status is unpaid or set up a dialog to display a simple message to the customers if the status equals paid.
Things to note:
- only REST APIs with JSON response is supported.
- API requests will time out after 10 seconds if a response is not received.