The WhatsApp Business API lets you send messages to customers on WhatsApp programmatically. Connecting InstantDM to WhatsApp creates a multi-channel experience - capture leads via Instagram DMs and follow up on WhatsApp, where open rates are significantly higher than email.
Why Connect InstantDM to WhatsApp?
- 90%+ open rates - WhatsApp messages get read far more than email
- Rich messaging - send images, documents, buttons, and list messages
- Global reach - WhatsApp is the dominant messaging app in most countries outside the US
- Template messages - send pre-approved messages outside the 24-hour window
- Multi-channel - reach leads on Instagram AND WhatsApp
Common Use Cases
- Send a WhatsApp confirmation after capturing a lead via Instagram DM
- Follow up on WhatsApp if the lead didn't respond to email
- Send product catalogs or PDFs via WhatsApp
- Alert your sales team on WhatsApp when a high-intent lead comes in
- Continue the conversation on WhatsApp for leads who prefer it
What You'll Need
| Requirement | Details |
|---|---|
| InstantDM account | Trendsetter, Trendsetter Pro, or any Multi plan |
| WhatsApp Business API access | Via Meta Business Suite or a BSP (Twilio, MessageBird, etc.) |
| InstantDM API key | Found at Settings → API in your InstantDM dashboard |
| Approved message templates | Required for sending messages outside the 24-hour window |
Important: The WhatsApp Business API is different from the WhatsApp Business App. The API requires approval from Meta and is accessed through a Business Solution Provider (BSP) or directly via Meta's Cloud API.
Option A: Via Twilio (Recommended BSP)
Twilio is the easiest way to access the WhatsApp Business API.
Step 1: Set Up Twilio WhatsApp
- Sign up at twilio.com.
- Go to Messaging → Try it out → Send a WhatsApp message.
- Follow the sandbox setup for testing, or apply for a production WhatsApp number.
- Note your Account SID, Auth Token, and WhatsApp number.
Step 2: Create a Webhook Receiver
const express = require('express');
const app = express();
app.use(express.json());
const TWILIO_SID = process.env.TWILIO_ACCOUNT_SID;
const TWILIO_AUTH = process.env.TWILIO_AUTH_TOKEN;
const WA_FROM = 'whatsapp:+14155238886'; // Your Twilio WhatsApp number
async function sendWhatsApp(to, body) {
const response = await fetch(
`https://api.twilio.com/2010-04-01/Accounts/${TWILIO_SID}/Messages.json`,
{
method: 'POST',
headers: {
'Authorization': 'Basic ' + Buffer.from(`${TWILIO_SID}:${TWILIO_AUTH}`).toString('base64'),
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
From: WA_FROM,
To: `whatsapp:${to}`,
Body: body,
}),
}
);
return response.json();
}
app.post('/instantdm-webhook', async (req, res) => {
const { event, data } = req.body;
if (event !== 'flow_completed') {
return res.status(200).json({ status: 'skipped' });
}
const phone = data.response_variables?.phone;
if (!phone) {
return res.status(200).json({ status: 'skipped', reason: 'no phone' });
}
try {
const name = data.response_variables.full_name || 'there';
const message = `Hi ${name}! 👋 Thanks for connecting with us on Instagram. Here's the info you requested about ${data.response_variables.interest || 'our services'}. Feel free to reply here if you have any questions!`;
const result = await sendWhatsApp(phone, message);
res.status(200).json({ status: 'sent', sid: result.sid });
} catch (error) {
res.status(500).json({ status: 'error', message: error.message });
}
});
app.listen(3000);
Option B: Via Meta Cloud API (Direct)
Step 1: Set Up Meta Cloud API
- Go to developers.facebook.com.
- Create a new app or use your existing Meta app.
- Add the WhatsApp product.
- Get a System User Access Token with
whatsapp_business_messagingpermission. - Note your Phone Number ID and Business Account ID.
Step 2: Create Message Templates
Before sending messages outside the 24-hour window, you need approved templates:
- Go to WhatsApp Manager → Message Templates.
- Create a template:
Template name: instagram_lead_welcome Category: Marketing
Language: English
Hi {{1}}! 👋
Thanks for connecting with us on Instagram. We've received your info and will follow up shortly.
In the meantime, here's what you requested about {{2}}.
Reply to this message if you have any questions!
- Submit for approval (usually takes minutes to hours).
Step 3: Build a Webhook Receiver
const express = require('express');
const app = express();
app.use(express.json());
const WA_TOKEN = process.env.WHATSAPP_TOKEN;
const PHONE_NUMBER_ID = process.env.WA_PHONE_NUMBER_ID;
app.post('/instantdm-webhook', async (req, res) => {
const { event, data } = req.body;
if (event !== 'flow_completed') {
return res.status(200).json({ status: 'skipped' });
}
const phone = data.response_variables?.phone;
if (!phone) {
return res.status(200).json({ status: 'skipped' });
}
// Remove the '+' prefix for WhatsApp API
const waNumber = phone.replace('+', '');
try {
const response = await fetch(
`https://graph.facebook.com/v18.0/${PHONE_NUMBER_ID}/messages`,
{
method: 'POST',
headers: {
'Authorization': `Bearer ${WA_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
messaging_product: 'whatsapp',
to: waNumber,
type: 'template',
template: {
name: 'instagram_lead_welcome',
language: { code: 'en' },
components: [
{
type: 'body',
parameters: [
{ type: 'text', text: data.response_variables.full_name || 'there' },
{ type: 'text', text: data.response_variables.interest || 'our services' },
],
},
],
},
}),
}
);
const result = await response.json();
res.status(200).json({ status: 'sent', messageId: result.messages?.[0]?.id });
} catch (error) {
res.status(500).json({ status: 'error', message: error.message });
}
});
app.listen(3000);
Via Make.com
- Set up the webhook scenario as described in the Make.com guide.
- Add a Filter:
eventequalsflow_completedANDdata.response_variables.phoneis not empty. - Add an HTTP → Make a request module (or Twilio module if using Twilio).
- Configure the API call to your WhatsApp provider.
Message Types
Text Message
Simple text - works within the 24-hour conversation window.
Template Message
Pre-approved templates - required for initiating conversations or messaging outside the 24-hour window.
Media Message
Send images, documents, or videos:
{
"messaging_product": "whatsapp",
"to": "1234567890",
"type": "image",
"image": {
"link": "https://yoursite.com/product-image.jpg",
"caption": "Check out this product you asked about!"
}
}
Interactive Message (Buttons)
{
"messaging_product": "whatsapp",
"to": "1234567890",
"type": "interactive",
"interactive": {
"type": "button",
"body": { "text": "Thanks for your interest! What would you like to do next?" },
"action": {
"buttons": [
{ "type": "reply", "reply": { "id": "pricing", "title": "View Pricing" } },
{ "type": "reply", "reply": { "id": "demo", "title": "Book a Demo" } },
{ "type": "reply", "reply": { "id": "catalog", "title": "See Products" } }
]
}
}
}
Troubleshooting
| Issue | Solution |
|---|---|
| Message not delivered | Check the phone number format (no + prefix for Meta API, whatsapp:+ prefix for Twilio). Verify the recipient has WhatsApp. |
| Template rejected | Review Meta's template guidelines. Avoid promotional language in utility templates. Resubmit with changes. |
| 24-hour window expired | You must use an approved template message to re-initiate the conversation. Free-form messages only work within 24 hours of the user's last message. |
| Error 131026 (not opted in) | The recipient hasn't opted in to receive messages from your business. They need to message you first or opt in via another channel. |
| Sandbox limitations | Twilio's WhatsApp sandbox only works with numbers that have joined the sandbox. Use a production number for real users. |
Frequently Asked Questions
Do I need a separate WhatsApp number?
Yes. The WhatsApp Business API requires a dedicated phone number that isn't registered with the regular WhatsApp app. You can use a Twilio number or register your own business number.
What's the 24-hour conversation window?
After a user messages you (or you send a template message), you have 24 hours to send free-form messages. After 24 hours, you can only send pre-approved template messages. This is Meta's policy to prevent spam.
How much does WhatsApp Business API cost?
Meta charges per conversation (not per message). Pricing varies by country and conversation type. Marketing conversations cost more than utility conversations. Check Meta's pricing page for current rates.
Can I use the same Meta app for Instagram and WhatsApp?
Yes. If you're already using Meta's APIs for Instagram (which InstantDM does), you can add WhatsApp to the same Meta app. This simplifies authentication and management.
What's Next
- Set up Twilio SMS for SMS messaging.
- Connect to Telegram for Telegram notifications.
- Read the Slack guide for team notifications.
- Build a Custom AI Agent to handle multi-channel conversations.
- Explore the full API docs at instantdm.com/instagram-api-docs.