"n8n in Practice 2026 — Wiring Up Discord, Notion, and Gmail"
From OAuth setup to your first three working workflows, step by step
ํต์ฌ ์์ฝ
- Audience: You read the n8n introduction and want to actually build it. Especially anyone stuck on OAuth.
- What you'll get: 1) Discord, Notion, and Gmail OAuth/credential setup step by step, 2) three working flows — Discord bot command + AI reply / Gmail → Notion auto-triage / Notion publish → Discord announcement, 3) seven common gotchas + fixes, 4) operational tips (monitoring, errors, backups).
- Prerequisite: n8n cloud trial or self-hosted install completed; accounts on each service.
1. Pre-flight — three credentials
Where most n8n attempts stall is OAuth/credential setup. Get these once and you're done.
1.1 Discord — Webhook + Bot Token
Discord supports two paths. Webhook for one-way send. Bot Token for two-way (trigger + reply).
Webhook (simple) 1. Discord channel settings → Integrations → Webhooks → New Webhook 2. Copy the URL 3. n8n: Discord node → Credential: paste Webhook URL → Save
Bot Token (two-way)
1. Discord Developer Portal → New Application → Bot → copy Token
2. OAuth2 → URL Generator → scopes: bot, applications.commands → permissions: read/send messages → invite bot to your server with the generated URL
3. n8n: Discord Bot API → paste Bot Token → Save
Most common mistake: pasting the token without inviting the bot to a server → no message events arrive.
1.2 Notion — Internal Integration Token
For Notion, an Internal Integration is far simpler than OAuth.
- Notion Integrations → New Integration
- Name + workspace → create
- Copy Internal Integration Secret
- In each page or database you want to automate: ⋯ → Connections → add the integration ← people forget this
- n8n: Notion API → paste secret as API Key
Most common mistake: skipping step 4 → "Object not found." The integration must be explicitly attached to each page.
1.3 Gmail — OAuth2
The most finicky. Two options:
Option A: n8n Cloud Managed OAuth2 (easiest) - Cloud users only. Click "Sign in with Google" when adding the credential. Done.
Option B: Self-hosted — set up Google Cloud Console manually
1. Google Cloud Console → create a project
2. APIs & Services → Library → enable Gmail API
3. OAuth consent screen → External → register your email
4. Credentials → Create OAuth 2.0 Client ID → Web application
5. Add https://your-n8n-domain/rest/oauth2-credential/callback to Redirect URIs
6. Copy Client ID / Secret
7. n8n: Gmail OAuth2 → paste Client ID / Secret → click "Connect my account"
Most common mistake: HTTP (not HTTPS) self-host fails OAuth. HTTPS is mandatory — Cloudflare Tunnel or ngrok.
2. Flow 1 — Discord bot command with AI reply
Scenario
Users type /ask <question> in Discord; the bot responds via Claude or GPT.
Steps
1. Discord Trigger node
- Bot Token credential
- Trigger on: Message Created
- Channel: a specific channel ID
2. IF node
- Condition: message text starts with "/ask "
3. Code or Set node
- Strip "/ask " prefix → question variable
4. Anthropic Chat node
- Model: Claude Sonnet 4.6
- System: "You are a helpful Discord bot. Reply concisely in plain English."
- User: {{ $json.question }}
5. Discord node (send reply)
- Operation: Send Message
- Channel: same channel
- Reply To: original message ID
- Content: {{ $json.choices[0].message.content }}
Cost estimate
- 50 calls/day → 1,500 runs/month → fits Cloud Starter (€24, 2,500 cap).
- Sonnet 4.6 at ~500 in / 500 out × 1,500 = $2.25 in + $11.25 out ≈ $13.50/month.
- Total ≈ €24 + $13.50 ≈ €36/month.
To cut cost: route through Haiku for simple Q&A first; escalate to Sonnet only on complex queries.
3. Flow 2 — Gmail → Notion auto-triage
Scenario
Tagged emails are auto-saved to a Notion database with title, sender, summary, link.
Steps
1. Gmail Trigger
- Credential: Gmail OAuth2
- Watch label: "Important" or inbox
- Polling: every 5 minutes (or webhook)
2. Claude Haiku Chat node
- System: "Summarize the email in one line, max 100 chars."
- User: {{ $json.snippet }}
3. Notion node
- Operation: Create Database Page
- Database: "Email Triage"
- Properties:
- Title: {{ $json.subject }}
- From: {{ $json.from }}
- Summary: {{ $('Claude Haiku').item.json.choices[0].message.content }}
- URL: {{ $json.threadUrl }}
- Date: {{ $json.date }}
- Source: "Auto"
Optional — add classification
Extend step 2 to classify + summarize:
System: "Classify the email into [Work/Personal/Subscription/Spam]
and add a one-line summary. Output JSON: {category, summary}."
Then add a category Notion property and a Switch node to route different categories to different databases.
Cost
- 100 emails/day × 30 = 3,000 runs → Cloud Pro €60/month
- Haiku tokens ≈ $1.50/month
- Total ≈ €61.50/month
Self-hosted + Haiku → ~$1.50/month total.
4. Flow 3 — Notion publish → Discord announcement
Scenario
A Notion database row flipping to "Status: Published" auto-posts an announcement to a Discord channel.
Steps
1. Schedule Trigger
- Every 5 minutes
2. Notion node
- Operation: Database Get Many
- Database: "Blog Posts"
- Filter: Status = "Published" AND Last Edited > {{ now - 5min }}
3. Loop Over Items (one row at a time)
4. (Optional) AI Agent node
- Model: Claude Sonnet 4.6
- System: "Take the post info and write a Discord announcement under 200 chars.
Include one emoji. End with the link."
- User: title + summary + URL
5. Discord node
- Operation: Send Message
- Channel: #announcements
- Content: {{ $('AI Agent').item.json.message }}
- Embed: title=post title, url=link, image=thumbnail
6. Notion node (again)
- Operation: Update Page
- Property: "Discord Announced" = true
(prevents duplicate posts)
Key trick
- Step 6 is the de-duplication. Without it, the same page posts every 5 minutes.
- Or add
AND Discord Announced = falseto the step 2 filter.
5. Seven common gotchas + fixes
| Symptom | Cause | Fix |
|---|---|---|
| Notion "Object not found" | Integration not attached to that page | Page ⋯ → Connections → add integration |
| Discord bot doesn't receive messages | Bot wasn't invited to the server | Use OAuth2 URL Generator to invite |
| Gmail OAuth "Access blocked" | Your email isn't in OAuth consent screen Test Users | Add yourself to Test Users |
| Self-host OAuth redirect fails | Not HTTPS or domain mismatch | Expose via Cloudflare Tunnel/ngrok; match redirect URI exactly |
| Same item processed repeatedly | No de-duplication flag | Add a "Processed" column + filter AND Processed = false |
| Webhook events never arrive | Trial relies on polling | Trial → polling; production → webhook |
| LLM response fails to parse | Free-form output | "Output JSON only" in system prompt + JSON Parse node |
6. Operations tips
6.1 Monitoring
- Executions tab: failed runs in red — click to see which node failed.
- Email notifications: Settings → Personal → enable error emails.
6.2 Error workflow
Build a dedicated alert workflow and connect every workflow's "Workflow Settings → Error Workflow."
6.3 Backups
- Cloud: handled.
- Self-host:
pg_dump(PostgreSQL) or daily SQLite copy. Also export workflow JSON to Git.
6.4 Secret management
- API keys go in Credentials only — never in node parameters.
- Self-host: set
N8N_ENCRYPTION_KEYenv var.
Developer notes
- Workflow as code: commit n8n JSON to Git → PR review → import on deploy. Enables CI/CD.
- Custom nodes: build your own (docs) for unusual SaaS or internal systems — TypeScript.
- Verify webhook secrets: external webhook nodes should validate a query token or HMAC signature. An exposed webhook is open to anyone.
- Rate-limit handling: Wait + Loop for token-bucket patterns; or push to an external queue (Redis) + Schedule.
- Postgres + multi-instance: run PostgreSQL backend with Worker mode for production throughput.
- Tracing: in big workflows, add Set nodes that emit metadata (timestamp, step name) — easy to follow execution logs.
References
- n8n Discord integration
- n8n Notion credentials docs
- n8n Google credentials docs
- GitHub — awesome-n8n-templates (280+)
- Hostinger — n8n + Discord guide
This is part 7-2 of 11 in the AI Basics series. Next: Local LLMs — Ollama and LM Studio.
๋๊ธ
๋๊ธ ์ฐ๊ธฐ