Webhook Guide – Google Sheets Integration

Automatically save WhatsApp logs or contact data from WMS Personal into your own Google Sheet using a webhook.

πŸ”§ How It Works

When a WhatsApp message or event triggers your webhook, WMS Personal will send a POST request containing message data to your specified URL. Using Google Apps Script, you can receive this data and store it directly into your Google Sheet β€” hosted for free by Google.

πŸͺ„ 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)
  ]);

  // Send a reply message
  var reply = "Thank you. Message Received.";

  // Return a JSON response (same format your WhatsApp system expects)
  return ContentService
    .createTextOutput(JSON.stringify({ reply: reply }))
    .setMimeType(ContentService.MimeType.JSON);

  return ContentService.createTextOutput("OK");
}

This script receives incoming webhook data from WMS Personal and writes it as a new row into your Sheet. It then sends a reply back "Thank you. Message Received."

πŸš€ 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 WMS Personal

  1. Login to your WMS Personal Dashboard
  2. Go to your Device Settings
  3. Paste your Google Apps Script Web App URL in the Webhook URL field
  4. Save and reconnect your device

Now, every incoming WhatsApp message will automatically be sent to your Google Sheet πŸŽ‰

πŸ“¬ Webhook Payload (POST)

Here’s an example of what WMS Personal will 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

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