How to Pass Personalized Data from a Google Sheets Row to a Chatbot

You can integrate SendPulse chatbots with other services to request data via Integromat. In this article, we'll look at how to view data (numeric or text) from a specific row in Google Sheets.

With the help of such a scenario, you can check the personal information of a client or give it out to a user. You can identify a user (for whom the data is written in one row and one of the columns is identified) using any data in your chatbot and Google Sheets — subscriber ID, contact information, and more.

How to Get Started

Log into your Integromat account, and click the + Create a new scenario button to start creating a scenario.

You can choose which services to connect — in this case, we want Webhooks and Google Sheets — using the search or find and add them directly in the constructor. Click the Continue button in the upper right corner.

How to Create a Webhook

Click on the block with the question mark at the center of your screen and select the "Webhooks" block — this block starts the flow.

You need to create a webhook that sends data from your chatbot flow. Select the "Custom webhook" block from the drop-down list.

Click the Add button to create a new webhook.

Enter a webhook name and click the Save button.

Your webhook has been created. Copy the link — you need to paste it into your chatbot flow.

Now, Integromat waits to receive the first webhook to determine the data structure it will need to work.

Log in to your SendPulse account. Select the bot you need and open the flow in the chatbot flow builder.

Add and place the "API Request" element right after the element you want to send the webhook. Select the "GET" request type, and enter the URL copied from Integromat.

You can request a personalized value, such as a contact ID, by adding a parameter in the form contact_id = {{contact_id}} at the end of the URL. You can also pass contact information using the {{email}} and {{phone}} variables.

Click the Test request button to send the request to Integromat so the system can recognize the received data structure.

When Integromat receives the webhook, you will see a "Successfully determinedmessage in the "Webhooks" block.

Now you can add more elements.

How to Get Data from Google Sheets

Click on "Add another module" next to the "Webhooks" block and select "Google Sheets." Select the "Search Rows" action.

Connect your Google account, select a spreadsheet and sheet.

To read all of the table rows where column A is equal to the contact's passed email, in the first field of the "Filter" section, select your column with emails in Google Sheets, and in the second field, select the received parameter "Email" from the webhook (or 6.contact.id if the contact's ID was passed).

Please note: if you do not have a variable of the form 6.Email (where 6 is the block number in Integromat, in which you received this variable from the chatbot), click the Run once button in the bottom left corner and start the flow in the chatbot you configured the webhook for. After the first flow runs, the variable will appear in Integromat.

Click the OK button.

How to Pass a Record from Google Sheets to a Chatbot

Click on "Add another module" next to the table block. Choose "Webhooks" > "Webhook response."

In the "Body" field, select the values ​​from the table that will be returned to the chatbot and write them in JSON format:

{"variable_name": "column_from_google_sheets", "variable_name": "column_from_google_sheets"}

Click the OK button to save the parameters.

Go back to editing your chatbot flow in your SendPulse account.

You can save the resulting value to a variable to use a filter and add it to a message as a variable. Or, you can display the data to the user once, without saving it as a variable, using an expression like {{$['variable']}}. Read more: Using Data as a JSON Path Expression.

Place the "Message" element just after the "API Request" element, and add a variable or JSON path expression.

Save and Run

Before saving and exiting, ensure that everything works correctly.

Click the Run once button and run the flow you configured the webhook for. If you have configured everything correctly, green check marks will appear under the Webhook and Google Sheets blocks.

You can also click on the number above the block to view the received information transmitted to the next block.

To activate the scenario, move the toggle switch to the "ON" position.

How to View Scenario History

Navigate to the script you want. In the "Last runs" or "History" tab, click "Details" for the desired operation. You will be presented with the block execution history diagram.

Click on the required block to view information about it. You will have access to all the information in the block — what values ​​it received and transmitted.

If any of the blocks have not been executed, they will be highlighted in red, and when pressed, the reason for the error and a hint on how to fix it will be displayed. Note that the entire scenario may pause and not execute until the error is resolved; operations will be queued.

If you have any questions about configuration or scenario failures, you can contact Integromat support.

Rate this article about "How to Pass Personalized Data from a Google Sheets Row to a Chatbot"

User Rating: 5 / 5 (6)

    Other useful articles

    Popular in Our Blog

    Try a free chatbot for Facebook Messenger