Green API icon

Green API

Send WhatsApp messages via Green API or trigger workflows on webhooks

Overview

The "Leave Group" operation in the Green API node allows a user to programmatically leave a WhatsApp group using the Green API service. This is useful for automating group management tasks, such as removing a bot or user from a group when certain conditions are met or as part of workflow automation.

Typical scenarios include:

  • Automatically leaving groups after completing a campaign or event.
  • Managing group memberships dynamically based on external triggers.
  • Cleaning up group memberships in bulk via workflows.

Example: A workflow could detect that a project is finished and then use this node operation to have the bot leave all related WhatsApp groups automatically.

Properties

Name Meaning
Mode Select between "Action" (execute WhatsApp actions) or "Listen for Incoming Webhook" (trigger workflows on webhooks). For leaving a group, "Action" mode is used.
Resource The resource type to operate on; here it must be set to "Group".
Operation The action to perform on the resource; here it must be "Leave Group".
Group ID The unique identifier of the WhatsApp group to leave, e.g., 972501234567-1587570015@g.us. This is required to specify which group to leave.

Note: The "Mode" property is general for the node and not specific to this operation but must be set to "Action" to perform the leave group operation.

Output

The node outputs a JSON array containing the response from the Green API server after attempting to leave the specified group. The structure of the output JSON depends on the API response but typically includes status information about the leave group request.

No binary data is output by 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 the Green API endpoints.
  • Proper configuration of the Green API credentials in n8n is necessary.
  • Network access to https://api.green-api.com must be available.

Troubleshooting

  • Common issues:

    • Invalid or missing Group ID will cause the operation to fail.
    • Incorrect or expired API credentials will result in authentication errors.
    • Network connectivity problems can prevent the API call from succeeding.
  • Error messages:

    • "Failed to leave group: <error message>" indicates the API call failed. Check the error message for details.
    • "Data sent: {...}" shows the payload sent to the API, useful for debugging incorrect parameters.
    • If the node is configured in "trigger" mode instead of "action", it will throw an error instructing to use it as a trigger node.
  • Resolution tips:

    • Verify the Group ID format matches WhatsApp group IDs.
    • Ensure API credentials are correctly set and valid.
    • Confirm network connectivity and API endpoint accessibility.
    • Use the debug output to inspect the exact data sent to the API.

Links and References

Discussion