home / skills / openclaw / skills / whatsapp-business

whatsapp-business skill

/skills/mrgoodb/whatsapp-business

This skill helps you send WhatsApp messages via Cloud API, including text, templates, images, and interactive buttons to customers.

npx playbooks add skill openclaw/skills --skill whatsapp-business

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
2.3 KB
---
name: whatsapp-business
description: Send messages via WhatsApp Business Cloud API. Send templates, media, and interactive messages to customers.
metadata: {"clawdbot":{"emoji":"💬","requires":{"env":["WHATSAPP_TOKEN","WHATSAPP_PHONE_ID"]}}}
---

# WhatsApp Business Cloud API

Business messaging on WhatsApp.

## Environment

```bash
export WHATSAPP_TOKEN="xxxxxxxxxx"
export WHATSAPP_PHONE_ID="xxxxxxxxxx"
```

## Send Text Message

```bash
curl -X POST "https://graph.facebook.com/v18.0/$WHATSAPP_PHONE_ID/messages" \
  -H "Authorization: Bearer $WHATSAPP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messaging_product": "whatsapp",
    "to": "1234567890",
    "type": "text",
    "text": {"body": "Hello from WhatsApp Business!"}
  }'
```

## Send Template Message

```bash
curl -X POST "https://graph.facebook.com/v18.0/$WHATSAPP_PHONE_ID/messages" \
  -H "Authorization: Bearer $WHATSAPP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messaging_product": "whatsapp",
    "to": "1234567890",
    "type": "template",
    "template": {
      "name": "hello_world",
      "language": {"code": "en_US"}
    }
  }'
```

## Send Image

```bash
curl -X POST "https://graph.facebook.com/v18.0/$WHATSAPP_PHONE_ID/messages" \
  -H "Authorization: Bearer $WHATSAPP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messaging_product": "whatsapp",
    "to": "1234567890",
    "type": "image",
    "image": {"link": "https://example.com/image.jpg"}
  }'
```

## Send Interactive Buttons

```bash
curl -X POST "https://graph.facebook.com/v18.0/$WHATSAPP_PHONE_ID/messages" \
  -H "Authorization: Bearer $WHATSAPP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "messaging_product": "whatsapp",
    "to": "1234567890",
    "type": "interactive",
    "interactive": {
      "type": "button",
      "body": {"text": "Choose an option:"},
      "action": {
        "buttons": [
          {"type": "reply", "reply": {"id": "yes", "title": "Yes"}},
          {"type": "reply", "reply": {"id": "no", "title": "No"}}
        ]
      }
    }
  }'
```

## Get Message Templates

```bash
curl "https://graph.facebook.com/v18.0/{WABA_ID}/message_templates" \
  -H "Authorization: Bearer $WHATSAPP_TOKEN"
```

## Links
- Console: https://business.facebook.com/wa/manage/home
- Docs: https://developers.facebook.com/docs/whatsapp/cloud-api

Overview

This skill sends messages using the WhatsApp Business Cloud API, enabling programmatic delivery of text, templates, media, and interactive messages to customers. It includes examples for text, template, image, and interactive button payloads and shows how to list registered message templates. Environment variables store the API token and phone ID for secure requests.

How this skill works

The skill constructs HTTPS POST requests to the Facebook Graph API endpoint for your WhatsApp Business phone number. It uses an authorization bearer token and JSON payloads to specify messaging_product, recipient, message type (text, template, image, interactive), and message-specific fields like body, template name, or media link. Templates and templates listing use dedicated endpoints and require pre-approved template names and languages.

When to use it

  • Send transactional or marketing notifications to customers via WhatsApp programmatically.
  • Deliver media-rich messages such as images or documents hosted on a public URL.
  • Use pre-approved template messages for notifications that must follow WhatsApp policies.
  • Create simple interactive flows with quick-reply buttons to capture customer choices.
  • Automate outbound messages from backend systems, CRMs, or support workflows.

Best practices

  • Store WHATSAPP_TOKEN and WHATSAPP_PHONE_ID in environment variables or a secrets manager, never in source code.
  • Use pre-approved message templates for notifications to avoid delivery restrictions.
  • Host media on reliable HTTPS URLs and verify size and format limits before sending.
  • Handle API errors and rate limits: retry with exponential backoff and log responses for debugging.
  • Validate recipient phone numbers in E.164 format and respect user opt-in and privacy rules.

Example use cases

  • Send order confirmations or shipping updates using template messages with dynamic parameters.
  • Deliver product images or attachments for support cases directly into customer chats.
  • Run simple surveys or menu choices using interactive button messages to collect quick responses.
  • Notify users of appointment reminders or time-sensitive alerts using scheduled backend jobs.
  • Sync message templates and inspect available templates from the WhatsApp Business account.

FAQ

What environment variables are required?

Set WHATSAPP_TOKEN (API bearer token) and WHATSAPP_PHONE_ID (your WhatsApp Business phone object ID).

How do I send an image?

Send a POST to the messages endpoint with type 'image' and include an image.link pointing to a public HTTPS URL.