Table of Contents

Connecting MySQL with Make.com (formerly Integromat)

Jonathan Goodfellow Updated by Jonathan Goodfellow

We will demonstrate how to run queries in MySQL and send the information to Landbot.

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

1. Prepare the "Trigger Automation" block on our bot.

2. Set up the trigger in Make.com to start the scenario automation

3. Set up a scenario to request external information using the information sent from Landbot, we will use MySQL in this example, but it can be adapted to other apps.

4. How to use the data collected from Make.com and using Landbot API, we will display the data collected from MySQL.

5. Resume the bot flow to a specific block using the Landbot API

As you noticed, the "Trigger Automation" block is not connected to the next block. This 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 scenario with Trigger automation block

Prepare Landbot

The information we collect will be stored in variables and sent to Make.com. As in the example below, we are storing the email entered in the @email variable for later use.

We connect our email question block to a set of variable block so we can create the variable @data, which will be an array and its value will be "{}" so we can store the JSON response as an empty object.

Then let's set a "Trigger Automation" block.

Then set 3 formulas:

GetValue(@data,"name")
GetValue(@data,"age")
GetValue(@data,"address")

GetValue returns the value of a path in an object or array. Like here, @data is the array, "name", "age" and "address" are the paths, the exact name, age and address are the values.

Since we didn't set an exact @data variable within Landbot when Make.com returns the data, it will be sent directly to the first formula block, but in JSON format.

Obviously, it is not an appropriate answer format for our clients. Therefore we use GetValue, to extract only the values.

After that, create 3 messages, with the variables @name, @age, and @address inside:

Create Make.com scenario

After creating our bot, we open Make.com, once inside we must click on "Create a new scenario". We can look for the icon we need and it will be "Webhook" and finally, we click on "Continue".

Integromat will ask you to select the type of Webhook, choose Custom Webhook. After clicking on Custom Webhook, a small window will appear:

We need to click the "Add" button and give the hook a name, in this case, it will be called Mysql Test.

Don't be in a rush to click on "OK", we still have to copy the API address:

Prepare Landbot request to Make.com

Let's go back to Landbot and paste the URL into the "Trigger Automation" block:

Now we are going to set the variables we want to send to Make.com. We will send the variable @email and @id that we will use to find the information on our database. To do that we pass the variables on the Trigger Automation Block,@email set it equal to "luis@test.com", @id set it to 1234, and click on "Test webhook trigger".

Now we see a green sentence 'Successfully determined' this means Integromat has received our variables.

And now you can click on OK,

Let's press the button Run once, to run the module for the test, and let's turn back to Landbot, open your bot builder, go to Share > Share with a link > Open, then complete the chat.

We have seen that above the icon of Webhooks, there is a 1 in the bubble, let's click on it:

Add a new module of MySQL

Move the mouse to the bubble of Webhook, and click on the button of Plus on the right side:

Then set the action event as "Execute a query (advanced)":

It displays this window:

Now we have to be sure that we comply with all the requirements that Make.com asks us to be able to connect our database, you can find more information at the following link:

MySQL App Help Docs Integromat

Prerequisites for a successful connection:

  • A MySQL server connection
  • A Configured MySQL server

We can look for our public ip address on Google typing "what is my ip".

Please make sure you set the port forwarding on your router otherwise it will not work.

Creating and Granting Remote Access to Your MySQL Account.

To grant access to a user we need to run the following query:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Once we have executed it we should have the following message in our database:

The database we use is the following:

We return to Make.com and now we have to give our connection a name, then we will have to enter our public IP, the port of our database, its name, the MySQL user, and the password of the user to whom we have given the permissions.

We have to introduce the following query in the reserved space and we introduce the variable that we brought from Landbot with the Webhook.

SELECT name,age,address FROM persons WHERE email = '{{2.email}}';

And now you can click on OK:

We need to click "Run once" for the scenario to listen to the data, then we go back to our bot and click Share> Share with a link> Open. We can check that Make.com has received our variables from the database and saved them.

In the following image we can see that the variables are in the Output:

Set action event and method

Let's move the mouse to the right side of the MySQL bubble and click the Plus button, search for HTTP, and then click on it:

Then select Make a request:

In the method, let's select Put:

Get Landbot API URL

Now let's open the documentation of Landbot API:

Copy the URL of API:

Then turn back to Make.com and paste it to the URL:

Insert the customer ID and adapt the variable name

Go to Make.com, replace ":customer_id" with the ID we sent:

And after that, replace ":field_name" with data:

Set the body type, content type, and request content

Inside of the body type we choose RAW, where appears Content type inside of it we choose JSON(application/JSON):

Now let's set the Request content with this JSON code:

{ 
"type": "object",
"value": {
"name":"",
"age":"",
"address":""
}
}

Then we complete the code with the data we have sent before:

Get API token and set headers in Make.com

Now let's turn to Landbot to get the token, by clicking on the avatar > account, scroll down, in the API token, and copy it:

Go to Make.com, scroll up, and press Add a header :

Below the name, we type in Authorization, and below the value, we type in Token XXXXXXXXXXXXXXXXXX

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

Then click on Add:

Scroll down and press OK:

Set up the actions through Make.com: Customers - Assign bot

Let's set another HTTP module:

In the method let's select PUT:

Get Landbot API URL

Then let's go to the Landbot API documentation, and go to Assign Bot:

Then copy the URL:

Then turn back to Make.com, and paste it:

Set the customer ID and Bot ID in the URL

Then replace ":customer_id" with the number we got from the first Webhook module:

To get the bot ID, let's open Landbot builder, and find its URL, copy the number before builder:

Turn back to Make.com, and replace "bot_id" with it:

Set the body type, content type, and request content

Turn back to API documentation, copy the body (there's a body we actually need below):

Inside of body type we choose RAW, appears Content type inside of it we choose JSON(application/json):

Then open Make.com, and paste the following into request content:

{ "launch": true,
"node": "XXXXXXXX"
}

To get the node, let's open Landbot, and click the first formulas block with right-click, press copy reference:

Then back to Make.com, replace the code after the node with it:

Get API token and set headers in Make.com

Now let's turn to Landbot to get the token, by clicking on the avatar > account, scroll down, in the API token, and copy it:

Go to Make.com, scroll up, and press Add a header :

Below the name, we type in Authorization, and below the value, we type in Token XXXXXXXXXXXXXXXXXX

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

Then click on Add:

Scroll down and press OK:

The whole scenario is done, it should be like this:

To make the scenario works automatically, we have to activate it, so let's turn on the scheduling, and select Immediately:

The whole flow should work like this:

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

How did we do?

How to upload a file to Google Drive using Make.com (formerly Integromat)

Contact