ZaloOA icon

ZaloOA

Consume ZaloOA API

Overview

This n8n node allows you to send a file message via the Zalo Official Account (OA) API. It is designed for scenarios where you need to deliver files (such as documents, images, or other media) to users on Zalo, either to identified users or anonymous users within a conversation. Typical use cases include customer support automation, sending receipts or reports, and delivering downloadable content through chatbots.

Practical examples:

  • Sending a PDF invoice to a user after a purchase.
  • Delivering an image or document to a user who initiated a chat with your OA.
  • Sharing files with anonymous users in a group or temporary conversation.

Properties

Name Meaning
Authentication Select the authentication method. Options: Parameter Credentials, Predefined Credentials
Base URL The base URL that serves the API (used when "Parameter Credentials" is selected).
Access Token OA access token required for authenticating API requests (used when "Parameter Credentials" is selected).
Send To Anonymous Whether the user is anonymous or not. Set to true if sending to an anonymous user; otherwise, set to false.
User ID User ID of Zalo. Required if "Send To Anonymous" is false.
Anonymous ID The ID representing the anonymous user. Required if "Send To Anonymous" is true.
Conversation ID The ID of the conversation. Required if "Send To Anonymous" is true.
File Token The token string returned when using the file upload API. This identifies the file to be sent.

Output

The node outputs the response from the Zalo OA API after attempting to send the file message. The structure typically includes:

{
  "error": 0,
  "message": "Success",
  "data": {
    // Additional data about the sent message, such as message ID, recipient info, etc.
  }
}
  • If the operation is successful, error will be 0 and message will indicate success.
  • If there is an error, error will contain a non-zero code and message will describe the issue.

Note: The actual fields may vary depending on the Zalo OA API's response.

Dependencies

  • Zalo Official Account API: Requires a valid OA access token.
  • n8n Credentials: If using "Predefined Credentials", you must configure the zaloOAApi credential in n8n.
  • Environment Variables: None specified, but ensure network access to https://openapi.zalo.me/v3.0/oa.

Troubleshooting

Common issues:

  • Invalid Access Token: If the access token is missing or incorrect, the API will return an authentication error. Ensure the correct token is provided.
  • Missing Required Fields: If required properties (like File Token, User ID, or Anonymous ID/Conversation ID) are not set according to the context, the API call will fail.
  • File Token Issues: The File Token must be obtained from a prior file upload operation. If expired or invalid, the file cannot be sent.

Error messages:

  • "error": -201, "message": "Invalid access token": Check and update your OA access token.
  • "error": -102, "message": "Missing parameter": Ensure all required fields are filled based on whether you're sending to an anonymous or regular user.
  • "error": -108, "message": "Invalid file token": Re-upload the file to obtain a new token.

Links and References

Discussion