UNPKG

@warriorteam/redai-zalo-sdk

Version:

Comprehensive TypeScript/JavaScript SDK for Zalo APIs - Official Account, ZNS, Consultation Service, Group Messaging, and Social APIs

137 lines 6.77 kB
import { ZaloClient } from "../clients/zalo-client"; import { MessageRecipient, SendMessageResponse, TextMessage, ConsultationQuoteMessage } from "../types/message"; /** * Service xử lý các API tin nhắn tư vấn của Zalo Official Account * * Tin nhắn tư vấn (CS - Customer Service) là loại tin nhắn đặc biệt * cho phép OA gửi tin nhắn chủ động đến người dùng trong khung thời gian nhất định * * ĐIỀU KIỆN GỬI TIN TƯ VẤN: * * 1. THỜI GIAN GỬI: * - Chỉ được gửi trong vòng 48 giờ kể từ khi người dùng tương tác cuối cùng với OA * - Tương tác bao gồm: gửi tin nhắn, nhấn button, gọi điện, truy cập website từ OA * * 2. NỘI DUNG TIN NHẮN: * - Phải liên quan đến tư vấn, hỗ trợ khách hàng * - Bao gồm: trả lời câu hỏi, hướng dẫn sử dụng, hỗ trợ kỹ thuật * - Không được chứa nội dung quảng cáo trực tiếp * * 3. TẦN SUẤT GỬI: * - Không giới hạn số lượng tin nhắn tư vấn trong ngày * - Tuy nhiên cần tuân thủ nguyên tắc không spam * * 4. NGƯỜI DÙNG: * - Người dùng phải đã follow OA * - Người dùng không được block OA * - Người dùng phải có tương tác gần đây với OA */ export declare class ConsultationService { private readonly client; private readonly endpoint; constructor(client: ZaloClient); /** * Gửi tin nhắn tư vấn văn bản * @param accessToken Access token của Official Account * @param recipient Thông tin người nhận * @param message Nội dung tin nhắn văn bản * @returns Thông tin tin nhắn đã gửi */ sendTextMessage(accessToken: string, recipient: MessageRecipient, message: TextMessage): Promise<SendMessageResponse>; /** * Gửi tin nhắn tư vấn trích dẫn (quote message) * @param accessToken Access token của Official Account * @param recipient Thông tin người nhận * @param text Nội dung tin nhắn trả lời (tối đa 2000 ký tự) * @param quoteMessageId ID của tin nhắn muốn trích dẫn * @returns Thông tin tin nhắn đã gửi với quota information */ sendQuoteMessage(accessToken: string, recipient: MessageRecipient, text: string, quoteMessageId: string): Promise<SendMessageResponse>; /** * Tạo ConsultationQuoteMessage object * @param text Nội dung tin nhắn trả lời * @param quoteMessageId ID của tin nhắn muốn trích dẫn * @param quoteContent Nội dung của tin nhắn được trích dẫn (optional) * @returns ConsultationQuoteMessage object */ createQuoteMessage(text: string, quoteMessageId: string, quoteContent?: string): ConsultationQuoteMessage; /** * Gửi tin nhắn tư vấn hình ảnh * Endpoint: https://openapi.zalo.me/v3.0/oa/message/cs * Method: POST * * @param accessToken Access token của Official Account * @param userId ID người nhận (user_id) * @param imageUrl URL hình ảnh (jpg, png, tối đa 1MB) * @param text Tiêu đề ảnh (optional, tối đa 2000 ký tự) * @returns Thông tin tin nhắn đã gửi */ sendImageMessage(accessToken: string, userId: string, imageUrl: string, text?: string): Promise<SendMessageResponse>; /** * Gửi tin nhắn tư vấn hình ảnh bằng attachment_id * Endpoint: https://openapi.zalo.me/v3.0/oa/message/cs * Method: POST * * @param accessToken Access token của Official Account * @param userId ID người nhận (user_id) * @param attachmentId ID của ảnh đã upload (từ API upload ảnh) * @param text Tiêu đề ảnh (optional, tối đa 2000 ký tự) * @returns Thông tin tin nhắn đã gửi */ sendImageByAttachmentId(accessToken: string, userId: string, attachmentId: string, text?: string): Promise<SendMessageResponse>; /** * Gửi tin nhắn tư vấn GIF * Endpoint: https://openapi.zalo.me/v3.0/oa/message/cs * Method: POST * * @param accessToken Access token của Official Account * @param userId ID người nhận (user_id) * @param gifUrl URL ảnh GIF * @param width Chiều rộng của ảnh (bắt buộc cho GIF) * @param height Chiều cao của ảnh (bắt buộc cho GIF) * @param text Tiêu đề ảnh (optional, tối đa 2000 ký tự) * @returns Thông tin tin nhắn đã gửi */ sendGifMessage(accessToken: string, userId: string, gifUrl: string, width: number, height: number, text?: string): Promise<SendMessageResponse>; /** * Gửi tin nhắn tư vấn đính kèm file * Endpoint: https://openapi.zalo.me/v3.0/oa/message/cs * Method: POST * * @param accessToken Access token của Official Account * @param userId ID người nhận (user_id) * @param fileToken Token của file đã upload (từ API upload file) * @returns Thông tin tin nhắn đã gửi * * Note: Cần sử dụng API upload file trước để lấy token */ sendFileMessage(accessToken: string, userId: string, fileToken: string): Promise<SendMessageResponse>; /** * Gửi tin nhắn tư vấn theo mẫu yêu cầu thông tin người dùng * Endpoint: https://openapi.zalo.me/v3.0/oa/message/cs * Method: POST * * @param accessToken Access token của Official Account * @param userId ID người nhận (user_id) * @param title Tiêu đề hiển thị của template (tối đa 100 ký tự) * @param subtitle Tiêu đề phụ của template (tối đa 500 ký tự) * @param imageUrl Đường dẫn đến ảnh * @returns Thông tin tin nhắn đã gửi */ sendRequestUserInfoMessage(accessToken: string, userId: string, title: string, subtitle: string, imageUrl: string): Promise<SendMessageResponse>; /** * Gửi tin nhắn tư vấn kèm Sticker * Endpoint: https://openapi.zalo.me/v3.0/oa/message/cs * Method: POST * * @param accessToken Access token của Official Account * @param userId ID người nhận (user_id) * @param stickerAttachmentId ID của sticker (lấy từ https://stickers.zaloapp.com/) * @returns Thông tin tin nhắn đã gửi * * Note: Sticker ID lấy từ nguồn https://stickers.zaloapp.com/ * Xem video hướng dẫn: https://vimeo.com/649330161 */ sendStickerMessage(accessToken: string, userId: string, stickerAttachmentId: string): Promise<SendMessageResponse>; } //# sourceMappingURL=consultation.service.d.ts.map