The Make an API call step allows you to configure an API call out to another system, such as an internal CRM or ERP, or to push conversation details to an external endpoint, like Amazon Event Bridge or Google Analytics.
In this article, we’ll walk you through the procedures involved in including and configuring the step in a bot flow.
For an overview of the Make an API call step and its configuration rules, see Understanding bot step types: Make an API call.
This article includes the following sections:
Adding a Make an API call step to your bot
Adding the Make an API call step to your bot includes a number of distinct tasks.
The procedures below assume you have already created a bot flow, and are adding this step to that bot.
To add a Make an API call step
- Open the bot in Flow Builder.
- Click the Add new icon where you want to insert the step, either at the end of a branch, or between two existing steps.
- In the Configuration panel, click Make an API call.
- Enter descriptive information for the step. Note that this is only visible to your team – customers will not see the information entered here:
- Name: A name for the call that makes it easy for your team to identify.
- Description (optional): A short description of the action taken by the call.
- Continue with the procedure described in Adding API details, below.
Adding API details
Use the API details section to configure the HTTP call you want to make, including the HTTP request method, location of the external resource, and adding headers if needed. The steps below are a continuation of the procedure in the previous section.
To add the API details
- In the Configuration panel, click API details.
- Use the dropdown to select a Request method:
- GET retrieves data from a server at the external resource. This is the most commonly used method.
- POST sends data to create or update a resource at an external site. If the resource already exists, the data sent modifies the resource.
- PUT sends data to update or create a resource. If the resource already exists, the data sent replaces the resource.
- PATCH sends data to update a resource at an external site. It is used to apply partial modifications to the resource.
- DELETE removes the resource at the external location.
- Enter an Endpoint URL. The endpoint URL is the location of the external resource you are connecting to. The endpoint URL supports both Http:// and Https://
- If needed, enter the key and value for an optional header.
- To make the call, click the Make Test API Call button. Please note this creates a real request to the configured end-point and any saved variables.
Saving the API response as a variable
A variable is a way to store API responses. For example, you can save a customer's name as a variable and refer to it in a bot message. Saved variables can be used anywhere in the flow after the Make an API call step in which the variable was created, in any step that includes a configurable message:
If a variable becomes invalid (if the API schema is changed, for example) the bot will skip the variable when displayed to the end user. You can add up to eight variables per step.
After configuring the API details and testing the API call, you can use the returned Response data to create your variables. The steps below are a continuation of the procedure in the previous section.
To create a variable to save data from external system
- In the Configuration panel, click Make API call.
- Expand the accordion and identify the data from external system that you want to turn into a variable.
Tip: Switch to the Response body tab to view the raw response that has came back from the external system.
- Click Save.
- Give the new variable a name. Variable names must only include lowercase letters, numbers, and underscores.
About the step branches
The Make an API call step is a branching step. Adding this step splits the bot responses depending on whether API was successfully executed
At bot run time, any 200 response codes will have the bot moving down the successful branch. All 400,500 response codes will have the bot moving down the failed branch. Please note that if the API returned 200 with an empty response, any variables saved from this step will be skipped at run_time.