Zalo OA icon

Zalo OA

Tương tác với Zalo Official Account API

Overview

The Zalo OA node integrates with the Zalo Official Account API, enabling automation of various interactions and management tasks related to a Zalo Official Account (OA). It supports multiple operations such as sending messages, managing followers and tags, uploading media files, handling articles, products, categories, and orders.

Specifically, the Upload File operation allows users to upload files to the Zalo OA platform either by providing a direct URL or by uploading binary file data from previous nodes in the workflow. This is useful for automating content management, sharing documents, or attaching files to messages within the Zalo ecosystem.

Practical examples:

  • Uploading a PDF brochure or contract file to the Zalo OA server to share with customers.
  • Automating the upload of user-generated files collected via forms or other integrations.
  • Managing media assets programmatically without manual uploads.

Properties

Name Meaning
Binary Data Boolean flag indicating if the file to upload is provided as binary data (true) or as a URL (false).
Binary Property The name of the binary property containing the file data when Binary Data is true. This must match the binary field name from previous nodes.
URL File The URL of the file to upload when Binary Data is false. The node will fetch and upload this file.

Output

The node outputs JSON data representing the response from the Zalo OA API after attempting to upload the file. The structure typically includes:

  • Success indicators and metadata about the uploaded file.
  • Error information if the upload failed, including error messages and suggestions.

If the upload is successful, the output JSON contains details confirming the file upload. If an error occurs, the output JSON includes an error flag set to true, a descriptive message, the raw API response data if available, and a suggestion on how to resolve the issue.

The node does not output binary data itself; it only returns JSON responses from the API.

Dependencies

  • Requires an API authentication token (access token) credential configured in n8n to authenticate requests to the Zalo Official Account API.
  • Uses the axios HTTP client library to make REST API calls.
  • Uses the form-data library to handle multipart form uploads when sending binary file data.
  • The node expects the Zalo OA API endpoint at https://openapi.zalo.me/v2.0/oa.

Troubleshooting

Common Issues

  • Missing binary data property: When Binary Data is enabled but the specified binary property does not exist on the input item, the node throws an error indicating the missing binary property.
  • Invalid file URL: If the provided file URL is invalid, inaccessible, or the file format is unsupported, the upload will fail.
  • Access token issues: Invalid or expired access tokens will cause authentication errors.
  • File format or permission errors: The Zalo OA API may reject files due to unsupported formats or insufficient permissions.

Common Error Messages and Resolutions

  • "No binary data property "" exists on item."
    Ensure that the binary property name matches exactly the binary field name from previous nodes and that the binary data is present.

  • Error uploading file: <message>
    Check the file format and ensure the OA has permission to accept the file. Verify the access token validity.

  • HTTP response status errors (e.g., 401 Unauthorized, 400 Bad Request)
    Confirm that the access token is valid and has the required scopes. Also verify the correctness of the file URL or binary data.

  • Network or connectivity errors
    Ensure that the n8n instance can reach the Zalo OA API endpoints and that there are no firewall or proxy restrictions.

Links and References

Discussion