We developed the Call API skill to help you quickly call an API within your flow. You can then save and use the responses received from the external API in your chatbot's code and flows.
Calling an API involves making an HTTP request from Botpress to a named host on a server. The request aims to access a resource on the server. The following are the components of your request through which you will supply information to an API.
The request body is set in the interface below. Please ensure that your request body adheres to the syntax specified for the API you are calling.
The request headers can be set here and should respect the JSON format.
All APIs respond to every request with an HTTP status indicating whether the request was successful. The response typically comes along with a json response which may contain additional information. The Call API skill supports receipt and storage of this response in the following manner.
We use memory to save the response given by the API we are calling. By default, Botpress will save the response in
temp.response, but you can use the memory of your choice according to the use-case.
The saved response object looks like this:
"body": <Response Body>,
Success / Failure
When a response returns a status code
400 and above, the request will fail and will execute the
On failure transition. All other status codes will result in success and will execute the
On success transition.
Botpress supports templating in the
body and the
headers to access variables stored in memory. All
event memory types are accessible via templating.