Z-API WhatsApp icon

Z-API WhatsApp

Custom operations

Overview

This node enables deleting a specific WhatsApp message using the Z-API WhatsApp service. It is useful in scenarios where you want to programmatically remove messages from a chat or group, for example, to moderate conversations, retract sent messages, or automate cleanup tasks.

A practical example: You have an automated system that sends notifications via WhatsApp but needs to delete certain messages after a condition is met (e.g., outdated alerts). This node can delete those messages by specifying their ID and associated chat.

Properties

Name Meaning
Instance Your Z-API instance ID used to identify your WhatsApp API instance.
Token Your Z-API token for authenticating API requests.
Client Token Your Z-API client token for additional authentication header required by the API.
Message ID The unique identifier of the message you want to delete.
Phone The phone number or group ID where the message is located.
Owner Boolean indicating whether you are the owner of the message (true/false).

Output

The output is a JSON object representing the response from the Z-API service after attempting to delete the message. It typically contains status information about the deletion request, such as success confirmation or error details.

No binary data is output by this operation.

Example output structure (simplified):

{
  "status": "success",
  "message": "Message deleted successfully"
}

or in case of failure:

{
  "status": "error",
  "message": "Message not found or cannot be deleted"
}

Dependencies

  • Requires access to the Z-API WhatsApp service.
  • Needs valid credentials: an instance ID, a token, and a client token.
  • The node makes HTTP DELETE requests to the Z-API endpoint with appropriate headers.
  • No additional environment variables are explicitly required beyond these credentials.

Troubleshooting

  • Common issues:

    • Invalid or expired tokens leading to authentication errors.
    • Incorrect message ID or phone/group ID causing the message not to be found.
    • Insufficient permissions if the "owner" flag is incorrectly set.
    • Network connectivity problems preventing API calls.
  • Error messages and resolutions:

    • "Message not found or cannot be deleted": Verify the message ID and phone/group ID are correct and that the message exists.
    • Authentication errors: Check that the instance ID, token, and client token are valid and have not expired.
    • "The operation 'delete-message' is not supported for resource 'messages'": Ensure the node parameters are correctly set to use the "Delete Message" operation under the "Message" resource.
    • If the node throws a generic error, enabling "Continue On Fail" can help process other items while logging errors for failed ones.

Links and References

Discussion