1. Opening Problem Statement
Meet Claire Baker, a busy professional constantly flooded with emails in her Gmail inbox. Sorting through countless newsletters, notifications, and client emails, Claire struggles to keep up with timely responses. She wastes precious hours reading emails that don’t need replies and crafting answers to those that do. Sometimes she misses important client questions or delays answering because she can’t respond immediately when away from her desk.
This inefficiency costs Claire valuable time and hampers her communication effectiveness. Writing responses on the go is difficult without stopping to type out detailed messages. She wished there was a way to quickly reply using just her voice on her phone, yet still maintain professional, polished email communications.
This exact challenge sparked the creation of this specialized n8n workflow, designed to automate emailed reply drafting using smart AI analysis and Telegram voice responses.
2. What This Automation Does
This workflow fundamentally transforms how Claire manages her email responses by connecting Gmail, Telegram, and OpenAI AI services through n8n. Here’s what happens when it runs:
- Automatically monitors incoming Gmail emails in the INBOX folder.
- Uses OpenAI’s GPT model to determine if an email needs a response, filtering out newsletters, no-reply messages, and informational emails.
- Posts email details (sender, subject, snippet) to a Telegram chat via a bot, so Claire can review important emails remotely.
- Allows Claire to reply to any email by sending a voice message in Telegram as a reply to the email message.
- Retrieves the voice message audio from Telegram, sends it to OpenAI’s Whisper model for transcription into text.
- Uses OpenAI GPT again to polish the raw voice transcription into a professional email response.
- Creates an email draft in the original Gmail thread containing the polished reply.
- Sends back a Telegram message with a link to the created draft for easy preview and final edit or sending.
Claire can now save hours each week by replying hands-free to emails with voice commands and let AI craft professional responses, eliminating the friction of manual typing and missed follow-ups.
3. Prerequisites ⚙️
- Gmail account with OAuth2 access enabled for n8n (to trigger on new emails and create drafts).
- Telegram account to set up a bot and receive/send messages (Telegram Bot API credentials required).
- OpenAI account with API access for GPT chat models and Whisper audio transcription.
- n8n account (cloud or self-hosted) to deploy and run the automation.
You can optionally self-host n8n for full control and privacy. For affordable hosting, check platforms like Hostinger.
4. Step-by-Step Guide to Building This Workflow
Step 1: Trigger on New Gmail Emails
Within n8n, add the Gmail Trigger node:
- Navigate: Click + Add Node → Search Gmail Trigger → Select it.
- Configure to watch for emails arriving in your inbox with the setting
simple: falseto access full email data. - Set polling to every minute to catch emails promptly.
- Authenticate with your Gmail OAuth2 credentials.
After this step, the workflow listens continuously and activates whenever new mail arrives.
Common mistake: Forgetting to set the trigger to the INBOX label, leading to catching sent or archived mails instead.
Step 2: Filter Emails in Inbox Only
Add an If node named In the Inbox?:
- Set condition to check if the incoming email’s label IDs contain
INBOX. - This ensures the automation only processes new incoming mail, skipping sent or other folders.
Connecting this ensures no unintentional processing.
Step 3: Determine If Email Needs a Response using OpenAI GPT
Add the OpenAI Chat Model node:
- Use GPT-3.5 or GPT-4 model to analyze email content.
- Input a prompt configured as:
Do you think the following email requires me to create a response or not? Your answer should be Y if yes, or N if not. Format your answer as JSON { response: Y } or { response: N } ... - This prompt includes criteria like ignoring no-reply addresses, newsletters, and only responding to direct queries or personal emails.
- Link the output through the Structured Output Parser node to format the response properly.
This is the core AI decision making gate.
Common mistake: Not using an output parser causes difficulty in branching logic based on AI response.
Step 4: Branch Logic – Only Proceed If Response Needed
Add another If node called Needs a response?:
- Checks if AI response JSON value is “Y”.
- Allows only emails requiring a reply to continue.
Step 5: Send Email Details to Telegram
Add the Set node to set a fixed chat ID (your Telegram chat ID):
- Set
chat_idto your Telegram user or group chat ID where you want email alerts.
Add a Telegram Node configured to send text messages:
- Compose the message including email metadata like ID, thread ID, sender name, email address, subject, and a snippet of the email body.
- Escape special Markdown characters to avoid formatting issues.
- Send to your specified chat ID.
This helps you receive email data instantly on your phone via Telegram.
Step 6: Trigger on Telegram Bot Reply Message
Add a Telegram Trigger node:
- Configure to listen for messages (type: message).
- This will catch your replies to the bot messages.
- Authenticate with your Telegram Bot API credentials.
Step 7: Check If Telegram Reply Is an Audio Message
Add an If node labeled Is Type Audio Message + Reply?:
- Validate that the Telegram message is a reply to a previous bot message
message.reply_to_messageexists. - Validate message has voice audio content
message.voice. - If these conditions fail, send an explanatory message back requesting a voice reply using the Telegram Node with a text response.
Step 8: Download Audio File from Telegram
Add a Telegram Node configured to fetch files using the file_id from the voice message sent.
This downloads the audio voice note to be further processed.
Step 9: Transcribe Audio Using OpenAI Whisper
Add the OpenAI Node configured for audio transcription:
- Upload the downloaded audio file to the OpenAI Whisper endpoint.
- The node outputs the transcribed text for the voice note.
Step 10: Generate Polished Email Reply with OpenAI GPT
Add the Chain LLM Node with OpenAI Chat Model configured:
- Input prompt includes the original email text and the transcribed voice reply.
- Instruction tells the model to produce a polished reply email reflecting the voice note’s intent and tone, without adding new information.
This step ensures your spoken words become a professional email response.
Step 11: Create Draft Email in Gmail
Add the Gmail Node configured to create a draft message:
- Set “sendTo” to the original email address extracted from the Telegram message data using regex.
- Set “threadId” to maintain the email thread continuity.
- Subject line prefixed with “RE:” and taken from the original email.
- The message body is the polished reply from the previous step.
This puts the reply in your Gmail drafts for later review and sending.
Step 12: Notify User with Draft Link in Telegram
Add a final Telegram Node to send a confirmation message back:
- Message includes the polished response text and a hyperlink to the Gmail draft thread.
- Replies directly to your Telegram voice message for easy context.
Now you can quickly preview and send the AI-drafted email without leaving Telegram.
5. Customizations ✏️
- Change Telegram Chat ID: In the Set Chat ID node, update
chat_idto your personal or group Telegram chat ID to control where email alerts appear. - Adjust AI Response Criteria: Modify the prompt in the Does Email Need a Response? node to tailor which emails the AI considers worthy of replies, such as including/excluding certain senders or keywords.
- Limit Telegram Snippet Length: Adjust message formatting in the Text Email node to control how much email body text is included in Telegram alerts, keeping messages concise.
- Change Draft Sending Behavior: In the Create Email Draft Gmail node, switch from creating drafts to automatically sending emails by changing resource operation if you want full automation.
- Customize Polished Reply Style: Update prompt instructions in the Write Polished Reply node to adjust tone, formality, or length of the generated email responses.
6. Troubleshooting 🔧
Problem: “The AI did not return a valid JSON response.”
Cause: The OpenAI Chat model prompt output is not strictly formatted as expected JSON.
Solution: Ensure you use the Structured Output Parser node immediately after the GPT chat node to cleanly parse the response and enforce JSON format compliance.
Problem: “Telegram message trigger fires but no reply branch works.”
Cause: Telegram message is missing the voice message or is not a reply to the bot’s earlier message.
Solution: Check the Is Type Audio Message + Reply? node’s condition logic to confirm both the reply and voice audio fields exist. Test by sending an actual voice reply directly to a Telegram bot message.
7. Pre-Production Checklist ✅
- Verify Gmail OAuth2 credentials are valid and have read/write draft permissions.
- Confirm Telegram bot token and chat IDs are correctly configured.
- Test OpenAI API keys for both chat and audio transcription endpoints to prevent quota or permission errors.
- Simulate receiving an email and see if it appears in your Telegram chat.
- Test sending a Telegram voice reply to the bot message and check draft creation in Gmail.
- Backup your n8n workflow configuration before major changes.
8. Deployment Guide
To deploy your workflow:
- Activate the workflow by toggling it ON in your n8n editor after all nodes are configured.
- Ensure the Gmail trigger is running, and your Telegram bot is online.
- Monitor execution logs in n8n for failures or unexpected issues after deployment.
- Adjust node parameters and test edge cases like non-reply emails, incorrect voice messages, or multiple simultaneous emails.
9. FAQs
Can I use another email provider instead of Gmail?
Currently, this workflow is tailored to Gmail using its official trigger and draft APIs. Other providers would require custom trigger and email send nodes.
Does this consume many OpenAI API credits?
Audio transcription and GPT chat calls do use API credits, but by filtering to only reply-necessary emails, usage is optimized.
Is my data secure?
All communication is secured by OAuth2 and API encryption. Hosting n8n yourself further enhances privacy controls.
10. Conclusion
In this tutorial, you transformed chaotic email management into an efficient, voice-powered interaction using n8n automation. By linking Gmail, Telegram, and OpenAI, you created a seamless flow where incoming emails are intelligently filtered for replies, and voice replies generate smart, polished draft emails automatically.
You’ve saved potentially hours each week and reduced the risk of missed or delayed responses. This system allows you to maintain professional communication on the go, all from your Telegram app.
Next, consider these ideas:
- Integrate calendar scheduling for meeting invites detected in emails.
- Add sentiment analysis to prioritize urgent replies.
- Expand to support SMS or WhatsApp for voice replies.
Start building this unique email automation now and reclaim your time with smarter workflows!