Zalo Send Message icon

Zalo Send Message

Gửi tin nhắn qua API Zalo sử dụng kết nối đăng nhập bằng cookie

Actions2

Overview

This node enables sending messages and message status updates through the Zalo messaging platform using its API. It is particularly useful for automating communication workflows involving Zalo, such as sending notifications, alerts, or chat messages to individual users or groups.

A common scenario includes sending a "typing" status indicator (message status) to a user or group thread to simulate real-time typing activity, enhancing user experience in chatbots or automated responders.

For example, before sending a message, the node can send a typing event to indicate that a response is being prepared.

Properties

Name Meaning
Thread ID The unique identifier of the thread (chat) where the message status will be sent.
Type The type of the message recipient: either a single User or a Group. Options: User, Group

Output

The node outputs a JSON object with the following structure:

  • success: Boolean indicating if the operation was successful.
  • message: A string confirming the status, typically "OK" when sending the typing status succeeds.

Example output JSON:

{
  "success": true,
  "message": "OK"
}

No binary data output is produced by this operation.

Dependencies

  • Requires an API key credential with a valid Zalo session cookie, IMEI, and user agent string to authenticate requests.
  • Uses the external zca-js library to interact with the Zalo API.
  • Utilizes helper functions to manage image attachments if used in other operations (not relevant here).
  • Proper configuration of credentials in n8n is necessary to enable API access.

Troubleshooting

  • Common issues:

    • Failure to initialize the Zalo API due to invalid or expired credentials.
    • Errors sending typing events if the thread ID is incorrect or the API rejects the request.
  • Error messages:

    • "Failed to initialize Zalo API. Check your credentials." — Indicates problems with authentication; verify the API key and session cookie.
    • "Zalo login error: <error message>" — Details from the underlying API login failure.
    • "Zalo API not initialized" — The node attempted to send a message status without a successful API login.
    • "Cannot send typing event: <error message>" — Issues encountered while sending the typing status; check thread ID validity and network connectivity.
  • Resolution tips:

    • Ensure credentials are correctly set up and have not expired.
    • Verify the thread ID corresponds to an existing user or group conversation.
    • Check network connectivity and API availability.

Links and References

Discussion