WAHA API icon

WAHA API

Complete WhatsApp automation with WAHA API - Multi-engine support

Overview

The "Clear Messages" operation under the "Chat" resource in this node allows users to clear all messages within a specified WhatsApp chat. This is useful for managing chat history by removing all messages from a conversation without deleting the chat itself.

Practical scenarios include:

  • Automating cleanup of chat histories to maintain privacy or reduce clutter.
  • Resetting conversations before starting new interactions.
  • Managing storage by clearing message data while keeping the chat accessible.

Example: A user wants to clear all messages in a group chat after an event concludes, preserving the group but removing all prior messages.

Properties

Name Meaning
Session Name The name of the WhatsApp session to use (defaults to a configured default session).
Chat ID The unique identifier of the WhatsApp chat to clear messages from (e.g., phone number with @c.us or group ID with @g.us).
Additional Fields Optional extra parameters; not specifically used for this operation but available for consistency.

Output

The output JSON contains the response from the WAHA API after attempting to clear messages in the specified chat. It typically includes status information indicating success or failure of the operation.

No binary data is output by this operation.

Example output structure:

{
  "status": "success",
  "message": "Messages cleared successfully"
}

Or in case of error:

{
  "error": "Error message describing the failure"
}

Dependencies

  • Requires a valid WAHA API credential with an API key and base URL configured in n8n.
  • Optionally uses an additional API key credential for validating subscription via the N8N Tools API.
  • The node sends HTTP requests to the WAHA API endpoints to perform operations.
  • Requires proper configuration of the WhatsApp session referenced by "Session Name".

Troubleshooting

  • Invalid Credentials: If the WAHA API key or base URL is incorrect, the node will fail to authenticate. Verify credentials in n8n settings.
  • Subscription Validation Failure: The node validates the subscription using the N8N Tools API. Errors like "Invalid subscription or API key" indicate issues with this secondary API key.
  • Unknown Resource or Operation: Errors mentioning unknown resources or operations suggest misconfiguration of the "Resource" or "Operation" properties.
  • Chat ID Format: Ensure the Chat ID is correctly formatted as a phone number with @c.us or a group ID with @g.us.
  • Network Issues: Connectivity problems to the WAHA API endpoint can cause request failures.
  • Continue On Fail: If enabled, errors per item are returned in the output JSON instead of stopping execution.

Links and References

Discussion