Whatsapp Cloud Lead Bot

    by Zeeonix Digital

    1

    Next.js and Node.js integration for Meta WhatsApp Cloud API with secure webhooks and automated template messaging.

    $14.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    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

    1. Add WHATSAPP_VERIFY_TOKEN and WHATSAPP_APP_SECRET to your .env file.
    2. Deploy the endpoint and configure the Webhook URL in the Meta Developer Portal.
    3. Subscribe to the messages field 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 GET challenge and POST events with constant-time token comparison.
    • HMAC validation secures incoming requests by verifying x-hub-signature-256 against 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

    1. Endpoint Setup creates a secure Route Handler for Meta to send real-time message updates.
    2. Security Layer implements the SHA256 signature check and environment variable validation.
    3. Outbound Client provides a structured method to send pre-approved templates with proper error handling.
    4. 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Read Files
    Network Access
    Write Files
    Terminal / Shell
    Listed9 days ago

    What's inside

    Frequently Asked Questions

    This skill provides a production-ready integration layer for the Meta WhatsApp Cloud API, automating secure webhook verification, HMAC signature validation, and template-based messaging for lead generation.

    The skill is designed for Next.js and Node.js environments and can be integrated with any AI agent or application capable of executing JavaScript/TypeScript logic and managing environment variables.

    You will receive a complete integration package including the secure webhook route handlers, the outbound API client, and a structured implementation guide for connecting your database and Meta App credentials.

    Yes, you must have a registered Meta Developer App and a verified WhatsApp Business Account (WABA) to obtain the necessary API tokens and phone number IDs required for operation.

    The skill is built for Meta Graph API v21.0+ and includes standard logic for phone number normalization and error handling to ensure compliance with Meta's strict messaging policies.

    This skill automates the outbound side via pre-approved templates, but free-form conversational replies are subject to Meta's standard 24-hour customer service window policy.

    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.