UNPKG

@warriorteam/redai-zalo-sdk

Version:

Comprehensive TypeScript/JavaScript SDK for Zalo APIs - Official Account v3.0, ZNS with Full Type Safety, Consultation Service, Broadcast Service, Group Messaging with List APIs, Social APIs, Enhanced Article Management, Promotion Service v3.0 with Multip

108 lines 4.49 kB
/** * Broadcast Service for Zalo Official Account * * Gửi tin Truyền thông Broadcast đến nhiều người dùng dựa trên tiêu chí targeting * API: https://openapi.zalo.me/v2.0/oa/message * * TÍNH NĂNG: * 1. GỬI TIN BROADCAST: * - Gửi tin nhắn đến nhiều người dùng cùng lúc * - Targeting theo tuổi, giới tính, địa điểm, platform * - Chỉ hỗ trợ template type "media" với article attachment * * 2. TARGETING CRITERIA: * - Ages: Nhóm tuổi (0-12, 13-17, 18-24, 25-34, 35-44, 45-54, 55-64, 65+) * - Gender: Giới tính (All, Male, Female) * - Cities: Tỉnh thành cụ thể (63 tỉnh thành Việt Nam) * - Locations: Miền (Bắc, Trung, Nam) * - Platform: Hệ điều hành (iOS, Android, Windows Phone) * * 3. GIỚI HẠN: * - Chỉ gửi được article attachment * - Cần có quyền broadcast từ Zalo * - Tuân thủ chính sách spam và nội dung * * LỖI THƯỜNG GẶP: * - 3001: Không có quyền gửi broadcast * - 3002: Article attachment không tồn tại * - 3003: Targeting criteria không hợp lệ * - 3004: Vượt quá giới hạn broadcast * - 3005: Nội dung vi phạm chính sách */ import { ZaloClient } from '../clients/zalo-client'; import { BroadcastResponse, BroadcastTarget, BroadcastRecipient, BROADCAST_CITY_CODES, BROADCAST_AGE_CODES, BROADCAST_GENDER_CODES, BROADCAST_LOCATION_CODES, BROADCAST_PLATFORM_CODES, MultipleBroadcastResult, MultipleBroadcastProgress } from '../types/broadcast'; export declare class BroadcastService { private readonly client; private readonly broadcastApiUrl; constructor(client: ZaloClient); /** * Gửi tin nhắn broadcast đến nhiều người dùng * @param accessToken Access token của Official Account * @param recipient Thông tin targeting người nhận * @param attachmentId ID của article attachment * @returns Thông tin tin nhắn broadcast đã gửi */ sendBroadcastMessage(accessToken: string, recipient: BroadcastRecipient, attachmentId: string): Promise<BroadcastResponse>; /** * Tạo broadcast target với các tiêu chí targeting * @param criteria Các tiêu chí targeting * @returns BroadcastTarget object */ createBroadcastTarget(criteria: { ages?: string[]; gender?: "ALL" | "MALE" | "FEMALE"; cities?: string[]; locations?: ("NORTH" | "CENTRAL" | "SOUTH")[]; platforms?: ("IOS" | "ANDROID" | "WINDOWS_PHONE")[]; }): BroadcastTarget; /** * Validate broadcast request parameters * @param recipient Broadcast recipient * @param attachmentId Article attachment ID */ private validateBroadcastRequest; /** * Get available city codes for targeting * @returns Object mapping city names to codes */ getCityCodes(): typeof BROADCAST_CITY_CODES; /** * Get available age group codes for targeting * @returns Object mapping age groups to codes */ getAgeGroupCodes(): typeof BROADCAST_AGE_CODES; /** * Get available gender codes for targeting * @returns Object mapping genders to codes */ getGenderCodes(): typeof BROADCAST_GENDER_CODES; /** * Get available location codes for targeting * @returns Object mapping locations to codes */ getLocationCodes(): typeof BROADCAST_LOCATION_CODES; /** * Get available platform codes for targeting * @returns Object mapping platforms to codes */ getPlatformCodes(): typeof BROADCAST_PLATFORM_CODES; /** * Gửi nhiều tin nhắn broadcast với nhiều attachment IDs * @param accessToken Access token của Official Account * @param recipient Thông tin targeting người nhận * @param attachmentIds Danh sách các article attachment IDs * @param options Tùy chọn gửi (delay giữa các tin, parallel/sequential) * @returns Danh sách kết quả gửi broadcast */ sendMultipleBroadcastMessages(accessToken: string, recipient: BroadcastRecipient, attachmentIds: string[], options?: { delay?: number; mode?: 'parallel' | 'sequential'; onProgress?: (progress: MultipleBroadcastProgress) => void; }): Promise<MultipleBroadcastResult>; /** * Sleep utility for delays * @param ms Milliseconds to sleep */ private sleep; } //# sourceMappingURL=broadcast.service.d.ts.map