Connect WhatsApp Webhooks to Google Sheets

Automatically save inbound WebWMS2U message data in your own Google Sheet using Google Apps Script—without hosting a separate server.

🔧 How It Works

When an enabled WebWMS2U automation rule triggers a webhook, WebWMS2U sends a POST request containing message data to the URL you configured. Google Apps Script can receive that payload, append it to a Sheet and return a JSON reply.

🪄 Step 1: Create Your Google Sheet

  1. Go to Google Sheets and create a new Sheet (e.g., WhatsApp Logs).
  2. In Row 1, create headers such as:
    Phone | Message | Timestamp

⚙️ Step 2: Add Google Apps Script

In your Sheet, go to Extensions → Apps Script and paste this code:

function doPost(e) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var data = JSON.parse(e.postData.contents);

  // Append webhook data to the sheet
  sheet.appendRow([
    data.from || '',
    data.message || '',
    new Date(data.timestamp * 1000)
  ]);

  // Return a reply in the format expected by WebWMS2U
  return ContentService
    .createTextOutput(JSON.stringify({ reply: "Thank you. Message received." }))
    .setMimeType(ContentService.MimeType.JSON);
}

This script receives inbound webhook data from WebWMS2U, writes a new row and returns the reply “Thank you. Message received.” Adapt the field names if your webhook configuration sends a different payload.

🚀 Step 3: Deploy as Web App

  1. Click Deploy → New deployment
  2. Choose Web app
  3. Under Execute as, select Me
  4. Under Who has access, select Anyone
  5. Click Deploy and copy your Web App URL, e.g.
    https://script.google.com/macros/s/AKfycbx123abcXYZ/exec

🔗 Step 4: Connect Your Webhook in WebWMS2U

  1. Log in to your WebWMS2U dashboard.
  2. Open the applicable Personal WhatsApp automation or keyword settings.
  3. Enable the webhook action and paste your Google Apps Script Web App URL.
  4. Save the rule, send a test keyword and confirm that a new row appears.

Only messages that match and trigger the configured automation rule are forwarded. Unmatched incoming messages are not sent to this webhook.

📬 Webhook Payload (POST)

Here’s an example of the data WebWMS2U can send to your webhook URL:

{
  "user_id": 123,
  "device_id": "abc123",
  "whatsapp_id": "60123456789@s.whatsapp.net",
  "from": "60123456789",
  "message": "Hi, can I get more info?",
  "message_id": "XYZ987654",
  "timestamp": 1722337200
}

💡 Optional Enhancements

🔒 Security Tips

For production integrations, also review the WebWMS2U webhook guide and API documentation.

Start Logging to Google Sheets Today

It only takes 5 minutes to set up your free Google-hosted webhook — no server required!

Create Your Free Account