WhatsApp Web Connect icon

WhatsApp Web Connect

Connect to WhatsApp Web and manage authentication

Send Message

AI-generated

Overview

This node integrates with WhatsApp Web to enable sending messages and managing WhatsApp sessions within an n8n workflow. It supports operations such as generating a QR code for authentication, connecting to WhatsApp Web using the QR code, sending messages to specific chats, checking connection status, and disconnecting.

A common use case is automating WhatsApp messaging in business workflows—for example, sending notifications, alerts, or customer support messages directly through WhatsApp. The "Send Message" operation allows sending text messages to any WhatsApp chat by specifying the chat ID (phone number with @c.us suffix) and the message content.

Properties

Name Meaning
Chat ID WhatsApp chat identifier, typically a phone number followed by @c.us (e.g., 1234567890@c.us). Specifies the recipient chat for sending messages.
Message The text content of the message to send to the specified chat.

Output

The output JSON structure varies depending on the operation:

  • Send Message:
    • operation: "send"
    • success: Boolean indicating if the message was sent successfully.
    • messageId: The unique identifier of the sent message (if successful).
    • timestamp: Timestamp when the message was sent.
    • error: Error message if sending failed.

For example:

{
  "operation": "send",
  "success": true,
  "messageId": "ABCD1234...",
  "timestamp": 1680000000
}

If sending fails:

{
  "operation": "send",
  "success": false,
  "error": "Error message describing failure"
}

The node can also output binary data indirectly by generating QR codes for authentication in other operations, but the "Send Message" operation outputs only JSON data related to message sending status.

Dependencies

  • Requires an API key credential for WhatsApp Web authentication (configured in n8n credentials).
  • Uses the whatsapp-web.js library internally to interact with WhatsApp Web.
  • Relies on Puppeteer for headless browser automation to manage WhatsApp Web sessions.
  • Temporary session data is stored under /tmp/whatsapp-web-{sessionName} on the host system.
  • Node requires network access to WhatsApp Web services.

Troubleshooting

  • Common Issues:

    • Failure to initialize the WhatsApp client due to session lock or profile directory issues.
    • QR code generation timeout or failure due to network problems or WhatsApp Web unavailability.
    • Authentication failures if the QR code is not scanned in time or invalid credentials are used.
    • Sending message errors if the chat ID is incorrect or the client is not connected.
  • Error Messages and Resolutions:

    • "Failed to initialize client: ...": Indicates problems starting the WhatsApp Web client. Try cleaning up session directories or restarting the node.
    • "Authentication failed: ...": QR code scanning failed or session expired. Regenerate QR code and reconnect.
    • "Failed to generate QR code within timeout period...": Network issues or WhatsApp Web service down. Retry later.
    • "Connection timed out after X seconds...": Increase timeout or check network connectivity.
    • Errors during sending usually include descriptive messages; verify chat ID format and ensure the client is connected.

Links and References


This summary focuses on the "Send Message" operation of the node's default resource, describing its inputs, outputs, dependencies, and potential troubleshooting tips based on static analysis of the source code.

Discussion