API Requests and Responses - Callback and Callback Message

The callback can be utilized for initiating an API call to an endpoint, allowing you to handle it as needed. The actual API call is defined under Callback Profiles, so only the Callback ID should be added in the Callback field. The Callback Message, which acts as a replacement for Prompt, allows you to configure the text that you want the Chatbot to send after the API call is executed. This can be a static text or it can be any data received in the API response, which can be accessed using angle brackets notation <>. Unlike Response Callbacks, Callbacks do not allow you to properly handle API errors, so consider this while choosing the design approach.

After the API call is executed and the Callback Message is sent to the end user, the user's response will then be saved in the variable defined under the Key Name.

For example,

In the example in the screenshot, we are asking for the user’s name in the follow-up question called 'Name'. In the next follow-up question, (following screenshot) we are using the Callback ID (defined under Callback Profiles) to make an API request to an external endpoint, sending the Name variable that was just collected in the previous question. The static message configured under Callback Message will then be sent to the end user.

📘

Note:

The screenshot displays the Callback ID as a static text. In a real situation, you'll need to supply the actual Callback ID, which can be obtained from the Callback Profile page.

How to access Chatbot variables when configuring a Callback Profile?
Callback Profiles are used to configure the actual API call that the bot needs to perform. When configuring a callback profile, you can access any Chatbot variable in the query parameters or in the request body by using the angle brackets notation <>. For instance, if you intend to perform a GET API call and pass the value of a Chatbot variable named “zip_code” in a query parameter also named “zip_code”, you can update as follows: https://endpoint.com?zip_code=<zip_code>.