- Home
- Skills
- APIs & Backend
- Whatsapp Cloud Lead Bot
Whatsapp Cloud Lead Bot
Next.js and Node.js integration for Meta WhatsApp Cloud API with secure webhooks and automated template messaging.
$14.99
Whatsapp Cloud Lead Bot
Example session with this skill installed
Integrate a WhatsApp lead bot into my Next.js app. I need a secure webhook and a function to send a 'welcome_lead' template when someone signs up. I use Prisma for the Lead model.
- Read your context and instructions
- Compiled the whatsapp cloud lead
I have implemented the WhatsApp Business Cloud API integration. This includes a secure webhook handler with HMAC-SHA256 verification and an outbound client for sending templates.
WhatsApp Integration Deliverables
API Webhook Handler
// src/app/api/webhooks/whatsapp/route.ts
import { NextRequest, NextResponse } from 'next/server';
import crypto from 'crypto';
import { prisma } from '@/lib/db';
export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url);
const mode = searchParams.get('hub.mode');
const token = searchParams.get('hub.verify_token');
const challenge = searchParams.get('hub.challenge');
if (mode === 'subscribe' && token === process.env.WHATSAPP_VERIFY_TOKEN) {
return new NextResponse(challenge, { status: 200 });
}
return new NextResponse('Forbidden', { status: 403 });
}
export async function POST(req: NextRequest) {
const rawBody = await req.text();
const signature = req.headers.get('x-hub-signature-256')?.split('sha256=')[1];
const expectedSignature = crypto
.createHmac('sha256', process.env.WHATSAPP_APP_SECRET!)
.update(rawBody)
.digest('hex');
if (!signature || !crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expectedSignature))) {
return new NextResponse('Invalid Signature', { status: 401 });
}
const data = JSON.parse(rawBody);
const message = data.entry?.[0]?.changes?.[0]?.value?.messages?.[0];
if (message) {
await prisma.chatMessage.create({
data: {
waId: message.from,
body: message.text?.body,
timestamp: new Date(),
}
});
}
return NextResponse.json({ status: 'ok' });
}
Outbound Template Client
// src/lib/whatsapp/client.ts
export async function sendLeadWelcomeTemplate(to: string, name: string) {
const res = await fetch(`https://graph.facebook.com/v21.0/${process.env.WHATSAPP_PHONE_NUMBER_ID}/messages`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.WHATSAPP_ACCESS_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
messaging_product: "whatsapp",
to: to,
type: "template",
template: {
name: "welcome_lead",
language: { code: "en_US" },
components: [{
type: "body",
parameters: [{ type: "text", text: name }]
}]
}
}),
});
return res.json();
}
Next steps
- Add
WHATSAPP_VERIFY_TOKENandWHATSAPP_APP_SECRETto your.envfile. - Deploy the endpoint and configure the Webhook URL in the Meta Developer Portal.
- Subscribe to the
messagesfield in the Meta Webhook settings.
Connects securely to your tools. The creator never sees your data.
About this skill
Manual WhatsApp API integration is a mess of HMAC signatures, webhook verification, and strict template rules. This skill implements a production-ready Meta WhatsApp Business Cloud API integration for Next.js or Node.js applications. It handles the heavy lifting of secure communication and lead automation so you can focus on your business logic.
What it does
- Webhook verification handles the Meta
GETchallenge andPOSTevents with constant-time token comparison. - HMAC validation secures incoming requests by verifying
x-hub-signature-256against your app secret. - Phone normalization formats raw user input into valid E.164 strings to prevent API rejection.
- Template messaging triggers automated outbound replies for new leads using the Meta Graph API.
- CRM synchronization persists incoming customer messages and delivery statuses into your database.
How it works
- Endpoint Setup creates a secure Route Handler for Meta to send real-time message updates.
- Security Layer implements the SHA256 signature check and environment variable validation.
- Outbound Client provides a structured method to send pre-approved templates with proper error handling.
- Integration Hook connects the WhatsApp sender to your existing lead capture or contact form flow.
Frameworks & tools
Next.js, Node.js, Prisma, Meta Graph API (v21.0+), and standard Web Crypto APIs for signature verification.
Why this beats prompting it yourself
Generic prompts often miss the nuances of Meta's 24-hour service window rules or fail to implement crypto.timingSafeEqual for secure webhook verification. This skill provides a specific, hardened implementation that follows Meta's official technical specifications for production environments.
Use cases
- Sending instant "Thank You" WhatsApp messages when a website visitor submits a lead form.
- Building a lightweight WhatsApp-to-CRM bridge that logs customer replies into a database.
- Automating service notifications like appointment confirmations or shipping alerts.
Known limitations
Requires a pre-configured Meta App and verified WhatsApp Business Account. Free-form messaging is restricted to the 24-hour customer service window per Meta policy.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 9 days ago
- Software
Node.jstsctypescript
Permissions
What's inside
Frequently Asked Questions
New in APIs & Backend
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.