How to Pass Data from a Specific Google Sheets Cell to a Chatbot

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

With the help of such a scenario, you can check the inventory of goods in your warehouse, the number of available apartments, prices based on the exchange rate, or a promotional code, and provide the user with up-to-date information.

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 the flow of your chatbot.

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 build a scenario by requesting a value from a specific cell — for this, add this cell to the parameter as cell = B2.

You can also request a value from a cell that the user requested. If you saved this value through "User input" — add this cell to the parameter as cell = {{cell}}.

Click the Test request button to send the request to Integromat and recognize the received data.

When Integromat receives the webhook, you will see a "Successfully determined" message 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 "Get a cell" action.

Connect your Google Account, select a spreadsheet and sheet.

Choose a cell of the spreadsheet you will read. It can be a static cell (like B2) or a cell that you can pass from a chatbot (like a cell).

Please note: if you do not have a variable of the form 3.cell (where 3 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 where you configured the webhook. 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 Value that the previous "Get a Cell" block returns, and write it to the variable val — this value will be returned to the chatbot:

{"val":" 4.Value"}

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 the message as a variable. Or, you can display the data to the user once, without saving, 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 checkmarks 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 the Scenario History

Navigate to the scenario you need. You will have access to a diagram of all of blocks with their execution history.

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

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 Data from a Specific Google Sheets Cell to a Chatbot"

User Rating: 5 / 5 (4)

    Other useful articles

    Popular in Our Blog

    Try a free chatbot for Facebook Messenger