Skip to content

Connect WhatsApp and Google Sheets

Save customer answers to a spreadsheet as they come in. A bot collects the details, an HTTP Request step sends them to a Google Apps Script, and the script adds a row.

This only uses the HTTP Request step, so the same idea works for any service that accepts a webhook. Google Sheets is just a handy example.

  1. Create a new Google Sheet.
  2. Add column headings:
Name | Phone | Email | Message | Date
  1. Click Extensions → Apps Script.
  2. Delete the code that’s there.
  3. Paste this:
function doPost(e) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = JSON.parse(e.postData.contents);
sheet.appendRow([
data.name,
data.phone,
data.email,
data.message,
new Date()
]);
return ContentService
.createTextOutput(JSON.stringify({status: "success"}))
.setMimeType(ContentService.MimeType.JSON);
}

Change the list inside sheet.appendRow([ ]) to match your own columns.

  1. Click Deploy → New deployment.
  2. Choose Web app.
  3. Under Who has access, choose Anyone.
  4. Click Deploy and copy the Web app URL.

In your bot, add an HTTP Request step from the Integrations group and open it.

The HTTP Request step settings

Setting Value
HTTP Method POST
URL Your Apps Script web app URL
Headers (JSON format) {"Content-Type": "application/json"}
Request Body (JSON format) See below

Put your bot’s variables into the body:

{
"name": "{{name}}",
"phone": "{{phone}}",
"email": "{{email}}",
"message": "{{message}}"
}

The step has Success and Failed outputs, so you can tell the customer if something went wrong.

Click Test API, then check your sheet for the new row.

Click Publish Now. From then on, every customer who reaches the step adds a row to your sheet.

  • Nothing arrives: check that the deployment is open to Anyone, and that you copied the web app URL, not the script editor’s address.
  • Rows have empty cells: a variable name in the body doesn’t match what the bot saved. Check the bot’s Logs for what was collected.

The same settings, method, URL and body, work for any API. Swap the Apps Script URL for your CRM or your own system and the bot sends data there instead.