Green API icon

Green API

Send WhatsApp messages via Green API or trigger workflows on webhooks

Overview

The node integrates with Green API to manage WhatsApp messaging and related group/chat/contact operations. Specifically, the Delete Message operation under the Message resource allows users to delete a WhatsApp message from a chat. This can be done either by deleting the message for everyone or only from the sender's side.

This node is beneficial in scenarios where automated workflows need to manage message lifecycles, such as removing sensitive information after processing, cleaning up test messages, or managing message visibility dynamically.

Practical example:

  • Automatically delete a message sent by a bot after a certain condition is met (e.g., user confirmation).
  • Remove erroneous messages sent to a group or private chat via automation.

Properties

Name Meaning
Mode Select between "Action" (execute WhatsApp actions) or "Listen for Incoming Webhook" (trigger workflows on incoming webhooks). For Delete Message, use "Action".
Resource The type of entity to operate on; here it should be "Message".
Operation The action to perform on the resource; here "Delete Message" deletes a message from chat.
Chat ID The identifier of the chat where the message exists. Format: phone@c.us for private chats or chatId@g.us for groups.
Message ID The unique ID of the message to delete. Required for deletion.
Delete for Sender Only Boolean flag indicating whether to delete the message only from the sender's side (true) or for everyone (false). Defaults to false.

Output

The node outputs a JSON array containing the response from the Green API for each processed item. The structure of the output JSON depends on the API response but generally includes confirmation of the deletion request status.

No binary data output is involved in this operation.

Example output snippet (conceptual):

[
  {
    "result": "success",
    "idMessage": "BAE5367237E13A87"
  }
]

Dependencies

  • Requires an active Green API account with valid credentials: an instance ID and an API token.
  • The node makes HTTP POST requests to Green API endpoints using these credentials.
  • No additional external dependencies beyond standard Node.js modules and n8n helpers.
  • Proper configuration of the Green API credentials in n8n is necessary.

Troubleshooting

  • Common issues:

    • Invalid or missing message ID will cause the deletion to fail.
    • Incorrect chat ID format may result in errors or no action.
    • Insufficient permissions or expired API tokens can cause authentication failures.
    • Network connectivity issues may prevent successful API calls.
  • Error messages:

    • "Failed to delete message: <error message>" indicates the API call failed. Check the error details and verify the message ID, chat ID, and credentials.
    • "This node is configured as a trigger. Please use it as a trigger node, not an action node." means the node mode is set to listen for webhooks instead of performing actions; switch mode to "Action".
    • File read errors or malformed input parameters will throw descriptive errors specifying the problem and the item index.
  • Resolution tips:

    • Double-check all required fields are correctly filled.
    • Ensure the API credentials are valid and have appropriate permissions.
    • Use correct chat and message IDs as per WhatsApp/Green API formats.
    • Review network access and firewall settings if requests time out.

Links and References

Discussion