@warriorteam/redai-zalo-sdk 1.1.1 → 1.3.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 +154 -0
- package/README.md +45 -0
- package/SERVICES_ADDED.md +38 -1
- package/docs/API_REFERENCE.md +680 -0
- package/docs/AUTHENTICATION.md +709 -0
- package/docs/CONSULTATION_SERVICE.md +330 -0
- package/docs/MESSAGE_SERVICES.md +1224 -0
- package/docs/TAG_MANAGEMENT.md +1462 -0
- package/docs/USER_MANAGEMENT.md +1248 -0
- package/docs/ZNS_SERVICE.md +985 -0
- package/examples/consultation-service-example.ts +390 -0
- package/package.json +15 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.2.0] - 2025-01-08
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
#### 🆕 ConsultationService - Customer Support Messaging
|
|
13
|
+
- **New Service**: `ConsultationService` for sending customer support messages within 48-hour interaction window
|
|
14
|
+
- **Text Messages**: Send consultation text messages with automatic validation (max 2000 characters)
|
|
15
|
+
- **Image Messages**: Send consultation images for visual support and guides
|
|
16
|
+
- **File Messages**: Send consultation file attachments (manuals, guides, documents)
|
|
17
|
+
- **Sticker Messages**: Send consultation sticker messages for friendly interactions
|
|
18
|
+
- **General Messages**: Send any type of consultation message with unified interface
|
|
19
|
+
|
|
20
|
+
#### 📚 Documentation & Examples
|
|
21
|
+
- **Comprehensive Guide**: New `docs/CONSULTATION_SERVICE.md` with detailed usage instructions
|
|
22
|
+
- **Practical Examples**: New `examples/consultation-service-example.ts` with 6 real-world scenarios
|
|
23
|
+
- **Smart Customer Support**: Example implementation of intelligent customer support bot
|
|
24
|
+
- **Webhook Integration**: Complete webhook integration examples for consultation service
|
|
25
|
+
- **Error Handling**: Detailed error handling and retry mechanism examples
|
|
26
|
+
|
|
27
|
+
#### 🔧 SDK Integration
|
|
28
|
+
- **Quick Access**: Available via `zalo.consultation` property
|
|
29
|
+
- **Quick Methods**: Added `zalo.sendConsultationText()` and `zalo.sendConsultationImage()` convenience methods
|
|
30
|
+
- **Type Safety**: Full TypeScript support with comprehensive type definitions
|
|
31
|
+
- **Error Handling**: Enhanced error handling with `ZaloSDKError` for consultation-specific errors
|
|
32
|
+
|
|
33
|
+
#### 📖 Documentation Updates
|
|
34
|
+
- **README.md**: Updated with ConsultationService examples and documentation links
|
|
35
|
+
- **SERVICES_ADDED.md**: Added detailed ConsultationService documentation
|
|
36
|
+
- **Keywords**: Enhanced package keywords for better discoverability
|
|
37
|
+
|
|
38
|
+
### Technical Details
|
|
39
|
+
|
|
40
|
+
#### Consultation Service Features
|
|
41
|
+
- **48-Hour Window**: Enforces Zalo's 48-hour interaction window for consultation messages
|
|
42
|
+
- **Content Validation**: Automatic validation of message content and format
|
|
43
|
+
- **Quota Management**: Built-in quota tracking and management
|
|
44
|
+
- **Anti-Spam**: Follows Zalo's anti-spam guidelines and best practices
|
|
45
|
+
- **Retry Logic**: Built-in retry mechanism for failed requests
|
|
46
|
+
|
|
47
|
+
#### Usage Conditions
|
|
48
|
+
- Messages must be sent within 48 hours of last user interaction
|
|
49
|
+
- Content must be consultation/support related (no direct advertising)
|
|
50
|
+
- User must have followed the OA and not blocked it
|
|
51
|
+
- No daily limit but must follow anti-spam guidelines
|
|
52
|
+
|
|
53
|
+
#### Integration Points
|
|
54
|
+
- Seamless integration with existing webhook system
|
|
55
|
+
- Compatible with all existing SDK features
|
|
56
|
+
- Follows established SDK patterns and conventions
|
|
57
|
+
- Full backward compatibility maintained
|
|
58
|
+
|
|
59
|
+
### Examples Added
|
|
60
|
+
|
|
61
|
+
1. **Basic Consultation**: Simple text message consultation
|
|
62
|
+
2. **Image Support**: Sending images for visual guidance
|
|
63
|
+
3. **File Attachments**: Sending documents and manuals
|
|
64
|
+
4. **Smart Customer Support**: AI-powered customer support bot
|
|
65
|
+
5. **Retry Mechanism**: Robust error handling and retry logic
|
|
66
|
+
6. **Webhook Integration**: Complete webhook event handling
|
|
67
|
+
|
|
68
|
+
### Files Added/Modified
|
|
69
|
+
|
|
70
|
+
#### New Files
|
|
71
|
+
- `src/services/consultation.service.ts` - Main ConsultationService implementation
|
|
72
|
+
- `docs/CONSULTATION_SERVICE.md` - Comprehensive documentation
|
|
73
|
+
- `examples/consultation-service-example.ts` - Practical examples
|
|
74
|
+
- `CHANGELOG.md` - This changelog file
|
|
75
|
+
|
|
76
|
+
#### Modified Files
|
|
77
|
+
- `README.md` - Added ConsultationService documentation and examples
|
|
78
|
+
- `SERVICES_ADDED.md` - Added ConsultationService details
|
|
79
|
+
- `package.json` - Updated version, description, keywords, and scripts
|
|
80
|
+
- `src/index.ts` - Export ConsultationService types and classes
|
|
81
|
+
- `src/zalo-sdk.ts` - Integrated ConsultationService into main SDK
|
|
82
|
+
|
|
83
|
+
### Breaking Changes
|
|
84
|
+
None. This release maintains full backward compatibility.
|
|
85
|
+
|
|
86
|
+
### Migration Guide
|
|
87
|
+
No migration required. All existing code will continue to work unchanged.
|
|
88
|
+
|
|
89
|
+
To use the new ConsultationService:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { ZaloSDK } from "@warriorteam/redai-zalo-sdk";
|
|
93
|
+
|
|
94
|
+
const zalo = new ZaloSDK({
|
|
95
|
+
appId: "your-app-id",
|
|
96
|
+
appSecret: "your-app-secret"
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Use consultation service
|
|
100
|
+
await zalo.consultation.sendTextMessage(
|
|
101
|
+
accessToken,
|
|
102
|
+
{ user_id: "user-id" },
|
|
103
|
+
{ type: "text", text: "How can I help you?" }
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// Or use quick methods
|
|
107
|
+
await zalo.sendConsultationText(accessToken, "user-id", "Hello!");
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## [1.1.1] - 2024-12-XX
|
|
113
|
+
|
|
114
|
+
### Fixed
|
|
115
|
+
- Bug fixes and stability improvements
|
|
116
|
+
- Enhanced error handling
|
|
117
|
+
- Documentation updates
|
|
118
|
+
|
|
119
|
+
### Added
|
|
120
|
+
- Additional webhook event types
|
|
121
|
+
- Improved TypeScript definitions
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## [1.1.0] - 2024-11-XX
|
|
126
|
+
|
|
127
|
+
### Added
|
|
128
|
+
- Group Management Service
|
|
129
|
+
- Article Management Service
|
|
130
|
+
- Video Upload Service
|
|
131
|
+
- Enhanced webhook handling
|
|
132
|
+
- Comprehensive documentation
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## [1.0.0] - 2024-10-XX
|
|
137
|
+
|
|
138
|
+
### Added
|
|
139
|
+
- Initial release
|
|
140
|
+
- Official Account API support
|
|
141
|
+
- ZNS (Zalo Notification Service) support
|
|
142
|
+
- Social API support
|
|
143
|
+
- Authentication flow
|
|
144
|
+
- Basic messaging capabilities
|
|
145
|
+
- TypeScript support
|
|
146
|
+
- Comprehensive error handling
|
|
147
|
+
|
|
148
|
+
### Features
|
|
149
|
+
- OAuth 2.0 authentication
|
|
150
|
+
- Message sending (text, image, file, sticker)
|
|
151
|
+
- User management
|
|
152
|
+
- Template management
|
|
153
|
+
- Quota monitoring
|
|
154
|
+
- Webhook event handling
|
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
A comprehensive TypeScript/JavaScript SDK for Zalo APIs, providing easy-to-use interfaces for:
|
|
4
4
|
|
|
5
5
|
- **Official Account (OA) API** - Manage your Zalo Official Account
|
|
6
|
+
- **Consultation Service** - Send customer support messages within 48-hour window
|
|
6
7
|
- **Zalo Notification Service (ZNS)** - Send template-based notification messages
|
|
7
8
|
- **Social API** - Access user social information and authentication
|
|
8
9
|
- **Group Message Framework (GMF)** - Send messages to Zalo groups
|
|
@@ -35,6 +36,7 @@ npm install @warriorteam/redai-zalo-sdk
|
|
|
35
36
|
- **[Services Added](./SERVICES_ADDED.md)** - Detailed breakdown of all services and features
|
|
36
37
|
- **[Group Management](./docs/GROUP_MANAGEMENT.md)** - Group messaging and management
|
|
37
38
|
- **[Article Management](./docs/ARTICLE_MANAGEMENT.md)** - Content and article management
|
|
39
|
+
- **[Consultation Service](./docs/CONSULTATION_SERVICE.md)** - Customer service messaging guide
|
|
38
40
|
|
|
39
41
|
## Development
|
|
40
42
|
|
|
@@ -319,6 +321,49 @@ For support and questions:
|
|
|
319
321
|
- Create an issue on GitHub
|
|
320
322
|
- Contact RedAI team
|
|
321
323
|
|
|
324
|
+
### Consultation Service (Customer Support)
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
// Send consultation text message
|
|
328
|
+
await zalo.consultation.sendTextMessage(accessToken,
|
|
329
|
+
{ user_id: "user-id" },
|
|
330
|
+
{
|
|
331
|
+
type: "text",
|
|
332
|
+
text: "Xin chào! Tôi có thể hỗ trợ gì cho bạn?"
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
// Send consultation image with guide
|
|
337
|
+
await zalo.consultation.sendImageMessage(accessToken,
|
|
338
|
+
{ user_id: "user-id" },
|
|
339
|
+
{
|
|
340
|
+
type: "image",
|
|
341
|
+
attachment: {
|
|
342
|
+
type: "image",
|
|
343
|
+
payload: {
|
|
344
|
+
url: "https://example.com/support-guide.jpg"
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
// Send file attachment for support
|
|
351
|
+
await zalo.consultation.sendFileMessage(accessToken,
|
|
352
|
+
{ user_id: "user-id" },
|
|
353
|
+
{
|
|
354
|
+
type: "file",
|
|
355
|
+
url: "https://example.com/manual.pdf",
|
|
356
|
+
filename: "User Manual.pdf",
|
|
357
|
+
attachment: {
|
|
358
|
+
type: "file",
|
|
359
|
+
payload: {
|
|
360
|
+
url: "https://example.com/manual.pdf"
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
);
|
|
365
|
+
```
|
|
366
|
+
|
|
322
367
|
### ZNS (Zalo Notification Service)
|
|
323
368
|
|
|
324
369
|
```typescript
|
package/SERVICES_ADDED.md
CHANGED
|
@@ -4,7 +4,44 @@ This document summarizes all the services that have been added to the RedAI Zalo
|
|
|
4
4
|
|
|
5
5
|
## New Services Added
|
|
6
6
|
|
|
7
|
-
### 1.
|
|
7
|
+
### 1. ConsultationService (`src/services/consultation.service.ts`)
|
|
8
|
+
|
|
9
|
+
**Purpose**: Customer Service messaging for sending consultation messages within 48-hour window
|
|
10
|
+
|
|
11
|
+
**Key Features**:
|
|
12
|
+
|
|
13
|
+
- Send consultation text messages
|
|
14
|
+
- Send consultation image messages
|
|
15
|
+
- Send consultation file messages
|
|
16
|
+
- Send consultation sticker messages
|
|
17
|
+
- Send general consultation messages
|
|
18
|
+
- Automatic validation of message content
|
|
19
|
+
- Built-in error handling and retry logic
|
|
20
|
+
- 48-hour interaction window enforcement
|
|
21
|
+
|
|
22
|
+
**Main Methods**:
|
|
23
|
+
|
|
24
|
+
- `sendTextMessage()` - Send consultation text message (max 2000 characters)
|
|
25
|
+
- `sendImageMessage()` - Send consultation image with support content
|
|
26
|
+
- `sendFileMessage()` - Send consultation file attachments (guides, manuals)
|
|
27
|
+
- `sendStickerMessage()` - Send consultation sticker messages
|
|
28
|
+
- `sendMessage()` - Send any type of consultation message
|
|
29
|
+
|
|
30
|
+
**Usage Conditions**:
|
|
31
|
+
|
|
32
|
+
- Must be sent within 48 hours of last user interaction
|
|
33
|
+
- Content must be consultation/support related (no direct advertising)
|
|
34
|
+
- User must have followed the OA and not blocked it
|
|
35
|
+
- No daily limit but must follow anti-spam guidelines
|
|
36
|
+
|
|
37
|
+
**Integration**:
|
|
38
|
+
|
|
39
|
+
- Accessible via `zalo.consultation` property
|
|
40
|
+
- Quick methods: `zalo.sendConsultationText()`, `zalo.sendConsultationImage()`
|
|
41
|
+
- Full webhook integration support
|
|
42
|
+
- Comprehensive error handling with ZaloSDKError
|
|
43
|
+
|
|
44
|
+
### 2. ZNSService (`src/services/zns.service.ts`)
|
|
8
45
|
|
|
9
46
|
**Purpose**: Zalo Notification Service for sending template-based notifications
|
|
10
47
|
|