Bỏ qua để đến Nội dung
Soul of NOTE
  • Khóa học
  • Check-in
    • NOTE
    • Headspace Vietnam
    • Fosllea
  • Diễn đàn
  • Company
    • Blog
    • Success Stories
  • 0
  • 0
  • Đăng nhập
Soul of NOTE
  • 0
  • 0
    • Khóa học
    • Check-in
      • NOTE
      • Headspace Vietnam
      • Fosllea
    • Diễn đàn
    • Company
      • Blog
      • Success Stories
  • Đăng nhập

[O03] O03 — Google Chat DM via Domain-wide Delegation

  • Tất cả blog
  • Knowledge Base
  • [O03] O03 — Google Chat DM via Domain-wide Delegation
  • 15 tháng 3, 2026 bởi
    [O03] O03 — Google Chat DM via Domain-wide Delegation
    Viet Nguyen
    ℹ️ 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

  • Cơ chế: Service Account + Domain-wide Delegation impersonate CEO (viet.nguyen@thescentnote.com)
  • API: Google Chat API v1 → spaces.setup (tạo DM space) + spaces.messages.create
  • Scopes: chat.spaces.create + chat.messages.create (chỉ 2 scopes này, không dùng chat.bot)
  • Tin nhắn hiện dưới danh nghĩa CEO — không phải bot
  • Không tự DM chính CEO được (Google Chat chặn)
  • 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

  • Code: config/api_config.py — functions send_dm(), send_dm_bulk(), _get_chat_service()
  • Staff roster: config/all_staff.yaml
  • Webhook (Space alerts): send_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

    trong Knowledge Base
    # Vận hành
    [O02] O02 — Intelligence System AI Audit: Current State, Gaps & Roadmap



    Bản quyền thuộc CÔNG TY TNHH NOTE
    Cung cấp bởi Odoo - Một nền tảng thương mại điện tử mã nguồn mở hàng đầu