< All Topics

Make an External Request

External Request allows you to integrate your bot with any system that has an API. You can use External Requests to get data from any other system and display the data to the user inside your Chatbot.

How to Use External Request?

On the flow builder, add Actions > External API Request.

How to save data to a custom field?

You can use Response Mapping to save data from API to a Custom Field If the API returns data in JSON format. Many times you may want to get data from an API and show the data to the user.

For example, we will use a currency exchange API to show how you could save the data returned from an API to a custom field. Below is the response from the API.

{
    "success": true,
    "timestamp": 1519296206,
    "base": "EUR",
    "date": "2021-03-17",
    "rates": {
        "AUD": 1.566015,
        "CAD": 1.560132,
        "CHF": 1.154727,
        "CNY": 7.827874,
        "GBP": 0.882047,
        "JPY": 132.360679,
        "USD": 1.23396
    }
}

If we want to show the USD value, you will need to use rates.USD, we advise you to test your Request, copy the response and use this service to get the correct JSONPath. Also, you can use this service to check if your JSONPath is correct. No need to start your JSONPath by x.

There is two way to display the data returned from an API to the user inside your bot. You can save the data to a custom field using Response Mapping and use the Custom Field in your flow to show the data to the user. Also, your API could return messages ready to be displayed to the end user inside your bot (Dynamic Contents).

How to get the HTTP status code or whole response body?

On the response mapping, use http_status_code to get the response code and use http_response_body to get the whole response body. Once you save the HTTP status code into a custom field, you can use conditions to do any logic you want. To download a file, use http_download_EXTENSION. For example, to download audio, you could use http_download_mp3.