Last updated December 25th, 2018
We have a whole section on the API block and the different kinds of functions you can perform with it. To access this section look for "API & Integration Tutorials" in the Voiceflow University menu.
What you'll learn:
- How to use the API block to send requests to outside services
- How to use the Endpoint Tool to test whether your requests are working successfully.
- A general walkthrough of the different tools within the API block
- Insight in to how responses work
API Block Overview
API blocks let us access code bases and integrations outside of Voiceflow easily and with little work. The API Block will retrieve data that is sent from outside sources and store them within your project so they can be used throughout your canvas.
There are several important portions to the above panel. Let's start with the drop down menu.
There are 5 different types of calls that we can make. Here is a short explanation of each:
GET: Retrieve some data from the external codebase
POST: Create some data to the external codebase
PUT: Update some data to the external codebase
DELETE: Delete data at the external codebase
PATCH: Apply partial modifications to data at an external codebase
Success and failure:
There are several status codes that API's can return us when we try to call them.
- 1xx (Informational): The request was received, continuing process
- 2xx (Successful): The request was successfully received, understood, and accepted. This is what we want every time.
- 3xx (Redirection): Further action needs to be taken in order to complete the request
- 4xx (Client Error): The request contains bad syntax or cannot be fulfilled
- 5xx (Server Error): The server failed to fulfill an apparently valid request
We don't need to worry about the majority of these codes. We just need to know that successful codes (2xx) will let us move on in our diagrams, and all others will be handled by the "fail" socket and we should specify an error message in case this happens, as demonstrated below:
To see it in action, checkout our tutorials on: