Zalo Upload Attachment
AI-generatedOverview
This node uploads attachments (images, videos, or files) to a Zalo chat thread using an authenticated connection via cookies. It supports uploading single or multiple files from various sources: local file paths on the n8n server, public URLs, or binary data from previous workflow nodes.
Typical use cases include:
- Automating sending media or documents to Zalo users or groups.
- Integrating Zalo messaging with other systems that generate or store files.
- Uploading files dynamically fetched from URLs or generated within workflows.
For example, you can upload a user profile picture stored locally or send multiple PDF reports downloaded from URLs to a Zalo group chat.
Properties
| Name | Meaning |
|---|---|
| Thread ID | The ID of the Zalo thread (user or group) where the attachment will be uploaded. |
| Type | The type of thread: User or Group. |
| Attachment Source | Source of the attachment file(s): File Path, URL, or Binary Data from workflow. |
| File Path | Absolute path to a single file on the n8n server (shown if Attachment Source is File Path). |
| File URL | Public URL of a single file to download and upload (shown if Attachment Source is URL). |
| Binary Property | Name of the binary property containing file data in the input item (shown if Attachment Source is Binary Data). |
| Filename | Filename with extension for the single binary file (shown if Attachment Source is Binary Data). |
| Multiple Files | Boolean flag to upload multiple files at once. |
| File Paths (Multiple) | List of file paths separated by commas or new lines for multiple files (shown if Attachment Source is File Path and Multiple Files is true). |
| File URLs (Multiple) | List of URLs separated by commas or new lines for multiple files (shown if Attachment Source is URL and Multiple Files is true). |
| Binary Properties (Multiple) | Comma-separated names of binary properties for multiple files (shown if Attachment Source is Binary Data and Multiple Files is true). |
| Filenames (Multiple) | Comma-separated filenames with extensions for multiple binary files (shown if Attachment Source is Binary Data and Multiple Files is true). |
Output
The node outputs JSON data describing the upload result for each input item. The structure includes:
success: Boolean indicating if the upload succeeded.threadId: The target thread ID.type: Thread type as string ("User" or "Group").uploadedFiles: An array of objects, each representing an uploaded file with fields:fileName: Name of the uploaded file.fileType: Type of file ("image", "video", or others).totalSize: Size of the uploaded file in bytes.- For images: additional fields like
fileId,fileUrl,width,height,hdUrl,thumbUrl. - For videos and other files: fields like
fileId,fileUrl, andchecksum.
If the node handles binary data, it temporarily saves it as files before uploading. The output does not contain raw binary data but metadata about the uploaded attachments.
Dependencies
- Requires valid Zalo API credentials including a cookie-based authentication token, IMEI, and user agent string.
- Uses the
zca-jslibrary for interacting with the Zalo API. - Relies on Node.js filesystem (
fs) and path (path) modules to handle files. - Uses helper functions to download files from URLs and clean up temporary files.
- Needs proper configuration of the Zalo API credential in n8n with required authentication details.
Troubleshooting
- File Not Found: If a specified local file path does not exist, the node throws an error. Verify the file paths are correct and accessible by the n8n process.
- Binary Property Missing or Invalid: Errors occur if the specified binary property is missing or contains invalid data. Ensure the binary data exists in the input item and matches the property name.
- Download Failures: When downloading files from URLs, failures may happen due to network issues or invalid URLs. Check URL accessibility and internet connectivity.
- Upload Timeout or Network Errors: The node retries uploads up to 3 times on timeouts, network errors, or server errors. Large files (>10MB) or unsupported formats may cause longer upload times or failures. Consider splitting large files or verifying supported formats.
- Unsupported File Extensions: Warnings are logged for file types that may not be supported by Zalo API. Confirm file compatibility.
- Credential Issues: Initialization failure indicates problems with Zalo API credentials. Recheck the provided cookie, IMEI, and user agent values.
- Temporary File Cleanup: Temporary files created during upload are deleted after completion. If permission issues arise, ensure n8n has rights to create and delete files in the working directory.