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, optionally including a caption and quoting an existing message.

Common scenarios for this node include:

  • Sending images, documents, or other media files directly from a local machine to a WhatsApp contact or group.
  • Automating file sharing in customer support workflows or marketing campaigns.
  • Adding context to shared files by including captions or referencing previous messages.

Example use case: Automatically sending a PDF invoice stored on your server to a client’s WhatsApp chat with a brief caption describing the document.

Properties

Name Meaning
Mode Selects the node mode: "Action" (execute WhatsApp actions) or "Listen for Incoming Webhook".
File Path The full path to the file on your local system that you want to upload and send.
Caption Optional text caption to accompany the sent file.

Additional properties relevant but not shown here (like Chat ID and Quoted Message ID) are used internally to specify the recipient and quoted message when sending.

Output

The node outputs a JSON array where each item corresponds to the response from the Green API after attempting to send the file. The JSON typically contains details about the sent message, such as message IDs and status.

If the operation fails, the node throws an error with details about the failure.

The node can handle binary data input for the file, allowing the file content to come from previous nodes instead of only from a file path.

Dependencies

  • Requires an active Green API account with valid credentials: an instance ID and an API token.
  • Needs network access to https://api.green-api.com endpoints.
  • Uses Node.js modules fs and path to read files from the local filesystem.
  • n8n workflow must provide the Green API credentials configured with the required authentication tokens.

Troubleshooting

  • File Read Errors: If the specified file path is incorrect or inaccessible, the node will throw an error indicating failure to read the file. Ensure the path is correct and accessible by the n8n process.
  • API Request Failures: Network issues or invalid credentials will cause request failures. Check your Green API credentials and network connectivity.
  • Incorrect Property Values: Missing or invalid chat IDs or file paths will result in errors. Verify all required fields are correctly set.
  • Binary Data Handling: When providing file content as binary data from previous nodes, ensure the binary property name matches the expected one ("data") and that the data is properly base64 encoded.

Links and References

Discussion