
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
zalo-api-final
Advanced tools
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ờ
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:
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!'
});
}
// 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ý
}
}
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);
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...'
});
}
}
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
Xem tài liệu API đầy đủ tại: https://hiennguyen270995.github.io/zalo-api-final/
# NPM
npm install zalo-api-final
# Yarn
yarn add zalo-api-final
# PNPM
pnpm add zalo-api-final
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!');
// 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'
}
});
// 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');
// 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'
});
// 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}`
});
}
});
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ể.'
});
}
}
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));
}
}
// 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);
}
Chúng tôi hoan nghênh mọi đóng góp! Hãy:
git checkout -b tinh-nang/TinhNangTuyetVoi)git commit -m 'Thêm tính năng tuyệt vời')git push origin tinh-nang/TinhNangTuyetVoi)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!
FAQs
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ờ
We found that zalo-api-final demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.