Table of Contents

How to extract data from an external source with Zapier and use it in Landbot

Alexander Gao Updated by Alexander Gao

Introduction

On some occasions we might want to extract information from an external database (like a CRM, Excel, Salesforce...) based on the inputs from the user in the bot, and use that external data inside the bot.

To do that, Zapier can help you to request such information, but we need to push a little bit further, to prepare Zapier to send Landbot such information, and once it's ready "tell" the bot to resume flow.

To do this in the article we will show you how to:

  • 1. Set up in Zapier the trigger to start the Zap automation
  • 2. Prepare the Automation trigger in Landbot that will trigger the Zap with the information needed (user data and the customer id "@id)
  • 3. Set up Zapier to request external information using the information sent from Landbot, we will use Google Spreadsheets in this example, but it can be adapted to other apps
  • 4.Use the data collected from Zapier and using Landbot API, create a variable in Landbot with the values we collected
  • 5. Resume the flow from a specific block using Landbot API
  • 6. Extract the data from the variable we created before to be used after

Below is an example of the flow:

  • a. Collect the data with Question blocks
  • b. Trigger Zapier with a trigger automation block
  • c. Use formulas to extract values from the recently created variable

As you noticed the trigger automation block is not connected to the next block. That is because, we will use the Landbot API to tell the bot to "jump" to a specific block, once we have the data ready in Landbot. This method is called "Assign bot".

Trigger zap with trigger automation block

Prepare Landbot
  1. Firstly, we have to make a little flow for collect information, like email.
The information that we collect, will be stored in variables, that we will send to Zapier. As in the example below, we are storing the name input in the variable @email, that we will use later
  1. To get @id we need, we have to set a message block, to get the exact id.

  1. Then let's set a Trigger automation block.
  1. Then set 3 formulas block, with
GetValue(@data, "name") 
GetValue(@data, "email")
GetValue(@data, "age") 

inside of each other.

GetValue returns the value at path in an object or array. Like here, @data is the array, "name", "email" and "age" from Google sheets (where we will extract data) are the paths, the exact name, email and age are the values:
Firstly we didn't set an exact @data inside of Landbot, when Zapier returns the data, they will be directly sent to the first formulas block, but in JSON format, like the one in the image: obviously it is not appropriate answer format for our clients. Therefore we use GetValue, to extract only the values (ex. alex, fatimimi@gmail.com, 24).
  1. After that, create 3 messages, with the variables @name, @email, and @age inside:
Create Zap trigger
  1. After set the whole flow, let's open Zapier:
  1. We need to do is click on Make A Zap:
  1. Then search Webhook:
  1. Then click on it, below Trigger Event, we just have to choose Catch Hook and we press continue:
  1. Copy the hook URL and press CONTINUE
  1. Then this screen will display, don't press the Test trigger yet, we will do it later:
Prepare Landbot request to Zap
  1. Let's get back to Landbot and paste the URL to Trigger automation block:
  1. Now we are going to set the testing values to send to Zapier:
As you can see we added @id. That is because we need to make sure we send the data to the specific customer. Without @id, we won't be able to send any data back to Landbot or resume the flow

  1. Then let's open the chat, go to Share > Share with a link > Open, then complete the chat:

As you can see here, we set a random value for @id, because it's Landbot's adaptive variables, Landbot will set it for you automatically.
In Zapier check request data
  1. Now we turn back to Zapier.
  2. And now you can Click on Test trigger, to check the information we have sent from the trigger automation block test:
  1. Once we press Test trigger, if everything goes well, you will see the page below with the variables and values we used in the test:

Yes, the @name, @email, @age and @id are the same that we sent to Zapier: This is how the trigger works, we send variables to Zapier, they receive, and when we try to test it as we did in step 13, it will be shown. After we turn on Zap, the whole progress will be doing it automatically.
  1. So far the trigger part is done, which means that after the trigger we have to do a lot of work on actions in Zapier. Also in following steps, we don't have to set anything inside of Landbot, but leave them to Zapier.

Now let's press continue 

  1. Choose Google Sheets:
  1. Then set action event as Lookup Spreadsheet Row:
  1. Then login your google account:
  1. Then we set our test sheet well, (in the image is Test inte), the page, and the variables we want to approve. Here before I have put name, email, and age:

  1. Let's set up the reference of search:
  2. Press Save & Continue:

  1. Finally we can test our trigger and action integration!

  1. Click on Test & Continue,

Webhook is a premium function of Zapier, unless you can turn on it, just click on test the request in trigger automation block of Landbot won't send the information right to the Sheet.

  1. Now we disconnect trigger automation block and formulas block, because @data will be analyzed by the formulas block once Zapier sends data to the bot, which means it will start with the first formulas block when it gets the data:

Set up the actions through Zapier: CustomerFields - Create

Set action event and method
  1. Complete the trigger and first action:

  1. Click on the button of plus:

  1. Search for Webhooks and click it:

  1. In the Action event, select Custom Request and press continue:

  1. In the method, let's select Post:

Get Landbot API URL
  1. Now let's open the documentation of Landbot API:

  1. Copy the URL of API:

  1. Then go back to Zapier and paste it to the URL:

Insert the customer ID and adapt the variable name
  1. Go to Zapier, replace :customer_id with the ID we sent:
  1. And after that, replace :field_name with data:
Set the Request body
  1. Now let's set the Data with this JSON code:
{ 
"type": "object",
"value": {
"name":"",
"email":"",
"age":""
}
}

  1. Then we complete the code with the data we sent before:

Get API token and set headers in Zapier
  1. Now let's turn to Landbot to get the token, by clicking on the avatar > account, scroll down, in the API token:

  1. Copy it:

  1. Go to Zapier, below the header we set like this:

Authorization Token XXXXXXXXXXXXXXXXXX

(You can also check at the top of Landbot API documentation, at General )

  1. And then click on the plus button, to add one more header:

  1. Type in below header:

Content-Type application/json

  1. Press Save & Continue:

  1. It displays this page:

  1. Scroll down and press Test & Continue:

Set up the actions through Zapier: Customers - Assign bot

Set action event and method
  1. Now let's set another Webhook action:

  1. In the Action event, select Custom Request and press continue:

  1. In the method, let's select Put:
Get Landbot API URL
  1. Then let's go to Landbot API documentation, and go to Assign Bot:

  1. Then copy the URL:

  1. Then turn back to Zapier, and paste it:

Set the customer ID and Bot ID in the URL

  1. Then go to Zapier, replace :customer_id with the number we got from Catch Hook:
  1. To get the bot ID let's open Landbot builder, and find its URL:
  1. Copy the number before builder:

  1. Turn back to Zapier, and replace :bot_id with it:

Set the Request body
  1. Turn back to API documentation, copy the body (there's a body we actually need below):
{ "launch": true,
"node": "XXXXXXXX"
}
  1. Then open Zapier, paste it to Data:

  1. Replace False with true, and delete the sentence after the asterisk:

  1. To get the node, let's open Landbot, and click the first formula block with a right click, press copy reference:
  1. Then go back to Zapier, replace the code after node with it:

Get API token and set headers in Zapier
  1. Now let's turn to Landbot to get the token, by clicking on the avatar > account, scroll down, in the API token:

  1. Copy it:

  1. Go to Zapier, below the header we set like this:

Authorization Token XXXXXXXXXXXXXXXXXX

(You can also check at the top of Landbot API documentation, at General )

  1. And then click on the plus button, to add one more header:

  1. Type in below header:

Content-Type application/json

  1. Press Save & Continue:

  1. It displays this page:

  1. Press Test & Continue:

  1. It displays this page, successfully sent:

  1. The whole flow should work like this:

Yes, the information we sent before appears, the action is completed!

How did we do?

Get Opt-ins (Subscribers) from Facebook Leads using Zapier

Zapier trigger

Contact