Green API icon

Green API

Send WhatsApp messages via Green API or trigger workflows on webhooks

Overview

This node enables sending WhatsApp messages and files via the Green API service, specifically supporting the "Send File By Upload" operation under the "Message" resource. It allows users to upload a file from their local system and send it as a WhatsApp message to a specified chat ID, optionally including a caption and quoting an existing message.

Common scenarios where this node is beneficial include:

  • Automating the sending of images, documents, or other media files to WhatsApp contacts or groups.
  • Integrating WhatsApp file sharing into workflows that generate or process files dynamically.
  • Adding captions to files for better context in conversations.
  • Quoting previous messages when sending files to maintain conversation threads.

Practical example:

  • A business automatically sends invoices (PDF files) to customers via WhatsApp after a purchase, attaching the invoice file with a caption like "Your invoice for order #12345".

Properties

Name Meaning
Mode Selects the node mode: "Action" to execute WhatsApp actions or "Listen for Incoming Webhook". For this operation, use "Action".
Resource The type of entity to operate on; here fixed as "Message".
Operation The action to perform; here "Send File By Upload" uploads and sends a file from local storage.
Chat ID The WhatsApp chat identifier to send the file to. Format: phone@c.us for private chats or chatId@g.us for groups.
File Path The full path to the file on the local system to be uploaded and sent.
Caption Optional text caption to accompany the file message.
Quoted Message ID (Optional) ID of a message to quote in the reply, maintaining conversation context.

Output

The node outputs a JSON array containing the response from the Green API after attempting to send the file. This typically includes details about the sent message such as message ID, status, and any metadata returned by the API.

If the operation succeeds, the output JSON reflects the successful message send confirmation. If it fails, an error is thrown instead.

No binary data is output by this node; it only returns JSON responses from the API.

Dependencies

  • Requires valid credentials for the Green API service, including an instance ID and an API token.
  • Needs access to the local filesystem to read the file specified by the "File Path" property.
  • Uses HTTP POST requests to the Green API endpoints.
  • Node must be configured with appropriate permissions to read files from the specified paths.

Troubleshooting

  • File Read Errors: If the node cannot read the file at the given path, it throws an error indicating failure to read the file. Ensure the file path is correct and accessible by n8n.
  • API Request Failures: Errors from the Green API (e.g., invalid credentials, network issues) will cause the node to throw errors with messages from the API. Verify API credentials and network connectivity.
  • Incorrect Chat ID Format: Sending to an invalid chat ID format may result in API errors. Use the correct format: phone@c.us for private chats or chatId@g.us for groups.
  • Missing Required Parameters: The "File Path" and "Chat ID" are required. Omitting these will cause validation errors.
  • Large Files: Very large files might fail due to API limits or timeouts. Check Green API documentation for file size restrictions.

Links and References

Discussion