Hébergement VPS n8n | Automatisation sécurisée et évolutive
Formation n8n en Français : Automatisation & Agents IA
This workflow watches a Gmail inbox, uses an OpenAI agent to classify every new message into one of 6 categories, applies the matching Gmail label automatically, and fires a Telegram alert the moment an email needs a direct reply (or can't be classified). This course lets you rebuild the whole thing node by node, live.
<aside> 🎯
This is a full rebuild of an older "Email Manager" template: OpenAI instead of Anthropic, labels resolved dynamically by NAME (no more hardcoded label IDs baked into the prompt), and a new Telegram alert branch.
</aside>
Gmail Trigger
→ Configuration
→ Get Gmail Labels → Aggregate Gmail Labels
→ Get Full Email
→ Classify Email (AI Agent)
→ Map Category to Label
→ Has Valid Label?
├─ true → Apply Gmail Label → Is Urgent & Alerts On?
│ ├─ true → Send Telegram Alert
│ └─ false → (end)
└─ false → Send Telegram Alert
| Credential | Type | Where to get it |
|---|---|---|
| Gmail account | Gmail OAuth2 | n8n → Credentials → New → Gmail OAuth2 → follow the Google consent screen. Needs the standard Gmail read/modify scopes (n8n requests them automatically). |
| OpenAI account | OpenAi API | platform.openai.com → API keys → Create new secret key. Paste it into a new "OpenAi API" credential in n8n. Make sure the key has access to gpt-4o-mini (or whichever model you set in Configuration). |
| Telegram account | Telegram API | Message @BotFather on Telegram → /newbot → copy the bot token into a new "Telegram API" credential in n8n. |
<aside> ⚠️
Before your first run, create 6 Gmail labels with these EXACT names (Gmail → Settings → Labels → Create new label): To Respond, FYI, Notification, Marketing, Meeting Update, Comment. The workflow resolves label IDs by matching these names — no manual ID copy-pasting needed.
</aside>
To find your Telegram chat ID: message @get_id_bot on Telegram, it replies with your numeric chat ID.