What You'll Build
In this guide, you'll build a fully functional WhatsApp chatbot that receives messages via a webhook and responds intelligently. Unlike drag-and-drop builders, this approach gives you complete control over the conversation logic — connect any AI model, CRM, or database you want.
Prerequisites
Before you start, you'll need:
- A SocialHook account with WhatsApp Business API connected
- Node.js 18+ and a basic understanding of Express
- A public URL for your webhook (use ngrok for local development)
Step 1: Set Up Your Webhook Server
First, create a simple Express server that will receive webhook payloads from SocialHook. Every time a customer sends a WhatsApp message to your business number, SocialHook will POST a JSON payload to this endpoint.
Step 2: Verify Payload Signatures
Always verify that incoming requests are genuinely from SocialHook. Every delivery includes an X-SocialHook-Signature header containing an HMAC-SHA256 hash of the payload body, signed with your secret key.
Reject any request where the signature doesn't match — this protects your server from spoofed webhook calls.
Step 3: Parse the Payload
A typical WhatsApp message payload looks like this:
{"platform":"whatsapp","event":"message.received","from":"+1555001234","message":{"type":"text","body":"Hello!"}}
The platform field will always be whatsapp for WhatsApp messages. The event field tells you whether this is a new message or a new conversation start.
Step 4: Add Your Business Logic
Now the fun part. You can connect any service to respond to messages. For a simple keyword bot, check message.body for trigger words. For an AI-powered bot, forward the message to your preferred LLM API and send back the response.
Step 5: Deploy and Test
Once your server is working locally, deploy to any Node.js hosting provider — Railway, Render, Fly.io, or your own VPS. Update your SocialHook webhook URL to point to your production endpoint, and send a test message from WhatsApp to verify everything works end-to-end.