Skip to content
Go back

How to Use WhatsApp for Business Automation with the Official API – Full Setup Guide

Tired of getting your number banned using Baileys and shady third-party hacks? Welcome to the clean, legit route: Meta’s Official WhatsApp Business API. This guide takes you from nothing to full automation using X-Asena CloudConnect—an open-source bot engine built on top of the official stack.

You’ll build a secure WhatsApp bot, connect it with real users, send messages, buttons, media, lists, and even integrate monetization.


Table of Contents

Open Table of Contents

Why Official API Matters


Prerequisites


Step-by-Step Setup (Meta + Cloud)

Step 1: Create Meta App

Step 2: Generate Access & Test Number

curl -X POST https://graph.facebook.com/v19.0/<phone_id>/messages \
  -H 'Authorization: Bearer <access_token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "messaging_product": "whatsapp",
    "to": "<user_number>",
    "type": "text",
    "text": { "body": "Hello from WhatsApp API" }
  }'

You’re live.


Local Bot Setup: X-Asena CloudConnect

Step 1: Clone the Repo

git clone https://github.com/Neeraj-x0/X-Asena-CloudConnect
cd X-Asena-CloudConnect
npm install

Step 2: Configure .env

Create a .env file:

PORT=3001
WEBHOOK_VERIFY_TOKEN=verify_token
API_URL= YOUR_API_URL
GRAPH_API_TOKEN=your-graph-api-token

Step 3: Expose with Ngrok (for dev)

npx ngrok http 3001

Copy the HTTPS URL. Paste it as your webhook callback in the Meta developer dashboard → Webhook → Setup → Add URL + Token.

Enable message events:


Command-Based Automation Examples

Inside commands/ folder, create files like ping.js.

command({
  pattern: "ping",
  fromMe: true,
  desc: "Checks bot responsiveness",
  type: "utility",
}, async (message) => {
  await message.reply("pong");
});

This responds to ping with pong. No DB. No fluff.


Real Examples with WaMessage API

Text

await api.sendText("Your order is confirmed!");

Media

await api.sendMedia("https://example.com/image.jpg");

Buttons (Text Only)

await api.sendButtonText({
  text: "Choose:",
  buttons: [
    { id: "buy", title: "Buy Now" },
    { id: "info", title: "More Info" }
  ]
});

List Message

await api.sendList({
  header: "Product List",
  body: "Select below:",
  footer: "Powered by X-Asena",
  button: "Show Options",
  sections: [
    {
      title: "Categories",
      rows: [
        { id: "cat1", title: "Books", description: "Digital/Printed" },
        { id: "cat2", title: "Gadgets", description: "Electronics" }
      ]
    }
  ]
});

Media Upload

const { id } = await api.uploadMedia("https://example.com/banner.png");

Media Delete

await api.deleteMedia("MEDIA_ID");

Extending the Bot with Plugins

Create your own plugin system using the command loader. Any file under commands/ is hot-loaded.

Add auth, DB, state, or custom logic. Example: store leads, push to CRM, etc.

Want to automate booking confirmations? Use text + buttons. Want product browsing? Use list + media.


Going Production + Monetization Ideas

Production Hosting:

Monetization:


Final Thoughts

Stop building on cracked foundations. The official WhatsApp API + X-Asena CloudConnect gives you the tools to scale your automation securely and legally.

Anything else is just noise.

whatsapp automation guide

Built for serious businesses. Powered by official APIs. Engineered by developers.



Share this post on: