Chatbot
...
Workflow
API Library
8 min
overview the api (application programming interface) integration feature is a powerful component of the exo chatbot platform that allows your chatbot to connect with and exchange data with external systems, services, and applications it acts as a bridge, enabling the bot to go beyond its pre defined knowledge to fetch real time information, trigger actions in other software, and deliver dynamic, personalized user experiences this module is designed to handle rest apis, supporting standard http methods such as get, post, put, delete, and patch from a central api library, you can add, configure, and test all your api endpoints without writing extensive code once an api is saved in the library, it can be easily inserted into any conversation flow using the "api" action element in the flow builder key capabilities of the api module include central api library a repository to save and manage all your api configurations for easy reuse across multiple flows support for rest methods configure calls to fetch data (get), submit data (post), update records (put/patch), and more comprehensive configuration set up every part of the api call, including the endpoint url, headers, query parameters, request body, and authentication details in console testing a built in testing tool allows you to run an api call and see the live response directly within the console before implementing it in a flow flow builder integration seamlessly call any saved api from within a conversation, pass dynamic data to it using variables, and save the response for use in subsequent steps how to use api this guide covers how to add and test an api in the library and then how to use it within the flow builder 2 1 adding and configuring an api from the main console menu, navigate to workflow > apis click the add button to create a new api or import to upload a collection (e g , a postman json file) basic configuration give your api a descriptive name (e g , get order status) select the appropriate http method from the dropdown (e g , post) enter the full endpoint url for the api detailed configuration (using the tabs) query add any required query parameters (key value pairs) that will be appended to the url authorization configure the authentication method for example, select "bearer token" and paste your api key header add necessary request headers, such as content type with a value of application/json body for methods like post or put, define the request payload here you can use variables to insert dynamic data collected from the user settings configure advanced options like request timeout or retry on failure logic test the api once configured, click the send button the response window at the bottom will display the status code and the data returned by the api, allowing you to verify that it's working correctly before you use it in a flow 2 2 using an api in the flow builder in the flow builder, add a new step to your flow and select the actions category choose the api element select api from the dropdown, choose the api you previously saved in the library map variables if the api requires dynamic inputs (like a user id in the url or data in the body), map the flow variables containing the user's input to the corresponding api parameters store the response select or create a new variable to store the data returned by the api this is crucial for using the results handle success and failure the api node will have two output connectors success and failure connect the success path to the next node that should be triggered if the api call is successful you can use the variable containing the api response in this path connect the failure path to a different node that handles the error, for example, by showing the user a message like, "sorry, i couldn't retrieve your details right now " common examples and use cases real time order tracking a user provides their order number the bot sends this number to an e commerce platform's api via a get request and displays the real time shipping status returned in the api response creating a support ticket a bot collects the user's issue details in a form it then uses a post api to send this data to a helpdesk system (like zendesk or jira), automatically creating a new support ticket user verification a user enters their member id the bot sends the id to an internal database api to verify if the user is a valid customer before proceeding with a sensitive transaction dynamic product search a user asks for "running shoes under $100 " the bot calls a product catalog api with "running shoes" and "100" as parameters and displays the results in a carousel best practices test extensively use the send button in the api module to test with both valid and invalid data to see how the api responds to different scenarios always handle the failure path network issues and server errors happen always build out the "failure" branch in your flow to provide a good user experience when an api call doesn't work use variables for everything never hardcode sensitive information like user ids or search queries directly in the api configuration always pass them dynamically using variables collected during the conversation parse the response the entire api response (often a complex json object) is stored in one variable use the modify data action or a custom function to extract the specific pieces of information you need (e g , just the status field from the json) common mistakes incorrect authentication forgetting to add an authorization header or using an expired api key is a common reason for api calls failing with a 401 unauthorized error wrong http method using a get request when the external service expects a post request (or vice versa) improperly formatted body forgetting to set the content type header to application/json or sending a malformed json body in a post request not storing the response the api might work perfectly, but if you forget to save its output to a variable, the data is lost, and you can't use it in the conversation ignoring the api's data structure trying to access response data when the actual data is located in response result items always check the response structure in the testing tool first note this module is available on version 8 and onwards
🤔
Have a question?
Our knowledgeable support team and an awesome community will get you an answer in a flash.
To ask a question or participate in discussions, you'll need to authenticate first.