API Step

Tahsim Ahmed
Tahsim Ahmed
  • Updated

API Step - How do I make API Calls? How do I connect my Voiceflow to APIs?

The API Step allows you to make custom API calls to connect your assistant with external APIs and data.

The API block consists of several parts:

  • The request type- GET, POST, PUT, DELETE, PATCH (1)
  • The endpoint- request URL (2) or {variable}
  • Headers, Body and Params- respective (3) parameter keys & values (can input raw body content code)
  • Capture Response- entering respective keys & saving/capturing to variables (4)
  • Send Request- test the API Step or call/request directly from Canvas (5)

There are 5 standard request types (1) available through the API block.

  • GET - Retrieves information from your data source
  • POST - Creates information in your data source
  • PUT - Completely updates information in your data source
  • DELETE - Deletes information in your data source
  • PATCH - Partially updates information in your data source

Depending on your assistant design, you should consider using an API step for functions that involve retrieving data from an external database or sending data to another source. Some use cases involve making a new Zendesk (or other similar customer support platforms) ticket request, sending and getting data from an Airtable database, or registering a potential client prospect in an internal repository. 

Endpoint

The endpoint (2) is the URL that points to your API. Similar to website URL, your endpoint URL is where your requests will be sent to speak with your API. You can also configure endpoints with { variables }.

An example API endpoint could look like the following:

<https://api.twitter.com/1.1/search/tweets.json>

Headers, Body and Params

Your API may need additional information (3) in order to give you information. This information can include data like Usernames, Passwords, Authentication tokens, etc. Typically these field(s) will be provided by your API provider in their documentation.

Capture Response/Saving to Variables

Once you have successfully made an API call, you will receive back a JSON object. Once you have this, you will likely want to save some of the information you got back onto Voiceflow to speak back to the user, send to another API or compare to something that a user has said.

You can do this using the "Capture Response" section. Simply copy the object path or key, and paste it into the text box. Then select a variable that you would like to save to/apply to.

Send/Test Request

Testing the request will allow you to make sure that your API call is working before moving on in your assistant. If it succeeds, you will see a message saying "Success".

You can click on the copy icon beside portions of the JSON to copy the object path and save it into a variable.

Certificate Upload

If required, you can also upload your SSL/TLS certificates directly to the API block for establishing a handshake between Voiceflow and your server.

To do this, select the settings button and then select Add Certificates.

Screen_Shot_2022-11-03_at_9.44.54_AM.png

Here you can upload both your certificate and key . Once uploaded, you can now connect with your server to perform any request. Supported file types are .pem, .cert and .key.

Screen_Shot_2022-11-08_at_9.11.51_AM.png

Was this article helpful?

2 out of 25 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.