n8n tutorial - Lesson 08: Automated Email Digest to Telegram with n8n
Hi everyone, in this post we'll build a Daily Email Digest to Telegram workflow using n8n — one of the most practical n8n telegram notification setups you can run fully automated. This is Session 8 of our n8n Workflow Automation Tutorial series, and by the end you'll have a live pipeline that summarizes your important emails every day at 6 PM and sends them straight to your phone.
How to do:
Step 1 — Create a Telegram Bot with BotFather
Before building anything in n8n, you need a Telegram bot token and your personal chat ID.- Open Telegram and search for @BotFather, then send the command
/newbot. - Follow the prompts to name your bot and choose a username ending in
bot(e.g.,MyDigestBot). BotFather will reply with a bot token — copy and save it securely. - Send any message to your new bot (e.g., "hello") so it has an active chat session to respond to.
- Retrieve your chat ID by calling the Telegram API in your browser:
- Visit
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates - Find the
chat.idfield in the JSON response — this is the number you'll need later.
- Visit
Tip — Save both the bot token and chat ID somewhere safe before moving to n8n. You cannot retrieve the token again from BotFather without revoking the old one.
Step 2 — Create the Telegram Credential in n8n
With your token ready, add the Telegram credential so n8n can send messages on your bot's behalf.- In n8n, go to Credentials → New Credential and search for Telegram API.
- Paste your bot token into the Access Token field.
- Name the credential something descriptive like
Telegram (Personal), then click Save.
Step 3 — Create the Workflow and Add a Schedule Trigger
The workflow is namedT2-B6-Daily-Digest and starts with a time-based trigger set to fire every day at 6 PM.
- Create a new workflow in n8n and name it
T2-B6-Daily-Digest. - Add a Schedule Trigger node as the first node.
- Configure the trigger:
- Set Trigger Interval to Days mode (not Minutes mode).
- Set Hour to
18and Minute to0. - Set Timezone to
Asia/Ho_Chi_Minh(or your local timezone).
Note — The Schedule Trigger has 6+ modes including Minutes, Hours, Days, Weeks, Months, and Custom (Cron Expression). For a daily digest, Days mode is the cleanest option — use Cron mode only if you need complex schedules like "every weekday at 6 PM."
Step 4 — Fetch Important Emails with Gmail Get Many
This node pulls emails from your labeled inbox using a Gmail search query scoped to the last 24 hours.- Add a Gmail node and set the operation to Get Many.
- Set the Search Query field to
label:n8n/Quan-trọng newer_than:1d— replaceQuan-trọngwith whatever label name your email classifier applies to important emails. - Set Simplify to OFF — this is critical.
- Set Limit to
10.
Note — Simplify = ON sounds helpful but in practice the simplified output does not include headers.from or headers.subject. The Simplify=ON shape only exposes fields like id, threadId, snippet, payload.mimeType, sizeEstimate, historyId, internalDate, and labels. If you need sender name and subject line — and you do for a digest — you must use Simplify = OFF. This was a confirmed bug in earlier session notes and has been corrected.
Step 5 — Merge Emails into a Single Batch with a Code Node
Because the AI node needs all emails in one prompt, a Code node combines every email item into a single text block before passing it forward.- Add a Code node after the Gmail node.
- Set Run Once for All Items (not once per item) — this is what allows the node to see and merge all emails together.
- Inside the code, build three variables:
count— total number of emails retrieved.today— today's date formatted as a readable string.emails_text— a concatenated string of all emails, each truncated to250characters.
- For the email body, use a fallback: prefer
j.textif available, otherwise fall back toj.snippet. After selecting the value, normalize whitespace and cut to250chars. - Return a single item containing
emails_text,count, andtodayso the next node receives one combined object.
Tip — The 250-character truncation keeps the AI prompt compact and avoids hitting token limits, especially when you have 10 emails. The fallback from j.text to j.snippet ensures the node doesn't crash on emails where full body parsing fails.
Step 6 — Summarize with an AI Node (Claude Haiku)
A Basic LLM Chain node takes the merged email text and produces a clean, formatted Telegram-ready summary.- Add a Basic LLM Chain node and connect it to the Code node.
- Select your AI model — this workflow uses Claude Haiku 4.5.
- Set model parameters:
- Temperature:
0.3(low, for consistent factual summaries) - Max Tokens:
1500
- Temperature:
- Write a system/user prompt that includes these explicit rules for Telegram Markdown:
- Bold text must use
*bold*(single asterisk) — NOT**bold**. Telegram uses legacy Markdown, not standard Markdown. - Avoid italic (
_text_) where possible — it renders inconsistently in Telegram legacy mode. - Use placeholder square brackets
[ ]as the prompt instructs for structured output sections.
- Bold text must use
Note — This Markdown difference is easy to miss: AI models default to writing **bold** (two asterisks, standard Markdown) but Telegram's legacy parse mode only renders *bold* (one asterisk). If you skip this rule in the prompt, your digest will arrive with raw asterisks showing as plain text instead of bold formatting.
Step 7 — Send the Digest to Telegram
The final node delivers the formatted summary to your Telegram chat.- Add a Telegram node and set the operation to Send Message.
- Select the
Telegram (Personal)credential you created in Step 2. - Set Chat ID to the chat ID you retrieved from the
getUpdatesAPI call. - In the Text field, reference the AI output — typically
{{ $json.text }}or the field your LLM Chain returns. - Configure additional options:
- Parse Mode:
Markdown(enables Telegram legacy Markdown rendering) - Append n8n Attribution: OFF (removes the "Sent with n8n" footer)
- Reply Markup: None
- Parse Mode:
Step 8 — Test End-to-End and Publish
Run the full workflow manually to verify the message arrives correctly before activating it.- Click Execute Workflow to trigger a manual run.
- Check your Telegram app — the digest message should arrive with bold text rendering correctly (not showing raw asterisks).
- Verify the format looks clean: subject lines bold, no n8n footer, no broken Markdown symbols.
- If bold text is not rendering, go back to the AI prompt and confirm the
*bold*rule is stated explicitly — the AI will default back to double asterisks if the instruction is vague. - Once the test passes, click Publish (toggle the workflow to Active) — the workflow will now run automatically every day at 6 PM.
Production tip — After going live, check the workflow after the first 1-2 real scheduled runs to confirm the digest arrives on time and the format still looks right. Real email content is messier than test data and may expose edge cases in the Code node's whitespace normalization or the AI's formatting output.
Key Lessons from This Session
- Always verify field names after each n8n update. Simplify=ON output changed between versions — fields assumed to exist (
headers.from,headers.subject) were absent in the actual output. Execute a test step and inspect real field names before writing downstream expressions. - Telegram uses legacy Markdown, not standard Markdown. Bold is
*text*, not**text**— you must state this rule explicitly in your AI prompt or the message will render incorrectly. - Use Simplify=OFF when you need full email headers. Simplify=ON only exposes a limited set of fields; sender and subject require the full raw payload.
- Set Code node to "Run Once for All Items" when aggregating. Without this setting, the node processes items individually and cannot merge them into a single batch for the AI prompt.
- Explain terms before building. "Daily digest" is not obvious to all learners — define domain terms before jumping into configuration steps.
- Don't activate a new workflow before completing prerequisite steps. In this session, the email classifier workflow (
T2-B4-Email-Classifier) needed to be published first before building the digest that depends on its labeled output.
Conclusion:
In this n8n tutorial, we built a complete 4-node daily digest pipeline — Schedule Trigger → Gmail Get Many → Code batch merge → AI summarize → Telegram Send — that runs automatically every evening without any manual action. This is a solid real-world example of n8n workflow automation: it combines scheduling, API data fetching, AI processing, and messaging into a single active pipeline. Next up in the series, we move into Week 3 — connecting Google Sheets with AI to auto-log expenses, capture leads, and generate weekly KPI reports.
If you have any questions, feel free to leave a comment below. Thank you!
Tags: n8n telegram notification, n8n tutorial, n8n workflow automation, email digest automation, n8n gmail integration, telegram bot n8n, n8n schedule trigger, n8n AI summarization
Maybe you are interested!
- Getting Started with n8n: Interface & Your First Manual Trigger
- n8n HTTP Request Node: Connect Any API Without Code
- Branching Workflows: IF, Switch & Merge Nodes in n8n
- n8n Expressions & Built-in Variables: The Complete Guide
- Comparing AI Models in n8n: Claude vs Gemini vs ChatGPT
- Connect Gmail to n8n: OAuth Setup & Reading Emails
- Build an AI Email Classifier with n8n

