Wcapi
Register
  • πŸ““1.Set up Your Meta Developer Account
  • 2.Connect WhatsApp cloud Api to Wcapi Platform
  • Add Meta Token & ID
  • How to verify a Meta Business Manager account
  • How to Create templates on WhatsApp cloud API (Step by Step) With Wcapi
  • OBA (Official Business Account) verification
  • How to Create a Template in Wcapi flatform
  • Docs WhatsApp Business Platform Pricing
  • Integrating WhatsApp Webhook with Google Sheets Using Wcapi
Powered by GitBook
On this page

Integrating WhatsApp Webhook with Google Sheets Using Wcapi

PreviousDocs WhatsApp Business Platform Pricing

Last updated 3 months ago

Introduction WhatsApp integration is a game-changer for businesses looking to streamline communication. With Wcapi, you can efficiently manage WhatsApp messages by forwarding webhook payloads to a endpoint. This guide will walk you through setting up a Google Apps Script to capture incoming WhatsApp messages in a spreadsheet for easy tracking and analysis.


Step 1: Setting Up Your Google Sheet

  1. Open Google Sheets and create a new spreadsheet.

  2. Copy the spreadsheet ID from the URL (it looks like a long string of random characters).

  3. Navigate to Extensions > Apps Script to open the script editor.


Step 2: Writing the In the script editor, paste the following Google Apps Script code:

/function doPost(e) {
var sheet = SpreadsheetApp.openById(β€œYour-endpoint”).getActiveSheet();
var data = JSON.parse(e.postData.contents);
sheet.appendRow([
new Date(), // Timestamp
data.contact.phone_number || β€œβ€,
data.contact.uid || β€œβ€,
data.contact.first_name || β€œβ€,
data.contact.last_name || β€œβ€,
data.contact.email || β€œβ€,
data.contact.language_code || β€œβ€,
data.contact.country || β€œβ€,
data.message.whatsapp_message_id || β€œβ€,
data.message.replied_to_whatsapp_message_id || β€œβ€,
data.message.is_new_message || β€œβ€,
data.message.body || β€œβ€,
data.message.status || β€œβ€,
data.message.media ? data.message.media.type : β€œβ€,
data.message.media ? data.message.media.link : β€œβ€,
data.message.media ? data.message.media.file_name : β€œβ€,
data.message.media ? data.message.media.original_filename : β€œβ€
]);
return ContentService.createTextOutput(β€œSuccess”).setMimeType(ContentService.MimeType.TEXT);
}

Step 3: Deploying the Script as a Web App

  1. Click Deploy > New Deployment.

  2. Select Web App as the deployment type.

  3. Set access permissions to Anyone.

  4. Copy the generated URL; this will be your webhook endpoint.


  1. Go to your Wcapi dashboard.

  2. In the webhook settings, paste the deployment URL from Google Apps Script.

  3. Save and activate the webhook.


Step 5: Testing the Integration Send a test message to your WhatsApp bot, and check if the message details appear in your Google Sheet. If everything is set up correctly, new messages will automatically be logged.


Conclusion By integrating Wcapi’s WhatsApp webhook with Google Sheets in real-time, you can automate message tracking and streamline customer interactions. This simple yet effective setup ensures that all incoming messages are recorded for further analysis and workflow automation.

Replace "Your-endpoint" with your Google Sheets ID.

Step 4: Connecting Webhook to Google Sheets

Google Sheets
Google Apps Script
Wcapi