Zalo OA icon

Zalo OA

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

Overview

This node integrates with the Zalo Official Account (OA) API, enabling users to interact programmatically with Zalo OA features. Specifically, the "Lấy Lịch Sử Hội Thoại" (Get Conversation History) operation retrieves the chat history between the OA and a specified user.

Typical use cases include:

  • Customer support automation: Fetching past conversations to provide context for ongoing support.
  • Analytics: Extracting message histories for sentiment analysis or customer behavior tracking.
  • CRM integration: Synchronizing conversation data with customer records.

For example, a business can use this node to pull the last 10 messages exchanged with a particular user to display in their internal dashboard or trigger follow-up actions based on conversation content.

Properties

Name Meaning
User ID The unique identifier of the user whose conversation history you want to retrieve.
Vị Trí Bắt Đầu The starting position (offset) in the conversation from which to begin fetching messages.
Số Lượng The number of messages to retrieve (maximum 50).

Output

The output is a JSON object containing the response from the Zalo OA API's conversation endpoint. It typically includes:

  • Conversation messages between the OA and the specified user.
  • Metadata such as message timestamps, sender information, and message content.
  • In case of errors, an error object with details including an error flag, message, notes, and suggestions.

No binary data output is produced by this operation.

Dependencies

  • Requires an active Zalo Official Account API access token credential configured in n8n.
  • Uses the Zalo OA API v2.0 endpoint https://openapi.zalo.me/v2.0/oa/conversation to fetch conversation history.
  • HTTP requests are made using Axios library.
  • Proper permissions must be granted to the access token, specifically the permission to manage and read messages ("Quyền quản lý tin nhắn người quan tâm").

Troubleshooting

Common Issues

  • Invalid or expired access token: The API call will fail if the access token is invalid or expired.
  • Insufficient permissions: If the access token lacks the required message management permission, the API will return an error.
  • Incorrect User ID: Providing a wrong or non-existent user ID will result in no data or an error.
  • Offset or count out of range: Using offset or count values outside allowed ranges may cause errors or empty results.

Error Messages and Resolutions

  • Error when calling API conversation: Indicates failure in fetching conversation history. Check that the OA access token is valid and has the necessary permissions.
  • Permission-related errors: Ensure the OA application has been granted the "Quyền quản lý tin nhắn người quan tâm" permission.
  • Rate limiting or network errors: Retry after some time or verify network connectivity.

In all error cases, the node outputs a JSON object with an error flag, descriptive message, optional note, and a suggestion field guiding corrective actions.

Links and References

Discussion