Zalo OA icon

Zalo OA

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

Overview

This node interacts with the Zalo Official Account (OA) API, enabling automation and management of various 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.

Use cases for this operation include:

  • Fetching recent messages exchanged with a particular user for customer support or analytics.
  • Archiving conversation history for compliance or record-keeping.
  • Triggering workflows based on past interactions or message content.

Example: Retrieve the last 10 messages starting from the 0th position in the conversation with a user identified by their User ID.

Properties

Name Meaning
User ID The unique identifier of the user whose conversation history you want to retrieve.
Vị Trí Bắt Đầu The offset position to start fetching messages from within the conversation (starting index).
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 includes details about the messages retrieved such as message content, timestamps, sender information, and other metadata related to the conversation history.

If an error occurs during the API call, the output JSON will contain an error flag set to true, an error message, optional note and suggestion fields to help diagnose the issue, and possibly the raw API response data.

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 endpoint at https://openapi.zalo.me/v2.0/oa/conversation.
  • The node depends on the axios HTTP client library for making API requests.
  • 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 missing, invalid, or expired.
  • Insufficient permissions: If the access token lacks the required message management permission, the API will return an authorization error.
  • Incorrect User ID: Providing an incorrect or non-existent user ID will result in an error or empty conversation data.
  • Offset/count out of range: Requesting an offset or count beyond available messages may return fewer results or errors.

Error Messages and Resolutions

  • "Lỗi khi gọi API lấy lịch sử hội thoại: <error message>": Indicates failure in calling the conversation API. Check network connectivity, access token validity, and API permissions.
  • "Hãy đảm bảo rằng bạn đã cấp quyền "Quyền quản lý tin nhắn người quan tâm" cho ứng dụng và có access_token hợp lệ.": Suggests missing required permissions or invalid token. Reauthorize the app and verify token scopes.
  • Network or timeout errors: Ensure stable internet connection and that the Zalo API service is reachable.

Links and References

Discussion