@warriorteam/redai-zalo-sdk 1.28.1 → 1.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,137 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.30.0] - 2025-01-05
6
+
7
+ ### ✨ Added - Template Message Support for ConsultationService
8
+
9
+ #### 🎯 New Core Function
10
+ - **`sendTemplateMessage()`** - Comprehensive template message function with full elements and buttons support
11
+ - Support for all Zalo OA template types with complete API specification compliance
12
+ - Type-safe template creation with comprehensive validation
13
+
14
+ #### 🛠️ Helper Functions (12 new functions)
15
+ - **Template Elements**: `createTemplateElement()` - Create template elements with validation
16
+ - **Template Buttons**:
17
+ - `createUrlButton()` - Create URL buttons (oa.open.url)
18
+ - `createQueryShowButton()` - Create query show buttons (oa.query.show)
19
+ - `createQueryHideButton()` - Create query hide buttons (oa.query.hide)
20
+ - `createSmsButton()` - Create SMS buttons (oa.open.sms)
21
+ - `createPhoneButton()` - Create phone call buttons (oa.open.phone)
22
+ - **Template Actions**:
23
+ - `createUrlAction()` - Create URL actions for elements
24
+ - `createQueryShowAction()` - Create query show actions
25
+ - `createQueryHideAction()` - Create query hide actions
26
+ - `createSmsAction()` - Create SMS actions
27
+ - `createPhoneAction()` - Create phone call actions
28
+
29
+ #### 📋 TypeScript Interfaces
30
+ - **`TemplateElement`** - Interface for template elements with validation rules
31
+ - **`TemplateButton`** - Interface for template buttons with type-specific payloads
32
+ - **`TemplateAction`** - Interface for template actions (default_action in elements)
33
+ - **`ConsultationTemplatePayload`** - Union type for all payload types
34
+ - **`UrlPayload`**, **`SmsPayload`**, **`PhonePayload`** - Specific payload interfaces
35
+
36
+ #### ✅ API Specification Compliance
37
+ - **Elements**: Maximum 5 elements, first element must have subtitle
38
+ - **Buttons**: Maximum 5 buttons with comprehensive validation
39
+ - **Title**: ≤ 100 characters validation
40
+ - **Subtitle**: ≤ 500 characters validation (required for first element)
41
+ - **Payload**: ≤ 1000 characters for string payloads
42
+ - **SMS Content**: ≤ 160 characters validation
43
+ - **Action Types**: Full support for all Zalo OA action types
44
+
45
+ #### 🔧 Validation & Error Handling
46
+ - Comprehensive input validation before API calls
47
+ - Detailed error messages with context information
48
+ - Type-safe development experience with TypeScript
49
+ - Runtime validation for all API specification rules
50
+
51
+ #### 📁 New Files
52
+ - `src/types/consultation.ts` - Complete TypeScript interfaces for consultation service
53
+ - `examples/consultation-template-example.ts` - Comprehensive usage examples
54
+ - `CONSULTATION-TEMPLATE-ENHANCEMENT.md` - Detailed documentation
55
+
56
+ #### 🔄 Updated Files
57
+ - `src/services/consultation.service.ts` - Added template message functions
58
+ - `src/index.ts` - Export new consultation types
59
+
60
+ ### 🎯 Use Cases Supported
61
+ - **Customer Support Templates** - Multi-element templates with various action buttons
62
+ - **Information Request Templates** - Templates requesting user information with callbacks
63
+ - **Interactive Templates** - Templates with URL, SMS, phone, and query actions
64
+ - **Marketing Templates** - Templates with multiple call-to-action buttons
65
+ - **Service Templates** - Templates for service interactions and support
66
+
67
+ ### 💡 Developer Experience Improvements
68
+ - **Type Safety**: Full TypeScript support with comprehensive interfaces
69
+ - **IntelliSense**: Complete autocomplete support for all template properties
70
+ - **Validation**: Automatic validation with clear error messages
71
+ - **Helper Functions**: Easy-to-use functions for creating template components
72
+ - **Documentation**: Comprehensive examples and API documentation
73
+
74
+ ## [1.29.0] - 2025-01-05
75
+
76
+ ### 🚀 Major Type Safety Improvements
77
+
78
+ #### ZNS Service Type Safety Enhancement
79
+ - **Feature**: Completely removed `any` types from ZNS Service validation functions
80
+ - **Impact**: Full type safety for all ZNS template components and validation
81
+ - **Benefits**: Better IDE support, compile-time error detection, improved developer experience
82
+
83
+ #### New Type Definitions Added
84
+ - `ZNSValidationComponent` - Union type for all ZNS components
85
+ - `ZNSTitleComponent` - Type-safe TITLE component (9-65 chars, max 4 params)
86
+ - `ZNSParagraphComponent` - Type-safe PARAGRAPH component (9-400 chars, max 10 params)
87
+ - `ZNSOTPComponent` - Type-safe OTP component (1-10 chars)
88
+ - `ZNSTableComponent` & `ZNSTableRow` - Type-safe TABLE component (2-8 rows)
89
+ - `ZNSLogoComponent` - Type-safe LOGO component with light/dark attachments
90
+ - `ZNSImagesComponent` - Type-safe IMAGES component (1-3 attachments)
91
+ - `ZNSButtonsComponent` & `ZNSButtonItem` - Type-safe BUTTONS component (1-2 buttons)
92
+ - `ZNSPaymentComponent` - Type-safe PAYMENT component with bank details
93
+ - `ZNSVoucherComponent` - Type-safe VOUCHER component with display options
94
+ - `ZNSRatingComponent` & `ZNSRatingItem` - Type-safe RATING component (exactly 5 items)
95
+ - `ZNSAttachment` - Type-safe attachment object for images
96
+
97
+ #### Updated Validation Functions
98
+ All validation functions now use specific types instead of `any`:
99
+ - `validateLayoutStructure()` - Uses `ZNSValidationComponent[]`
100
+ - `validateTitleComponent()` - Uses `ZNSTitleComponent`
101
+ - `validateParagraphComponent()` - Uses `ZNSParagraphComponent`
102
+ - `validateOTPComponent()` - Uses `ZNSOTPComponent`
103
+ - `validateTableComponent()` - Uses `ZNSTableComponent`
104
+ - `validateLogoComponent()` - Uses `ZNSLogoComponent`
105
+ - `validateImagesComponent()` - Uses `ZNSImagesComponent`
106
+ - `validateButtonsComponent()` - Uses `ZNSButtonsComponent`
107
+ - `validatePaymentComponent()` - Uses `ZNSPaymentComponent`
108
+ - `validateVoucherComponent()` - Uses `ZNSVoucherComponent`
109
+ - `validateRatingComponent()` - Uses `ZNSRatingComponent`
110
+ - `validateAttachment()` - Uses `ZNSAttachment`
111
+
112
+ #### Developer Experience Improvements
113
+ - **IntelliSense**: Full autocomplete support for all ZNS components
114
+ - **Error Detection**: Compile-time validation of component structures
115
+ - **Type Safety**: Eliminated runtime errors from incorrect component usage
116
+ - **Documentation**: Type definitions serve as inline documentation
117
+
118
+ #### Files Added/Modified
119
+ - `src/types/zns.ts` - Added comprehensive component type definitions
120
+ - `src/services/zns.service.ts` - Updated all validation functions with proper types
121
+ - `examples/zns-validation-example.ts` - Complete usage examples for all template types
122
+ - `ZNS-TYPE-IMPROVEMENTS.md` - Detailed documentation of improvements
123
+
124
+ #### Migration Guide
125
+ Existing code continues to work, but developers can now benefit from:
126
+ ```typescript
127
+ // Before: No type safety
128
+ const component: any = { TITLE: { value: "Hello" } };
129
+
130
+ // After: Full type safety
131
+ const component: ZNSValidationComponent = {
132
+ TITLE: { value: "Hello {{customer_name}}!" }
133
+ };
134
+ ```
135
+
5
136
  ## [1.27.3] - 2025-08-31
6
137
 
7
138
  ### 🐛 Critical Bug Fixes
@@ -0,0 +1,220 @@
1
+ # ZNS Service Type Improvements
2
+
3
+ ## Tổng quan
4
+
5
+ Đã cập nhật ZNS Service để sử dụng các type cụ thể thay vì `any` type, cải thiện type safety và developer experience.
6
+
7
+ ## Những thay đổi chính
8
+
9
+ ### 1. Thêm các interface validation components mới trong `src/types/zns.ts`
10
+
11
+ ```typescript
12
+ // Attachment object cho LOGO và IMAGES
13
+ export interface ZNSAttachment {
14
+ type: "IMAGE";
15
+ media_id: string;
16
+ }
17
+
18
+ // TITLE component
19
+ export interface ZNSTitleComponent {
20
+ value: string; // 9-65 ký tự, tối đa 4 params
21
+ }
22
+
23
+ // PARAGRAPH component
24
+ export interface ZNSParagraphComponent {
25
+ value: string; // 9-400 ký tự, tối đa 10 params
26
+ }
27
+
28
+ // OTP component
29
+ export interface ZNSOTPComponent {
30
+ value: string; // 1-10 ký tự
31
+ }
32
+
33
+ // TABLE component
34
+ export interface ZNSTableComponent {
35
+ rows: ZNSTableRow[]; // 2-8 rows
36
+ }
37
+
38
+ export interface ZNSTableRow {
39
+ title: string; // 3-36 ký tự, chỉ text cố định
40
+ value: string; // 3-90 ký tự, có thể có params
41
+ row_type?: 0 | 1 | 2 | 3 | 4 | 5; // Hiệu ứng row
42
+ }
43
+
44
+ // LOGO component
45
+ export interface ZNSLogoComponent {
46
+ light: ZNSAttachment;
47
+ dark: ZNSAttachment;
48
+ }
49
+
50
+ // IMAGES component
51
+ export interface ZNSImagesComponent {
52
+ items: ZNSAttachment[]; // 1-3 attachments
53
+ }
54
+
55
+ // BUTTONS component
56
+ export interface ZNSButtonsComponent {
57
+ items: ZNSButtonItem[]; // 1-2 buttons
58
+ }
59
+
60
+ export interface ZNSButtonItem {
61
+ type: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; // Button types
62
+ title: string; // 5-30 ký tự, chỉ text cố định
63
+ content: string; // URL/phone, có thể có params
64
+ }
65
+
66
+ // PAYMENT component
67
+ export interface ZNSPaymentComponent {
68
+ bank_code: string; // Bank code cố định
69
+ account_name: string; // 1-100 ký tự, text cố định
70
+ bank_account: string; // 1-100 ký tự, text cố định
71
+ amount: string | number; // Số tiền hoặc param
72
+ note?: string; // 1-90 ký tự, có thể có params
73
+ }
74
+
75
+ // VOUCHER component
76
+ export interface ZNSVoucherComponent {
77
+ name: string; // 1-30 ký tự, có thể có params
78
+ condition: string; // 1-40 ký tự, có thể có params
79
+ start_date?: string; // Có thể có params
80
+ end_date: string; // Có thể có params
81
+ voucher_code: string; // 1-25 ký tự, có thể có params
82
+ display_code?: 1 | 2 | 3; // QR code, Bar code, Text only
83
+ }
84
+
85
+ // RATING component
86
+ export interface ZNSRatingComponent {
87
+ items: ZNSRatingItem[]; // Đúng 5 items
88
+ }
89
+
90
+ export interface ZNSRatingItem {
91
+ star: 1 | 2 | 3 | 4 | 5; // Số sao
92
+ title: string; // 1-50 ký tự
93
+ question?: string; // 1-100 ký tự
94
+ answers?: string[]; // 1-5 câu trả lời, mỗi câu 1-50 ký tự
95
+ thanks: string; // 1-100 ký tự
96
+ description: string; // 1-200 ký tự
97
+ }
98
+
99
+ // Union type cho tất cả các component
100
+ export type ZNSValidationComponent =
101
+ | { TITLE: ZNSTitleComponent }
102
+ | { PARAGRAPH: ZNSParagraphComponent }
103
+ | { OTP: ZNSOTPComponent }
104
+ | { TABLE: ZNSTableComponent }
105
+ | { LOGO: ZNSLogoComponent }
106
+ | { IMAGES: ZNSImagesComponent }
107
+ | { BUTTONS: ZNSButtonsComponent }
108
+ | { PAYMENT: ZNSPaymentComponent }
109
+ | { VOUCHER: ZNSVoucherComponent }
110
+ | { RATING: ZNSRatingComponent };
111
+ ```
112
+
113
+ ### 2. Cập nhật ZNS Service validation functions
114
+
115
+ Tất cả các function validation trong `src/services/zns.service.ts` đã được cập nhật để sử dụng type cụ thể:
116
+
117
+ - `validateLayoutStructure()`: Sử dụng `ZNSValidationComponent[]` thay vì `any[]`
118
+ - `isHeaderComponent()`, `isBodyComponent()`, `isFooterComponent()`: Sử dụng `ZNSValidationComponent`
119
+ - `validateComponent()`: Sử dụng `ZNSValidationComponent`
120
+ - `validateTitleComponent()`: Sử dụng `ZNSTitleComponent`
121
+ - `validateParagraphComponent()`: Sử dụng `ZNSParagraphComponent`
122
+ - `validateOTPComponent()`: Sử dụng `ZNSOTPComponent`
123
+ - `validateTableComponent()`: Sử dụng `ZNSTableComponent`
124
+ - `validateLogoComponent()`: Sử dụng `ZNSLogoComponent`
125
+ - `validateImagesComponent()`: Sử dụng `ZNSImagesComponent`
126
+ - `validateButtonsComponent()`: Sử dụng `ZNSButtonsComponent`
127
+ - `validatePaymentComponent()`: Sử dụng `ZNSPaymentComponent`
128
+ - `validateVoucherComponent()`: Sử dụng `ZNSVoucherComponent`
129
+ - `validateRatingComponent()`: Sử dụng `ZNSRatingComponent`
130
+ - `validateAttachment()`: Sử dụng `ZNSAttachment`
131
+
132
+ ### 3. Lợi ích của việc cập nhật
133
+
134
+ #### Type Safety
135
+ - Loại bỏ hoàn toàn việc sử dụng `any` type
136
+ - IDE có thể detect lỗi type ngay khi code
137
+ - Autocomplete tốt hơn khi viết code
138
+
139
+ #### Developer Experience
140
+ - IntelliSense hiển thị đúng các property có sẵn
141
+ - Validation tự động khi compile TypeScript
142
+ - Dễ dàng refactor code mà không lo lỗi runtime
143
+
144
+ #### Maintainability
145
+ - Code dễ đọc và hiểu hơn
146
+ - Ít bug hơn do type checking
147
+ - Dễ dàng thêm feature mới
148
+
149
+ ### 4. Ví dụ sử dụng
150
+
151
+ Xem file `examples/zns-validation-example.ts` để biết cách sử dụng các type mới.
152
+
153
+ #### Trước khi cập nhật:
154
+ ```typescript
155
+ // Không có type safety
156
+ private validateTitleComponent(title: any): void {
157
+ if (!title.value || typeof title.value !== 'string') {
158
+ // Có thể có lỗi runtime nếu title không đúng cấu trúc
159
+ }
160
+ }
161
+ ```
162
+
163
+ #### Sau khi cập nhật:
164
+ ```typescript
165
+ // Type safety đầy đủ
166
+ private validateTitleComponent(title: ZNSTitleComponent): void {
167
+ if (!title.value || typeof title.value !== 'string') {
168
+ // IDE sẽ báo lỗi ngay nếu title không đúng type
169
+ }
170
+ }
171
+ ```
172
+
173
+ ### 5. Cách sử dụng trong dự án
174
+
175
+ ```typescript
176
+ import {
177
+ ZNSValidationComponent,
178
+ ZNSTitleComponent,
179
+ ZNSButtonsComponent
180
+ } from "./src/types/zns";
181
+
182
+ // Tạo component với type safety
183
+ const titleComponent: ZNSValidationComponent = {
184
+ TITLE: {
185
+ value: "Xin chào {{customer_name}}!"
186
+ }
187
+ };
188
+
189
+ const buttonsComponent: ZNSValidationComponent = {
190
+ BUTTONS: {
191
+ items: [
192
+ {
193
+ type: 1, // URL
194
+ title: "Xem chi tiết",
195
+ content: "https://example.com"
196
+ }
197
+ ]
198
+ }
199
+ };
200
+ ```
201
+
202
+ ### 6. Migration Guide
203
+
204
+ Nếu bạn đang sử dụng code cũ với `any` type:
205
+
206
+ 1. Import các type mới từ `src/types/zns`
207
+ 2. Thay thế `any` bằng type cụ thể tương ứng
208
+ 3. TypeScript compiler sẽ báo lỗi nếu có vấn đề về type
209
+ 4. Fix các lỗi type để đảm bảo code chạy đúng
210
+
211
+ ### 7. Kết luận
212
+
213
+ Việc cập nhật này giúp:
214
+ - ✅ Loại bỏ hoàn toàn `any` type
215
+ - ✅ Cải thiện type safety
216
+ - ✅ Tăng developer experience
217
+ - ✅ Giảm bugs và lỗi runtime
218
+ - ✅ Code dễ maintain hơn
219
+
220
+ Tất cả validation functions trong ZNS Service giờ đây đều có type safety đầy đủ và tuân thủ đúng chuẩn TypeScript best practices.
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from "./types/zns";
16
16
  export * from "./types/article";
17
17
  export * from "./types/broadcast";
18
18
  export * from "./types/promotion";
19
+ export * from "./types/consultation";
19
20
  export * from "./constants/zns.constants";
20
21
  export type { BaseMessage, TextMessage, ImageMessage, FileMessage, StickerMessage, TemplateMessage as MessageTemplateMessage, ReactionMessage as MessageReactionMessage, Message, MessageRecipient, SendMessageRequest, SendMessageResponse, UploadFileResponse, MessageStatus, MessageEvent, ConsultationTextMessage, ConsultationImageMessage, ConsultationFileMessage, ConsultationStickerMessage, ConsultationQuoteMessage, ConsultationRequestInfoMessage, TransactionMessage, AnonymousTextMessage, AnonymousImageMessage, AnonymousFileMessage, AnonymousStickerMessage, MiniAppMessage, ExtendedMessage, } from "./types/message";
21
22
  export * from "./types/webhook";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,2BAA2B,CAAC;AAG1C,YAAY,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,WAAW,EACX,cAAc,EACd,eAAe,IAAI,sBAAsB,EACzC,eAAe,IAAI,sBAAsB,EACzC,OAAO,EACP,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EAC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types/zns"), exports);
34
34
  __exportStar(require("./types/article"), exports);
35
35
  __exportStar(require("./types/broadcast"), exports);
36
36
  __exportStar(require("./types/promotion"), exports);
37
+ __exportStar(require("./types/consultation"), exports);
37
38
  // Export ZNS constants and helpers
38
39
  __exportStar(require("./constants/zns.constants"), exports);
39
40
  // Export webhook types (avoiding conflicts with message and group types)
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;AAEH,eAAe;AACf,iDAA+B;AAC/B,+CAA6B;AAC7B,6CAA2B;AAC3B,+CAA6B;AAC7B,8CAA4B;AAC5B,kDAAgC;AAChC,oDAAkC;AAClC,oDAAkC;AAElC,mCAAmC;AACnC,4DAA0C;AAkC1C,yEAAyE;AACzE,kDAAgC;AAEhC,yEAAyE;AACzE,mDAoB6B;AAlB3B,uHAAA,wBAAwB,OAAA;AACxB,wHAAA,yBAAyB,OAAA;AACzB,wHAAA,yBAAyB,OAAA;AACzB,wHAAA,yBAAyB,OAAA;AACzB,uHAAA,wBAAwB,OAAA;AACxB,sHAAA,uBAAuB,OAAA;AACvB,gHAAA,iBAAiB,OAAA;AACjB,iHAAA,kBAAkB,OAAA;AAClB,gHAAA,iBAAiB,OAAA;AACjB,mHAAA,oBAAoB,OAAA;AACpB,+GAAA,gBAAgB,OAAA;AAChB,qHAAA,sBAAsB,OAAA;AACtB,sHAAA,uBAAuB,OAAA;AACvB,qHAAA,sBAAsB,OAAA;AACtB,wHAAA,yBAAyB,OAAA;AACzB,oHAAA,qBAAqB,OAAA;AACrB,0GAAA,WAAW,OAAA;AACX,6GAAA,cAAc,OAAA;AAEhB,kCAAkC;AAClC,2CAMyB;AALvB,6GAAA,kBAAkB,OAAA;AAClB,8GAAA,mBAAmB,OAAA;AACnB,iHAAA,sBAAsB,OAAA;AACtB,kHAAA,uBAAuB,OAAA;AACvB,8GAAA,mBAAm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AkB,OAAA;AAC3B,kEAAgE;AAAvD,qHAAA,gBAAgB,OAAA;AACzB,8EAA2E;AAAlE,gIAAA,qBAAqB,OAAA;AAC9B,oFAQ+C;AAP7C,sIAAA,wBAAwB,OAAA;AAQ1B,kEAAgE;AAAvD,qHAAA,gBAAgB,OAAA;AAEzB,wBAAwB;AACxB,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAEhB,iBAAiB;AACjB,uCAAgD;AAAvC,mGAAA,OAAO,OAAW"}
@@ -1,152 +1,6 @@
1
1
  import { ZaloClient } from "../clients/zalo-client";
2
2
  import { MessageRecipient, SendMessageResponse, TextMessage, ConsultationQuoteMessage } from "../types/message";
3
- /**
4
- * Interface cho từng tin nhắn trong chuỗi tin nhắn
5
- */
6
- export interface MessageItem {
7
- /** Loại tin nhắn */
8
- type: "text" | "image" | "gif" | "file" | "sticker" | "request_user_info";
9
- /** Nội dung tin nhắn (cho text message) */
10
- text?: string;
11
- /** URL hình ảnh (cho image/gif message) */
12
- imageUrl?: string;
13
- /** URL GIF (cho gif message) */
14
- gifUrl?: string;
15
- /** Chiều rộng GIF (bắt buộc cho gif) */
16
- width?: number;
17
- /** Chiều cao GIF (bắt buộc cho gif) */
18
- height?: number;
19
- /** Token file (cho file message) */
20
- fileToken?: string;
21
- /** Attachment ID (cho image/sticker message) */
22
- attachmentId?: string;
23
- /** Sticker attachment ID (cho sticker message) */
24
- stickerAttachmentId?: string;
25
- /** Tiêu đề (cho request_user_info message) */
26
- title?: string;
27
- /** Tiêu đề phụ (cho request_user_info message) */
28
- subtitle?: string;
29
- /** Delay sau khi gửi tin nhắn này (milliseconds) */
30
- delay?: number;
31
- }
32
- /**
33
- * Interface cho request gửi chuỗi tin nhắn
34
- */
35
- export interface SendMessageSequenceRequest {
36
- /** Access token của Official Account */
37
- accessToken: string;
38
- /** ID người nhận */
39
- userId: string;
40
- /** Danh sách tin nhắn */
41
- messages: MessageItem[];
42
- /** Delay mặc định giữa các tin nhắn (milliseconds) - nếu không có delay riêng */
43
- defaultDelay?: number;
44
- }
45
- /**
46
- * Interface cho response gửi chuỗi tin nhắn
47
- */
48
- export interface SendMessageSequenceResponse {
49
- /** Tổng số tin nhắn đã gửi thành công */
50
- successCount: number;
51
- /** Tổng số tin nhắn thất bại */
52
- failureCount: number;
53
- /** Chi tiết kết quả từng tin nhắn */
54
- results: Array<{
55
- /** Index của tin nhắn trong danh sách */
56
- index: number;
57
- /** Loại tin nhắn */
58
- type: string;
59
- /** Trạng thái gửi */
60
- success: boolean;
61
- /** Thông tin response nếu thành công */
62
- response?: SendMessageResponse;
63
- /** Thông tin lỗi nếu thất bại */
64
- error?: string;
65
- /** Thời gian gửi */
66
- timestamp: number;
67
- }>;
68
- /** Tổng thời gian thực hiện (milliseconds) */
69
- totalDuration: number;
70
- }
71
- /**
72
- * Interface cho request gửi chuỗi tin nhắn tới nhiều users
73
- */
74
- export interface SendMessageSequenceToMultipleUsersRequest {
75
- /** Access token của Official Account */
76
- accessToken: string;
77
- /** Danh sách user IDs */
78
- userIds: string[];
79
- /** Danh sách tin nhắn */
80
- messages: MessageItem[];
81
- /** Delay mặc định giữa các tin nhắn (milliseconds) */
82
- defaultDelay?: number;
83
- /** Delay giữa các user (milliseconds) để tránh rate limit */
84
- delayBetweenUsers?: number;
85
- /** Callback function để tracking tiến trình */
86
- onProgress?: (progress: UserProgressInfo) => void;
87
- }
88
- /**
89
- * Interface cho thông tin tiến trình từng user
90
- */
91
- export interface UserProgressInfo {
92
- /** User ID hiện tại */
93
- userId: string;
94
- /** Index của user trong danh sách (bắt đầu từ 0) */
95
- userIndex: number;
96
- /** Tổng số users */
97
- totalUsers: number;
98
- /** Trạng thái: 'started' | 'completed' | 'failed' */
99
- status: 'started' | 'completed' | 'failed';
100
- /** Kết quả gửi tin nhắn (nếu đã hoàn thành) */
101
- result?: SendMessageSequenceResponse;
102
- /** Thông tin lỗi (nếu thất bại) */
103
- error?: string;
104
- /** Thời gian bắt đầu */
105
- startTime: number;
106
- /** Thời gian kết thúc (nếu đã hoàn thành) */
107
- endTime?: number;
108
- }
109
- /**
110
- * Interface cho response gửi chuỗi tin nhắn tới nhiều users
111
- */
112
- export interface SendMessageSequenceToMultipleUsersResponse {
113
- /** Tổng số users */
114
- totalUsers: number;
115
- /** Số users gửi thành công */
116
- successfulUsers: number;
117
- /** Số users gửi thất bại */
118
- failedUsers: number;
119
- /** Chi tiết kết quả từng user */
120
- userResults: Array<{
121
- /** User ID */
122
- userId: string;
123
- /** Index của user trong danh sách */
124
- userIndex: number;
125
- /** Trạng thái gửi cho user này */
126
- success: boolean;
127
- /** Kết quả chi tiết gửi tin nhắn */
128
- messageSequenceResult?: SendMessageSequenceResponse;
129
- /** Thông tin lỗi nếu thất bại */
130
- error?: string;
131
- /** Thời gian bắt đầu gửi */
132
- startTime: number;
133
- /** Thời gian kết thúc */
134
- endTime: number;
135
- /** Thời gian thực hiện (milliseconds) */
136
- duration: number;
137
- }>;
138
- /** Tổng thời gian thực hiện (milliseconds) */
139
- totalDuration: number;
140
- /** Thống kê tin nhắn tổng cộng */
141
- messageStats: {
142
- /** Tổng số tin nhắn đã gửi thành công */
143
- totalSuccessfulMessages: number;
144
- /** Tổng số tin nhắn thất bại */
145
- totalFailedMessages: number;
146
- /** Tổng số tin nhắn */
147
- totalMessages: number;
148
- };
149
- }
3
+ import { TemplateAction, TemplateElement, TemplateButton, SendMessageSequenceRequest, SendMessageSequenceResponse, SendMessageSequenceToMultipleUsersRequest, SendMessageSequenceToMultipleUsersResponse } from "../types/consultation";
150
4
  /**
151
5
  * Service xử lý các API tin nhắn tư vấn của Zalo Official Account
152
6
  *
@@ -328,6 +182,119 @@ export declare class ConsultationService {
328
182
  * @returns Kết quả gửi tin nhắn cho tất cả users
329
183
  */
330
184
  sendMessageSequenceToMultipleUsers(request: SendMessageSequenceToMultipleUsersRequest): Promise<SendMessageSequenceToMultipleUsersResponse>;
185
+ /**
186
+ * Gửi tin nhắn template tổng quát với elements và buttons
187
+ * Endpoint: https://openapi.zalo.me/v3.0/oa/message/cs
188
+ * Method: POST
189
+ *
190
+ * @param accessToken Access token của Official Account
191
+ * @param userId ID người nhận (user_id)
192
+ * @param templateType Loại template (ví dụ: "request_user_info")
193
+ * @param elements Mảng elements (tối đa 5 phần tử)
194
+ * @param buttons Mảng buttons (tối đa 5 phần tử, optional)
195
+ * @returns Thông tin tin nhắn đã gửi
196
+ */
197
+ sendTemplateMessage(accessToken: string, userId: string, templateType: string, elements: TemplateElement[], buttons?: TemplateButton[]): Promise<SendMessageResponse>;
198
+ /**
199
+ * Validate template element theo quy tắc API
200
+ * @param element Template element cần validate
201
+ * @param index Index của element trong mảng (để báo lỗi)
202
+ */
203
+ private validateTemplateElement;
204
+ /**
205
+ * Validate template button theo quy tắc API
206
+ * @param button Template button cần validate
207
+ * @param index Index của button trong mảng (để báo lỗi)
208
+ */
209
+ private validateTemplateButton;
210
+ /**
211
+ * Validate template action (cho default_action)
212
+ * @param action Template action cần validate
213
+ * @param context Context để báo lỗi
214
+ */
215
+ private validateTemplateAction;
216
+ /**
217
+ * Validate button payload theo type
218
+ * @param button Template button cần validate
219
+ * @param index Index của button trong mảng (để báo lỗi)
220
+ */
221
+ private validateButtonPayload;
222
+ /**
223
+ * Helper function để tạo template element
224
+ * @param title Tiêu đề (bắt buộc, ≤ 100 ký tự)
225
+ * @param subtitle Tiêu đề phụ (≤ 500 ký tự)
226
+ * @param imageUrl URL ảnh (optional)
227
+ * @param defaultAction Hành động khi click (optional)
228
+ * @returns TemplateElement object
229
+ */
230
+ createTemplateElement(title: string, subtitle?: string, imageUrl?: string, defaultAction?: TemplateAction): TemplateElement;
231
+ /**
232
+ * Helper function để tạo template button với URL
233
+ * @param title Tiêu đề button (≤ 100 ký tự)
234
+ * @param url URL để mở
235
+ * @returns TemplateButton object
236
+ */
237
+ createUrlButton(title: string, url: string): TemplateButton;
238
+ /**
239
+ * Helper function để tạo template button với query (hiển thị)
240
+ * @param title Tiêu đề button (≤ 100 ký tự)
241
+ * @param payload Dữ liệu callback (≤ 1000 ký tự)
242
+ * @returns TemplateButton object
243
+ */
244
+ createQueryShowButton(title: string, payload: string): TemplateButton;
245
+ /**
246
+ * Helper function để tạo template button với query (ẩn)
247
+ * @param title Tiêu đề button (≤ 100 ký tự)
248
+ * @param payload Dữ liệu callback (≤ 1000 ký tự)
249
+ * @returns TemplateButton object
250
+ */
251
+ createQueryHideButton(title: string, payload: string): TemplateButton;
252
+ /**
253
+ * Helper function để tạo template button với SMS
254
+ * @param title Tiêu đề button (≤ 100 ký tự)
255
+ * @param phoneCode Số điện thoại
256
+ * @param content Nội dung SMS (≤ 160 ký tự)
257
+ * @returns TemplateButton object
258
+ */
259
+ createSmsButton(title: string, phoneCode: string, content?: string): TemplateButton;
260
+ /**
261
+ * Helper function để tạo template button với Phone
262
+ * @param title Tiêu đề button (≤ 100 ký tự)
263
+ * @param phoneCode Số điện thoại
264
+ * @returns TemplateButton object
265
+ */
266
+ createPhoneButton(title: string, phoneCode: string): TemplateButton;
267
+ /**
268
+ * Helper function để tạo template action với URL
269
+ * @param url URL để mở
270
+ * @returns TemplateAction object
271
+ */
272
+ createUrlAction(url: string): TemplateAction;
273
+ /**
274
+ * Helper function để tạo template action với query (hiển thị)
275
+ * @param payload Dữ liệu callback (≤ 1000 ký tự)
276
+ * @returns TemplateAction object
277
+ */
278
+ createQueryShowAction(payload: string): TemplateAction;
279
+ /**
280
+ * Helper function để tạo template action với query (ẩn)
281
+ * @param payload Dữ liệu callback (≤ 1000 ký tự)
282
+ * @returns TemplateAction object
283
+ */
284
+ createQueryHideAction(payload: string): TemplateAction;
285
+ /**
286
+ * Helper function để tạo template action với SMS
287
+ * @param phoneCode Số điện thoại
288
+ * @param content Nội dung SMS (≤ 160 ký tự)
289
+ * @returns TemplateAction object
290
+ */
291
+ createSmsAction(phoneCode: string, content?: string): TemplateAction;
292
+ /**
293
+ * Helper function để tạo template action với Phone
294
+ * @param phoneCode Số điện thoại
295
+ * @returns TemplateAction object
296
+ */
297
+ createPhoneAction(phoneCode: string): TemplateAction;
331
298
  /**
332
299
  * Utility method để sleep/delay
333
300
  * @param ms Thời gian delay tính bằng milliseconds