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

Zalo Send Message

AI-generated

Overview

This node sends messages through the Zalo messaging platform using an API authenticated by a cookie-based login. It supports sending text messages, quoting previous messages, mentioning users, and attaching multiple files from URLs or local paths. The node handles different message types (user or group) and allows setting message urgency levels.

Common scenarios include:

  • Automating customer support replies on Zalo.
  • Broadcasting announcements to groups or individual users.
  • Sending multimedia content such as images, documents, or videos alongside text messages.
  • Quoting previous messages for context in conversations.
  • Mentioning specific users within group chats.

Example: Automatically send an urgent notification with attached PDF and image files to a user thread, quoting a previous message and mentioning a user.

Properties

Name Meaning
Thread ID The ID of the conversation thread where the message will be sent.
Type The type of message recipient: either "User" (individual chat) or "Group" (group chat).
Message The main text content of the message to send.
Urgency The urgency level of the message: "Default", "Important", or "Urgent".
Quote Message Optional quoted message details to reference in the new message, including: Message ID, Sender ID, and Content of the quoted message.
Mentions Optional collection of mentions specifying User ID, position in the message text, and length of the mention.
Attachments One or more attachments to send with the message. Currently supports URLs pointing to files (images, PDFs, ZIPs, DOCs, MP4s, MP3s, etc.). Multiple attachments can be added.
Multiple URLs Comma-separated list of URLs to multiple files to attach and send simultaneously. Supports various file types like images, documents, audio, and video.
Local File Path Path to a local file to attach and send. Supports relative or absolute paths to various file types (images, PDFs, ZIPs, DOCs, MP4s, MP3s, etc.).

Output

The node outputs an array of JSON objects, each representing the result of sending a message for each input item. Each output object 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 code representing the thread type (user or group).
  • messageContent: Object containing the message parameters used (text, urgency, quote, mentions, attachments).

If sending fails and "Continue On Fail" is enabled, the output includes an error message instead.

Attachments are handled internally and cleaned up if temporary files were created during processing. Local files are not deleted.

Dependencies

  • Requires an API key credential that provides a valid Zalo cookie, IMEI, and user agent string for authentication.
  • Uses the external zca-js library for interacting with the Zalo API.
  • Node.js fs and path modules for file system operations.
  • Utility functions for saving remote files locally and removing temporary files.
  • Network access to download attachment URLs and communicate with Zalo servers.

Troubleshooting

  • Timeout errors: Large attachments (>10MB) may cause send timeouts. The node retries sending up to 2 times with increasing delays. If failures persist, it attempts a fallback strategy by sending the text message first, then sending attachments individually.
  • Large file warnings: Files larger than 20MB trigger warnings recommending pre-uploading via a dedicated upload node to avoid timeouts.
  • File path resolution: Local file paths are resolved against multiple directories (current working directory, node directory, workspace root). If the file is not found or unreadable, an error is logged.
  • Authentication errors: Failure to initialize the Zalo API usually indicates invalid or expired credentials.
  • Mention and quote formatting: Incorrect mention positions or missing quote fields may cause unexpected message formatting.
  • Attachment format issues: Only URL-based attachments are supported currently; other types may fail silently or cause errors.

To resolve common errors:

  • Use smaller files or pre-upload large files.
  • Verify local file paths and permissions.
  • Ensure valid and current API credentials.
  • Check network connectivity and retry sending.
  • Enable detailed logging to diagnose issues.

Links and References

Discussion