Auto Marketing — Multi-Agent Architecture với n8n
Bài 5/21Thực hành

Bài 5 — Telegram Bot + Google Sheets: credential đầu tiên

Tạo Telegram Bot, OAuth Google Sheets trên n8n Cloud, gửi tin test.

24 min
Mục tiêu bài học
  • Tạo Telegram Bot qua @BotFather và credential n8n
  • Kết nối Google Sheets OAuth trên n8n Cloud (managed OAuth)
  • Chạy workflow test Append Sheet → Telegram

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

Bước A — Tạo Bot qua @BotFather

  1. Mở Telegram → chat @BotFather → gửi /newbot
  2. Đặt tên hiển thị và username (phải kết thúc bằng bot)
  3. Copy HTTP API Token — dùng trong n8n Credentials → Telegram API
  4. Chat với bot của bạn một lần (Start) để bot nhận tin nhắn

Bước B — Telegram credential trên n8n Cloud

  1. n8n Cloud → Credentials → Add credential → Telegram API
  2. Dán Access Token từ BotFather → Save
  3. Thêm node Telegram Trigger → chọn credential → n8n Cloud tự tạo webhook HTTPS
  4. Lưu chat_id từ output node (dùng cho Send Message sau này)
Webhook URLs trong node Webhook — tương tự Telegram Trigger trên Cloud
n8n Cloud cung cấp Production/Test webhook URL sẵn — không cần cấu hình reverse proxydocs.n8n.io

Tài liệu chính thức — Google Sheets

Managed OAuth2 credentials trên n8n Cloud
n8n Cloud hỗ trợ managed OAuth — click Connect my account, không cần tạo Google Cloud project cho học tậpdocs.n8n.io
Google Cloud project dropdown — khi dùng custom OAuth self-host
Self-host cần chọn Google Cloud project; Cloud thường dùng managed OAuth đơn giản hơndocs.n8n.io

Bước C — Google Sheets trên n8n Cloud

  1. Credentials → Google Sheets OAuth2 API → Sign in with Google → Allow
  2. Share Google Sheet Auto Marketing Tracker cho email Google vừa OAuth
  3. Node Google Sheets → Operation Append → chọn Document + Sheet Products
  4. Map cột: product_id, name, description, created_at

Workflow test tích hợp

Workflow mẫu với IF node — logic phân nhánh tương tự Orchestrator Switch
Pattern IF/Switch bạn sẽ dùng cho /product, /generate, /reportdocs.n8n.io
[Manual Trigger]
    → [Google Sheets: Append row to Products tab]
    → [Telegram: Send Message "Đã thêm sản phẩm {{ $json.name }}"]
    → [Execute Workflow] — lưu workflow, bấm Test hoặc Publish

Bài tập thực hành

  • Tạo Bot + credential Telegram trên n8n Cloud
  • Kết nối Google Sheets OAuth + append 1 dòng Products
  • Gửi Telegram confirm — screenshot Executions success

Tiếp tục lộ trình

Hoàn thành từng bài thực hành để xây hệ Auto Marketing Multi-Agent của riêng bạn.

Bài 5 — Telegram Bot + Google Sheets: credential đầu tiên — Auto Marketing — Multi-Agent Architecture với n8n | Sage Marketing