How to Send and Receive Data from External Sources

Automating the data retrieval process has become even easier with API requests. You can request data about the information your user is interested in, create a customer profile, or register for an event in external systems. In response, you receive information that you can display directly in a message to the user or save it to a chatbot variable.

How to Send a Data Request

Drag the "API Request" element to the workspace, connect it to the element, after which, you want to get information.

Select the type of request:

  • A GET request is usually used to get existing data;
  • A POST request is usually used to create a new object in the system and obtain information about it.

Enter the URL to send the request to. You can use your chatbot variables in the request.

You can also add request headers, for example, to authorize requests.

If you are using a POST request, in the required field enter the request body in JSON with parameters.

Click on "Test Request" to check the submission of the data. Also, this test is useful for data recognition for the next settings.

How to Use the Received Data

If the response is successful, you will receive the response body.

You can use the received data in the next element or save it to a chatbot variable for repeated use.

Using Data by Saving it to a Variable

To save the data as variables for future use, in the "API Request" element in the mapping settings, click "Add."

From the response field, select the key whose variable value you want to use.

Select the variable to store the value into.

When you have saved the required number of variables, click "Apply" and proceed to create the next element.

In this example, we created an order, received data from our CRM, saved it as variables, and informed the user to quickly identify the service or product they ordered.

As a user, communicating with your chatbot looks like this:

Using data as a JSON Path expression

If you do not need to write data to variables, you can use the received information by inserting a JSON path expression of the structure.

To do this, after checking the request and receiving a successful response, click "Add", find your variable and copy the JSON Path from the response field.

Then click “Apply” and proceed to create the next item.

Note that data that you are not writing can only be used once in the next text block.

In the text message, add JSON Path {{$ ['somekey'] ['nestedkey']}}.

As a user, communicating with your chatbot will look like this:

Rate this article about "How to Send and Receive Data from External Sources"

User Rating: 5 / 5 (7)

    Other useful articles

    Popular in Our Blog

    Try SendPulse today for free