npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

zalo-api-final

v2.1.1

Published

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ờ

Downloads

203

Readme

🚀 Zalo API Final - API Zalo Cá Nhân Hoàn Chỉnh

npm version Downloads License: MIT

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.

📖 Tài liệu chính thức

🔗 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

🎯 Dành cho ai?

  • 🏢 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

⭐ Tính năng chính

💬 Quản lý tin nhắn

  • ✅ Gửi tin nhắn văn bản, hình ảnh, video
  • ✅ Gửi sticker, emoji, link preview
  • ✅ Forward tin nhắn
  • ✅ Xóa tin nhắn đã gửi
  • ✅ Nhận webhook tin nhắn real-time

👥 Quản lý bạn bè

  • ✅ Lấy danh sách bạn bè
  • ✅ Tìm kiếm người dùng qua số điện thoại
  • ✅ Gửi lời mời kết bạn
  • ✅ Chấp nhận/từ chối lời mời kết bạn
  • ✅ Hủy lời mời đã gửi
  • ✅ Chặn/bỏ chặn người dùng
  • ✅ Đặt/xóa biệt danh bạn bè

🏘️ Quản lý nhóm

  • ✅ Tạo nhóm mới
  • ✅ Thêm/xóa thành viên
  • ✅ Thay đổi tên nhóm, avatar
  • ✅ Đặt/xóa phó nhóm
  • ✅ Chuyển quyền quản trị
  • ✅ Chặn/bỏ chặn thành viên
  • ✅ Tạo link mời nhóm
  • ✅ Giải tán nhóm

🔔 Webhook & Events

  • ✅ Lắng nghe tin nhắn mới
  • ✅ Theo dõi thay đổi nhóm
  • ✅ Nhận thông báo bạn bè
  • ✅ Event typing, seen, delivered

🛠️ Tính năng nâng cao

  • ✅ Tạo poll/bình chọn
  • ✅ Quản lý ghi chú nhóm
  • ✅ Tạo reminder/nhắc nhở
  • ✅ Upload file đính kèm
  • ✅ Quản lý thông tin cá nhân

🚀 Ứng dụng thực tế

🏢 Multi-Account Management cho Doanh nghiệp

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!'
  });
}

🔧 Xây dựng Node N8N

// 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ý
  }
}

📱 Backend API Server

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);

🛒 Phần mềm bán hàng

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/

�📦 Cài đặt

# NPM
npm install zalo-api-final

# Yarn
yarn add zalo-api-final

# PNPM
pnpm add zalo-api-final

🔧 Sử dụng cơ bản

Đăng nhập QR Code

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

// 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'
  }
});

Quản lý bạn bè

// 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');

Quản lý nhóm

// 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 webhook

// 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

Hệ thống customer service tự động

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ể.'
    });
  }
}

Multi-account marketing automation

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 ý

⚠️ Lưu ý quan trọng

  • 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

🛡️ Best practices

// 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)
  5. Mở Pull Request

📞 Hỗ trợ

📝 Changelog

v2.1.0

  • ✨ Thêm hỗ trợ multi-account management
  • 🚀 Cải thiện performance và stability
  • 🔧 Tối ưu hóa cho N8N integration
  • 📖 Hoàn thiện documentation tiếng Việt
  • 🛡️ Tăng cường bảo mật

v2.0.0

  • 🎉 Release chính thức
  • 📦 Hỗ trợ cả ESM và CommonJS
  • 🔄 Rebuild từ zalo-api-final với nhiều cải tiến
  • 🎯 Tối ưu cho business applications

📄 License

MIT License - xem LICENSE để biết thêm chi tiết.

Credits

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!