Green API icon

Green API

Send WhatsApp messages via Green API or trigger workflows on webhooks

Overview

This node enables interaction with WhatsApp via the Green API service, specifically allowing users to delete messages from chats. The "Delete Message" operation removes a specified message either for all chat participants or only from the sender's side.

Common scenarios include:

  • Automatically cleaning up sent messages after a certain event.
  • Removing mistakenly sent messages.
  • Managing message visibility selectively (e.g., deleting only on sender side).

Practical example:

  • A workflow that deletes a message by its ID after a user triggers a specific condition, such as a command or a time delay.

Properties

Name Meaning
Mode Select between "Action" (execute WhatsApp actions) or "Listen for Incoming Webhook" (trigger workflows on incoming webhooks). For deleting messages, use "Action".
Resource The type of entity to operate on; here it is "Message".
Operation The action to perform on the resource; here it is "Delete Message".
Chat ID The identifier of the chat where the message exists (e.g., 972501234567@c.us for private chat or group chat ID ending with @g.us). Required.
Message ID The unique ID of the message to delete. Required.
Delete for Sender Only Boolean flag indicating whether to delete the message only from the sender's side (true) or from all participants (false). Default is false.

Output

The node outputs a JSON array containing the response from the Green API after attempting to delete the message. The structure typically includes status information about the deletion request.

Example output JSON snippet:

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

No binary data output is involved in this operation.

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.
  • Proper configuration of these credentials in n8n is necessary.
  • No additional external dependencies beyond standard Node.js modules and n8n helpers.

Troubleshooting

  • Common issues:

    • Invalid or missing message ID or chat ID will cause the deletion to fail.
    • Incorrect or expired API credentials will result in authentication errors.
    • Network connectivity problems can prevent successful API calls.
  • Error messages:

    • "Failed to delete message: <error message>" indicates the API call failed. Check the error message 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 incorrectly; ensure "Mode" is set to "Action" for deleting messages.
  • Resolution tips:

    • Double-check the message ID and chat ID values.
    • Verify API credentials are correctly set and have required permissions.
    • Ensure the Green API service is reachable from your environment.

Links and References

Discussion