WSAPI Message

Send and manage WhatsApp messages via WSAPI

Overview

This node enables sending and managing WhatsApp messages through a WebSocket API (WSAPI). It supports a wide range of message operations including sending various types of messages (text, images, videos, audio, voice notes, documents, contacts, locations, stickers), reacting to messages, editing sent messages, deleting messages either for everyone or just for the user, starring/un-starring messages, and marking messages as read.

A practical use case is automating WhatsApp communications in customer support workflows, marketing campaigns, or internal team notifications. For example, you can automatically send a text message or an image to a customer when a new order is placed, or delete a message if it was sent by mistake.

The Delete Message operation specifically allows deleting a message for all participants in the chat, effectively removing it from the conversation history.

Properties

Name Meaning
Message ID ID of the message to delete (hexadecimal string)
Chat ID WhatsApp ID of the chat containing the message (e.g., phone number with @s.whatsapp.net)
Message Sender ID WhatsApp ID of the original sender of the message

These properties are required to identify exactly which message to delete and in which chat.

Output

The output is a JSON object representing the response from the WSAPI after attempting to delete the specified message. This typically includes confirmation of deletion or error details if the operation failed.

No binary data is output by this operation.

Example output structure (simplified):

{
  "success": true,
  "messageId": "0123456789ABCDEF",
  "chatId": "1234567890@s.whatsapp.net"
}

Or in case of failure:

{
  "error": "Message not found or already deleted"
}

Dependencies

  • Requires connection to a WSAPI service that manages WhatsApp messaging.
  • Needs an API key credential and instance identifier configured in n8n credentials for authentication.
  • The node sends HTTP requests to the WSAPI endpoints using these credentials.

Troubleshooting

  • Common issues:

    • Incorrect or missing Message ID, Chat ID, or Message Sender ID will cause the deletion to fail.
    • Trying to delete a message that does not exist or has already been deleted.
    • Insufficient permissions or invalid API key/instance ID may result in authorization errors.
    • Network connectivity issues to the WSAPI endpoint.
  • Error messages and resolutions:

    • "Message not found": Verify the Message ID and Chat ID are correct.
    • "Unauthorized" or "Invalid API key": Check that the API key and instance ID credentials are correctly set up.
    • "Failed to delete message": Confirm the message is deletable (e.g., not too old or restricted by WhatsApp policies).
    • Timeout or network errors: Ensure the WSAPI service is reachable and stable.

Links and References

Discussion