WhatsApp MB icon

WhatsApp MB

Use WhatsApp Cloud API

Overview

The WhatsApp MB node for n8n enables sending messages via the WhatsApp Cloud API. Specifically, with the "Send Message" operation, it allows you to send either session-based text messages or template-based messages (including support for templates with custom components and buttons) to a specified phone number. This is useful for automating notifications, alerts, customer engagement, or transactional messaging directly through WhatsApp.

Example scenarios:

  • Sending appointment reminders to customers.
  • Notifying users of order status updates using pre-approved WhatsApp templates.
  • Sending interactive messages with quick-reply buttons for customer support.

Properties

Name Meaning
To Number The destination phone number to which the message will be sent.
Message Type The type of message to send. Options:
- Session: Standard text message within an active session.
- Template: Pre-approved WhatsApp template message.
Message Text The text content of the message. Required when "Message Type" is set to "Session".
Template Name The name of the WhatsApp template to use. Required when "Message Type" is set to "Template".
Language Code The language code for the template (e.g., "en_US"). Required when "Message Type" is "Template".
Components Custom components for the template in JSON format. Required when "Message Type" is "Template".
Buttons One or more buttons to include with the message. Each button has a "Text" property specifying its label.

Output

The node returns a JSON array where each item represents the result of a message sent. The structure of each output object depends on the response from the WhatsApp Cloud API and may include fields such as:

{
  "messages": [
    {
      "id": "wamid.HBgMNTg..."
    }
  ],
  "contacts": [
    {
      "input": "+1234567890",
      "wa_id": "1234567890"
    }
  ]
}
  • For session messages: The output contains information about the sent message, including message ID and contact details.
  • For template messages: The output includes similar information, reflecting the template used and recipient details.

Note: The actual structure may vary based on the WhatsApp API's response.

Dependencies

  • External Service: WhatsApp Cloud API.
  • Credentials: Requires whatsappCredentialsApi credential in n8n, containing:
    • wppToken: WhatsApp API access token.
    • number_id: Your WhatsApp Business Account phone number ID.

Troubleshooting

  • Common Issues:

    • Invalid Credentials: If the API token or number ID is incorrect, authentication errors will occur.
    • Missing Required Fields: Omitting required properties (like "To Number" or "Message Text"/"Template Name") will cause validation errors.
    • Incorrect Template/Language: Using a template name or language code not approved in your WhatsApp account will result in API errors.
    • Malformed Components JSON: Providing invalid JSON in "Components" will cause parsing errors.
  • Error Messages:

    • "The operation \"<operation>\" is not supported!"
      • Cause: An unsupported operation was selected.
      • Solution: Ensure you select a valid operation ("Send Message" or "Mark as Read").
    • WhatsApp API error responses (e.g., invalid phone number, unauthorized template):
      • Check the API response in the node output for details and correct the input accordingly.

Links and References

Discussion