ℹ️ LOW |
Category: Vận hành |
ID: O03 |
Owner: CEO
O03 — Google Chat DM via Domain-wide Delegation
Bài học
send_dm() trong config/api_config.py gửi được DM cá nhân tới mọi Google account (Gmail, Workspace, bất kỳ domain), không giới hạn @thescentnote.com.
Chi tiết kỹ thuật
viet.nguyen@thescentnote.com)spaces.setup (tạo DM space) + spaces.messages.createchat.spaces.create + chat.messages.create (chỉ 2 scopes này, không dùng chat.bot)Usage
from config.api_config import send_dm, send_dm_bulk
Gửi 1 người (by email hoặc tên)
send_dm("ketoan@thescentnote.com", "Nhắc: nộp D02 data")
send_dm("Ánh", "Nhắc: set TikTok R Parfums")
Gửi nhiều người
send_dm_bulk(["ketoan", "Long", "Ánh"], "Nhắc việc quá hạn")
External email cũng được
send_dm("external@gmail.com", "Hello from Company HQ")
Setup requirements
1. Service account: config/gw_service_account.json (project: note-company-hq)
2. Google Cloud Console: Enable Chat API + Domain-wide Delegation on service account
3. Google Admin: Domain-wide Delegation → Client ID 104872753169041806193 → scopes chat.spaces.create,chat.messages.create
Liên kết
config/api_config.py — functions send_dm(), send_dm_bulk(), _get_chat_service()config/all_staff.yamlsend_chat_alert() — khác cơ chế, dùng webhook POST
📚 Published from Company Knowledge Base — O03
Last updated: 2026-03-14
Review by: 2026-06-12