In this section, we'll learn how to send data from our project off to an external code base. 

We're going to be making use of the same handy sample API endpoint that we used in our last tutorial to create a user and update it at our endpoint.

This time, we'll be creating an entity on their server, so we'll be using a POST request. 

As mentioned in part 1, POST requests help us create new entities on the server we are sending our request to.

Once we have set our URL endpoint, we need to set the Header that we will be sending over. POST requests are a little bit more tricky than GET requests because we are not simply fetching data so there is an extra step. We will need to set a Header and a Body. 

For the vast majority of projects, we will be sending JSON requests, so we can set our Header to:

key: Content-Type
value: application/json

This is just a fancy way to tell Voiceflow that we are sending JSON to the server so that no mishaps happen along the way.

Next we want to fill our body. We can input any value we want in here as we are creating it ourselves.

For our example, we'll use the example above. Whatever value we put for either the key or the value should work. 

To test that this is working, we'll set a value to the variable and see whether our value is being passed back.

Lets set a variable named "first_name" to the value of name.

Note that all values taken in from our response needs to be preceded by "response." so for our purposes, we'll set "first_name" to ""

Lets head into our test tool and see if we are receiving the correct name.


Although we can not see the response inside Voiceflow just yet (coming soon), this is the response that is being sent back to us. We can access any thing inside of this entity including the "id" and "createdAt" values.

I'm going to set the value of first_name equal to "response.createdAt" to demonstrate.

Above we see that we are displaying the value of "createdAt" in our test tool. 

Since we are creating this entity, we can update it to be whatever you want. I'm going to change first name to "Andrew".

After setting our variable "first_name" back to "", we can go back into the test tool, and see we are now printing out "Andrew".

This brings us to the end of tutorial on sending data to external code bases. 

Other Resources:

To see our other tutorials on API requests check out:

Still have questions? Did we miss something? Have a suggestion? 

Did this answer your question?