zalo-api-final - API Zalo cá nhân hoàn chỉnh cho JavaScript. Xây dựng node n8n, backend quản lý nhiều tài khoản Zalo, phần mềm bán hàng, quản trị Zalo cho công ty tăng doanh số. Gửi tin nhắn, tạo nhóm, quản lý bạn bè, chặn/bỏ chặn người dùng, chấp nhận lờ
npm install zalo-api-final


Thư viện API Zalo cá nhân mạnh mẽ và hoàn chỉnh nhất cho JavaScript/TypeScript
✨ Phiên bản cuối cùng và tốt nhất của zalo-api-final với nhiều cải tiến về bảo mật, ổn định và tính năng.
🔗 Xem hướng dẫn đầy đủ tại Documentation
Tài liệu bao gồm:
- 📋 Hướng dẫn cài đặt và sử dụng từng bước
- 🔧 API Methods và Examples chi tiết
- 📚 Models & Types reference
- 🎧 Event Listeners và Webhook
- 🔐 Các phương thức đăng nhập
- 🎯 Ví dụ thực tế và best practices
- 🏢 Doanh nghiệp muốn quản lý nhiều tài khoản Zalo để tăng doanh số
- 💻 Developer xây dựng bot, backend, hoặc ứng dụng tích hợp Zalo
- 🔧 N8N Users tạo node tự động hóa workflow Zalo
- 📱 Marketer cần tự động hóa marketing qua Zalo
- 🛒 Bán hàng online quản lý khách hàng qua Zalo
javascript
import { Zalo } from 'zalo-api-final';// Quản lý nhiều tài khoản Zalo
const accounts = [
new Zalo({ sessionId: 'account1' }),
new Zalo({ sessionId: 'account2' }),
new Zalo({ sessionId: 'account3' })
];
// Gửi tin nhắn marketing hàng loạt
for (const zalo of accounts) {
await zalo.sendMessage({
userId: 'customer_id',
message: 'Khuyến mãi đặc biệt hôm nay!'
});
}
`$3
`javascript
// Tạo node N8N tùy chỉnh
export class ZaloNode implements INodeType {
description: INodeTypeDescription = {
displayName: 'Zalo',
name: 'zalo',
// ... cấu hình node
}; async execute(this: IExecuteFunctions) {
const zalo = new Zalo();
// Logic xử lý
}
}
`$3
`javascript
import express from 'express';
import { Zalo } from 'zalo-api-final';const app = express();
const zalo = new Zalo();
// API endpoint gửi tin nhắn
app.post('/send-message', async (req, res) => {
const { userId, message } = req.body;
try {
await zalo.sendMessage({ userId, message });
res.json({ success: true });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.listen(3000);
`$3
`javascript
class ZaloSalesBot {
constructor() {
this.zalo = new Zalo();
} // Tự động trả lời khách hàng
async handleCustomerMessage(message) {
if (message.includes('giá')) {
await this.sendPriceList(message.userId);
}
if (message.includes('đặt hàng')) {
await this.processOrder(message.userId);
}
}
// Gửi bảng giá
async sendPriceList(userId) {
await this.zalo.sendMessage({
userId,
message: '📋 Bảng giá sản phẩm:\n...'
});
}
}
`☕ Ủng hộ dự án
Nếu thư viện này giúp bạn tiết kiệm thời gian hoặc giải quyết được vấn đề, hãy cân nhắc ủng hộ tác giả một ☕ để duy trì và phát triển thêm tính năng mới!
📱 Quét QR Code để mời cafe:

VietinBank - 100884532014 - NGUYEN THI HIEN
� Tài liệu chi tiết
Xem tài liệu API đầy đủ tại: https://hiennguyen270995.github.io/zalo-api-final/
- 📖 API Methods
- 🏗️ Models & Types
- 🎧 Event Listeners
- 🔐 Login Methods
�📦 Cài đặt
`bash
NPM
npm install zalo-api-finalYarn
yarn add zalo-api-finalPNPM
pnpm add zalo-api-final
`🔧 Sử dụng cơ bản
$3
`javascript
import { Zalo } from 'zalo-api-final';const zalo = new Zalo();
// Đăng nhập bằng QR
await zalo.loginQR((qr) => {
console.log('Quét mã QR này để đăng nhập:');
console.log(qr);
});
console.log('Đăng nhập thành công!');
`$3
`javascript
// Gửi tin nhắn văn bản
await zalo.sendMessage({
userId: 'recipient_id',
message: 'Xin chào! 👋'
});// Gửi hình ảnh
await zalo.sendMessage({
userId: 'recipient_id',
attachment: {
type: 'image',
url: 'https://example.com/image.jpg'
}
});
`$3
`javascript
// Lấy danh sách bạn bè
const friends = await zalo.getAllFriends();// Gửi lời mời kết bạn
await zalo.sendFriendRequest({
phone: '0123456789',
message: 'Xin chào, kết bạn nhé!'
});
// Chấp nhận lời mời kết bạn
await zalo.acceptFriendRequest('request_id');
`$3
`javascript
// Tạo nhóm mới
const group = await zalo.createGroup({
name: 'Nhóm Marketing',
members: ['user1', 'user2', 'user3']
});// Thêm thành viên vào nhóm
await zalo.addUserToGroup({
groupId: group.id,
userId: 'new_member_id'
});
`$3
`javascript
// Lắng nghe tin nhắn mới
zalo.listen((message) => {
console.log('Tin nhắn mới:', message);
// Tự động trả lời
if (message.type === 'text') {
zalo.sendMessage({
userId: message.userId,
message: Bạn vừa nói: ${message.text}
});
}
});
`🏗️ Ví dụ nâng cao
$3
`javascript
class ZaloCustomerService {
constructor() {
this.zalo = new Zalo();
this.supportKeywords = {
'hỗ trợ': this.handleSupport,
'khiếu nại': this.handleComplaint,
'đơn hàng': this.handleOrder
};
} async start() {
await this.zalo.loginQR();
this.zalo.listen(async (message) => {
for (const [keyword, handler] of Object.entries(this.supportKeywords)) {
if (message.text.toLowerCase().includes(keyword)) {
await handler.call(this, message);
break;
}
}
});
}
async handleSupport(message) {
await this.zalo.sendMessage({
userId: message.userId,
message: '🆘 Chúng tôi sẽ hỗ trợ bạn ngay! Vui lòng mô tả vấn đề cụ thể.'
});
}
}
`$3
`javascript
class ZaloMarketing {
constructor(accounts) {
this.accounts = accounts.map(acc => new Zalo(acc));
} async broadcastMessage(message, customerList) {
const chunks = this.chunkArray(customerList, this.accounts.length);
const promises = chunks.map(async (chunk, index) => {
const zalo = this.accounts[index];
for (const customerId of chunk) {
await zalo.sendMessage({
userId: customerId,
message: this.personalizeMessage(message, customerId)
});
// Delay để tránh spam
await this.delay(1000);
}
});
await Promise.all(promises);
}
personalizeMessage(template, customerId) {
// Cá nhân hóa tin nhắn
return template.replace('{name}', this.getCustomerName(customerId));
}
}
`🔒 Bảo mật & Lưu ý
$3
- Thư viện này dành cho mục đích học tập và phát triển
- Việc sử dụng có thể vi phạm điều khoản dịch vụ của Zalo
- Tác giả không chịu trách nhiệm nếu tài khoản bị khóa
- Hãy sử dụng có trách nhiệm và tuân thủ pháp luật$3
`javascript
// Sử dụng rate limiting
const rateLimiter = new RateLimit({
windowMs: 60000, // 1 phút
max: 30 // Tối đa 30 tin nhắn/phút
});// Xử lý lỗi properly
try {
await zalo.sendMessage(params);
} catch (error) {
if (error.code === 'RATE_LIMITED') {
await delay(60000); // Chờ 1 phút
return retry();
}
console.error('Lỗi:', error.message);
}
`🤝 Đóng góp
Chúng tôi hoan nghênh mọi đóng góp! Hãy:
1. Fork repository này
2. Tạo nhánh tính năng (
git checkout -b tinh-nang/TinhNangTuyetVoi)
3. Commit thay đổi (git commit -m 'Thêm tính năng tuyệt vời')
4. Push lên nhánh (git push origin tinh-nang/TinhNangTuyetVoi`)- 📧 Email: hiennguyen270995@gmail.com
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
MIT License - xem LICENSE để biết thêm chi tiết.
Dựa trên thư viện zalo-api-final với nhiều cải tiến và tối ưu hóa.
---
⭐ Nếu thư viện hữu ích, hãy cho chúng tôi một star trên GitHub!
💡 Có ý tưởng tính năng mới? Hãy tạo issue để thảo luận!
💡 Có ý tưởng tính năng mới? Hãy tạo issue để thảo luận!