Actions21
- Message Actions
- Group Actions
- Chat Actions
- Contact Actions
Overview
This node integrates with Green API to interact with WhatsApp chats. Specifically, the Get Chat History operation retrieves a specified number of messages from a given WhatsApp chat. This is useful for scenarios where you want to analyze past conversations, archive chat data, or trigger workflows based on historical messages.
Practical examples include:
- Fetching recent messages from a customer support chat to analyze user queries.
- Archiving chat history for compliance or record-keeping.
- Triggering follow-up actions in workflows based on previous chat content.
Properties
| Name | Meaning |
|---|---|
| Mode | Select between "Action" (execute WhatsApp actions) or "Listen for Incoming Webhook" (trigger workflows on incoming webhooks). For this operation, use "Action". |
| Chat ID | The unique identifier of the WhatsApp chat to retrieve history from. Format example: 972501234567@c.us for private chats. |
| Count | Number of messages to retrieve from the chat history. Defaults to 100 if not specified. |
Output
The output is a JSON array containing the response from the Green API endpoint for chat history. Each item in the array corresponds to one execution input and contains the retrieved chat messages.
The structure of each output JSON object typically includes message details such as sender, timestamp, message content, and message type as returned by the Green API.
No binary data output is produced by this operation.
Dependencies
- Requires an active Green API account with valid credentials: an instance ID and an API token.
- The node uses these credentials to authenticate requests to the Green API endpoints.
- Network access to
https://api.green-api.comis required. - No additional environment variables are needed beyond the configured credentials.
Troubleshooting
Common issues:
- Invalid or missing chat ID: Ensure the chat ID is correctly formatted and corresponds to an existing chat.
- Insufficient permissions or invalid credentials: Verify that the API token and instance ID are correct and have necessary permissions.
- Network connectivity problems: Confirm that your n8n instance can reach the Green API servers.
Error messages:
"Failed to get chat history: <error message>": Indicates an issue with the API request. Check the error message for details, verify parameters, and ensure credentials are valid.- NodeOperationError with data sent: Provides the payload sent to the API for debugging.
To resolve errors, double-check input parameters, especially the chat ID and count, and confirm your Green API credentials are properly set up in n8n.
Links and References
- Green API Documentation – Official API docs for WhatsApp integration.
- WhatsApp Chat IDs Format – Explanation of chat ID formats used in WhatsApp.