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 allows sending messages through the Zalo platform using its API, authenticated via a cookie-based login. It is designed to send text messages to either individual users or groups within Zalo threads. The node supports additional features such as quoting previous messages, mentioning users in the message, attaching images by URL, and setting the urgency level of the message.

Typical use cases include automating customer support replies, broadcasting announcements to groups, or integrating Zalo messaging into workflows that require notifications or alerts.

Example scenarios:

  • Sending a notification message to a specific user thread when an event occurs.
  • Replying to a group chat with an important update including quoted context.
  • Sending images along with text messages to users or groups.

Properties

Name Meaning
Thread ID The unique identifier of the Zalo thread (user or group) where the message will be sent.
Type The type of the thread: User (0) or Group (1).
Message The text content of the message to be sent.
Urgency The urgency level of the message: Default (0), Important (1), or Urgent (2).
Quote Message Optional quoted message details to reply to a specific message, including Message ID, Sender ID, and Content.
Mentions Optional mentions within the message specifying User ID, position, and length of the mention.
Attachments One or more image attachments specified by public URLs to be included in the message.

Output

The node outputs an array of JSON objects, each corresponding to an input item processed. Each output JSON contains:

  • success: Boolean indicating if the message was sent successfully.
  • response: The raw response from the Zalo API after sending the message.
  • threadId: The ID of the thread where the message was sent.
  • threadType: Numeric value representing whether the thread is a user (0) or group (1).
  • messageContent: The full message object sent, including text, urgency, quotes, mentions, and attachments.

If the node encounters an error and is set to continue on failure, it outputs:

  • success: false
  • error: The error message describing what went wrong.

The node can also handle binary data indirectly by downloading images from URLs before sending them as attachments, but the output itself does not contain binary data.

Dependencies

  • Requires an API key credential containing a valid Zalo cookie, IMEI, and user agent string for authentication.
  • Uses the external zca-js library to interact with the Zalo API.
  • Utilizes helper functions to download and remove images temporarily when sending attachments.
  • Requires proper configuration of credentials in n8n with the necessary Zalo authentication details.

Troubleshooting

  • Failed to initialize Zalo API: This error indicates invalid or expired credentials (cookie, IMEI, or user agent). Verify that the API key credential is correct and up to date.
  • Zalo login error: Could be caused by network issues or incorrect credential format. Check connectivity and credential validity.
  • Cannot send typing event: Non-critical warning logged if the typing indicator cannot be sent; usually safe to ignore.
  • Error sending Zalo message: General catch-all for failures during message sending. Inspect the error message for specifics, such as invalid thread ID or attachment issues.
  • If attachments fail to upload, ensure the image URLs are publicly accessible and valid.
  • When continuing on failure is disabled, any error will stop execution and throw an error.

Links and References

Discussion