You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Clone repository
git clone https://github.com/your-org/zia.git
cd zia
# Cài đặt dependencies
bun install
# Copy file môi trường mẫu
cp apps/bot/.env.example apps/bot/.env
# Cấu hình API keys trong apps/bot/.env# Tối thiểu cần GEMINI_API_KEY# Chạy database migrations
bun run --cwd apps/bot db:migrate
Đăng Nhập Zalo Lần Đầu
Chạy bot: bun run dev:bot
File qr.png sẽ được tạo trong apps/bot/
Mở Zalo → Cài đặt → Đăng nhập trên máy tính → Quét mã QR
Credentials được lưu vào credentials.json cho các phiên sau
📖 Sử Dụng
# Development
bun run dev:bot # Chạy bot với hot reload
bun run dev:web # Chạy web dashboard# Production
bun run start:bot # Chạy bot production
bun run build:web # Build web dashboard# Database
bun run --cwd apps/bot db:studio # Mở Drizzle Studio
bun run --cwd apps/bot db:generate # Tạo migrations
bun run --cwd apps/bot db:migrate # Chạy migrations# Testing
bun run test# Tất cả tests
bun run test:integration # Integration tests
⚙️ Cấu Hình
Biến Môi Trường (apps/bot/.env)
# Bắt buộc
GEMINI_API_KEY=your_gemini_api_key
# Hỗ trợ nhiều keys (tự động xoay khi rate limit)# GEMINI_API_KEY=key1,key2,key3# Hoặc:# GEMINI_API_KEY_1=key1# GEMINI_API_KEY_2=key2# Dịch vụ tùy chọn
GROQ_API_KEY=your_groq_key # Background agent
E2B_API_KEY=your_e2b_key # Chạy code sandbox
FREEPIK_API_KEY=your_freepik_key # Tạo ảnh AI
ELEVENLABS_API_KEY=your_elevenlabs_key # Text-to-speech
YOUTUBE_API_KEY=your_youtube_key # Tìm kiếm YouTube
GOOGLE_SEARCH_API_KEY=your_search_key # Tìm kiếm web
GOOGLE_SEARCH_CX=your_search_engine_cx
GIPHY_API_KEY=your_giphy_key # Tìm kiếm GIF# Cloud Backup (cho Render/Railway)
GITHUB_GIST_TOKEN=your_github_token
GITHUB_GIST_ID=your_gist_id
# API Key cho Web Dashboard
API_KEY=your_random_api_key
Cài Đặt Runtime (apps/bot/settings.json)
Các cấu hình quan trọng:
Section
Key
Mô tả
bot
useStreaming
Bật streaming response
bot
maxToolDepth
Độ sâu tool calls tối đa
bot
sleepMode
Tự động offline theo giờ
bot
maintenanceMode
Chế độ bảo trì
buffer
delayMs
Cửa sổ gom tin nhắn (ms)
modules
*
Bật/tắt từng module
allowedUserIds
-
Whitelist user IDs
cloudBackup
enabled
Bật cloud backup
✨ Tính Năng
Xử Lý Tin Nhắn
Message Buffering (RxJS) - Gom nhiều tin nhắn liên tiếp:
User gửi: "Alo" → "Có đó không" → "Giúp mình với"
↓ (đợi 2.5s không có tin mới)
Bot xử lý: [3 tin nhắn cùng lúc]
Hỗ Trợ Media
Loại
Định dạng
Xử lý
Hình ảnh
PNG, JPG, GIF, WEBP, HEIC
Phân tích bởi Gemini
Video
MP4, MOV, AVI, WEBM (< 20MB)
Trích xuất thumbnail
Audio
AAC, MP3, WAV, OGG, FLAC
Tự động transcribe
Voice
Tin nhắn thoại Zalo
Tự động transcribe
File
PDF, TXT, DOC, Code files
Trích xuất nội dung
Response Tags
[reaction:heart] → Thả reaction vào tin cuối
[sticker:hello] → Gửi sticker
[msg]Nội dung[/msg] → Gửi tin nhắn riêng
[quote:0]Trả lời[/quote] → Reply vào tin cụ thể
[undo:-1] → Thu hồi tin nhắn cuối của bot
Rich Text Formatting
Cú pháp
Kết quả
*text*
đậm
_text_
nghiêng
__text__
gạch chân
~text~
gạch ngang
🔌 Modules & Tools
Chat Module
Tool
Mô tả
clearHistory
Xóa lịch sử chat
saveMemory
Lưu vào bộ nhớ dài hạn
recallMemory
Truy xuất bộ nhớ
Media Module
Tool
Mô tả
API cần thiết
createChart
Tạo biểu đồ (bar, line, pie)
-
createFile
Tạo tài liệu (docx, pdf, pptx, xlsx)
-
freepikImage
Tạo ảnh AI
Freepik
textToSpeech
Chuyển text thành giọng nói
ElevenLabs
Search Module
Tool
Mô tả
API cần thiết
googleSearch
Tìm kiếm web
Google Search
youtube
Tìm kiếm/lấy thông tin YouTube
YouTube API
weather
Thời tiết
-
currency
Tỷ giá tiền tệ
-
steam
Thông tin game Steam
-
Social Module
Tool
Mô tả
getUserInfo
Lấy thông tin user Zalo
getAllFriends
Danh sách bạn bè
getFriendOnlines
Bạn bè đang online
getGroupMembers
Thành viên nhóm
forwardMessage
Chuyển tiếp tin nhắn
board
Quản lý board/ghi chú
poll
Tạo/quản lý bình chọn
reminder
Tạo/quản lý nhắc nhở
groupAdmin
Quản lý nhóm (admin)
friendRequest
Quản lý lời mời kết bạn
Task Module
Tool
Mô tả
API cần thiết
executeCode
Chạy code trong sandbox
E2B
solveMath
Giải toán với LaTeX
-
createApp
Tạo code ứng dụng
-
scheduleTask
Lên lịch task tương lai
Groq
flushLogs
Gửi file log qua Zalo
-
Entertainment Module (Jikan API)
Tool
Mô tả
jikanSearch
Tìm kiếm anime/manga
jikanDetails
Lấy chi tiết
jikanTop
Bảng xếp hạng
jikanSeason
Anime theo mùa
jikanCharacters
Danh sách nhân vật
jikanRecommendations
Gợi ý
jikanGenres
Danh sách thể loại
jikanEpisodes
Danh sách tập
nekosImages
Ảnh anime
giphyGif
Tìm kiếm GIF (cần Giphy API)
Academic Module (TVU Portal)
Tool
Mô tả
tvuLogin
Đăng nhập portal
tvuStudentInfo
Thông tin sinh viên
tvuSemesters
Danh sách học kỳ
tvuSchedule
Thời khóa biểu
tvuGrades
Điểm học tập
tvuTuition
Thông tin học phí
tvuCurriculum
Chương trình đào tạo
tvuNotifications
Thông báo portal
🌐 Web Dashboard
Dashboard Next.js để quản lý bot:
Trang
Chức năng
/
Dashboard tổng quan, thống kê
/settings
Cấu hình bot
/logs
Xem logs
/memories
Quản lý long-term memory
/history
Lịch sử hội thoại
/tasks
Quản lý scheduled tasks
/backup
Cloud backup/restore
Chạy Web Dashboard
# Development
bun run dev:web
# Production
bun run build:web
bun run --cwd apps/web start
Cần set API_KEY trong .env của cả bot và web để bảo vệ API endpoints.