Build AI-Powered Telegram Assistant with n8n & OpenAI

This n8n workflow automates handling Telegram messages by converting voice to text, fetching calendar events, emails, and tasks, then replying with AI-generated summaries. It saves time managing communication by integrating Gmail, Google Calendar, and Baserow databases with OpenAI’s GPT-4 mini model.
telegramTrigger
agent
gmailTool
+10
Workflow Identifier: 1002
NODES in Use: telegramTrigger, set, if, telegram, telegram, getVoiceFile, openAi, agent, lmChatOpenAi, memoryBufferWindow, gmailTool, googleCalendarTool, baserowTool

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Derek, a busy professional who manages multiple communication channels daily. Between voice messages, emails, calendar events, and task updates, Derek often feels overwhelmed, spending hours sifting through information to stay organized. Specifically, Derek wants an intelligent assistant that can understand his Telegram voice or text messages and reply with consolidated, relevant information from his calendar, emails, and task databases. Without automation, this manual juggling costs him at least 2 hours every day and increases the likelihood of missing important updates.

2. What This Automation Does

This unique n8n workflow creates an AI-powered Telegram assistant named “Angie” that listens for messages, understands them (voice or text), and responds with intelligent insights. Here’s exactly what happens:

  • Detects incoming Telegram messages, whether voice or text.
  • Converts voice messages to text using OpenAI’s audio transcription.
  • Fetches unread Gmail emails received after a specified date to find relevant messages.
  • Retrieves Google Calendar events filtered by date context from the user’s calendar.
  • Queries Baserow tables for tasks and contacts related to the conversation.
  • Uses OpenAI GPT-4 mini via a custom LangChain agent to interpret the request, summarize information, and formulate a smart reply.
  • Sends the AI-generated response back to the Telegram user seamlessly.

The benefits? Derek saves hours of manual research every day, avoids missing crucial info, and interacts with all his important data directly through Telegram — hands-free and hassle-free.

3. Prerequisites ⚙️

  • n8n account with access to create workflows.
  • Telegram account with bot setup and API credentials.
  • Google Calendar OAuth2 credentials linked to your calendar.
  • Gmail OAuth2 credentials to access your email inbox.
  • Baserow account with API key and existing databases for tasks and contacts.
  • OpenAI API key with permission to use GPT-4 mini and audio transcription.

Optional: For those wanting full control, consider self-hosting n8n for enhanced privacy and customization options.

4. Step-by-Step Guide

Step 1: Set Up Telegram Trigger

Go to your n8n editor, click “Add New Node” → Select Telegram Trigger. Configure it to listen for “message” updates, and link your Telegram bot credentials. This node will capture incoming voice or text messages from users like Derek.

Visual: You should see webhook URL ready for Telegram to call on new messages.

Step 2: Identify Message Type

Add an If node next and connect from Telegram Trigger. Configure the condition to check if {{$json.message.text}} is empty. If empty, the message is a voice note; if not, it’s text.

Outcome: routing messages for proper processing.

Step 3: Extract Text from Voice

Add Get Voice File node connected to the If node’s “true” branch. Set this node to fetch the file ID from Telegram message voice data.

Then, link a Speech to Text OpenAI node to transcribe the audio file to text using OpenAI’s audio transcription API.

This step transforms voice messages into readable text for AI processing.

Step 4: Pass Text for AI Understanding

Use a Set node named “Voice or Text” to ensure the text comes either directly from Telegram or from the transcription process. Map text fields accordingly.

Step 5: Memory Context with Window Buffer

Add a Window Buffer Memory node to maintain conversational context per user session, keyed by Telegram user ID. This keeps conversations coherent over multiple messages.

Step 6: Integrate Google Services

To enrich replies, configure Get Email node to pull unread Gmail messages from the inbox received after the requested date. Similarly, add Google Calendar node to fetch calendar events after the same date.

Step 7: Fetch Tasks and Contacts from Baserow

Add Tasks and Contacts nodes using Baserow tool to query your databases by their table and database IDs. These will provide relevant task and contact data to the AI.

Step 8: Configure AI Assistant Node

Setup the LangChain Agent node “Angie, AI Assistant 👩🏻‍🏫” to:

  • Receive the consolidated text input.
  • Use GPT-4 mini model for natural language understanding.
  • Apply guidelines in the system message to filter emails, summarize, and only report relevant calendar events and tasks.

This node generates the smart, personalized reply.

Step 9: Reply via Telegram

Add the Telegram node connected to the AI Assistant. Configure it to send the AI-generated reply text back to the user’s Telegram chat ID, with Markdown formatting enabled.

5. Customizations ✏️

  • Change Date Filters: In both Google Calendar and Get Email nodes, update the date filter parameter to broaden or narrow the timeframe of fetched information.
  • Adjust AI Assistant Response Style: Modify the “systemMessage” in the LangChain Agent node to make responses more formal, casual, or concise.
  • Add More Data Sources: Incorporate other APIs or tools by adding new nodes, such as Slack messages or CRM data, feeding info to Angie.
  • Enable Multi-Language Support: Use OpenAI’s language translation before sending text to AI to handle requests in foreign languages.

6. Troubleshooting 🔧

Problem: “No webhook response from Telegram trigger.”
Cause: Telegram bot webhook URL not set correctly or n8n workflow not active.
Solution: Confirm Telegram bot webhook points to n8n URL, activate and save the workflow, and check network firewall.

Problem: “Emails not fetched despite correct credentials.”
Cause: Date filter parsing issue or incorrect Gmail label/permissions.
Solution: Verify the “receivedAfter” date format matches ISO8601 standard, and permissions include read access to inbox.

7. Pre-Production Checklist ✅

  • Test Telegram trigger manually by sending voice and text messages to your bot.
  • Validate OpenAI transcription and chat credentials under n8n credentials manager.
  • Verify Google Calendar and Gmail access by testing Get Email and Calendar nodes separately.
  • Confirm Baserow API connections with sample data pulls.
  • Run full end-to-end test sending a Telegram voice message and receiving a reply.

8. Deployment Guide

Once tested, activate your n8n workflow by toggling it to “Active.” Ensure your n8n instance is accessible online for webhook responses. Monitor the execution via n8n’s built-in workflow execution logs to catch any errors. Consider alerts for failure notifications based on node responses.

9. FAQs

Q: Can I use other email providers instead of Gmail?
A: This workflow uses Gmail node for its OAuth2 integration and label filters; to use other services, you’d need to replace that node with a compatible one supporting your email provider.

Q: Does OpenAI transcription consume extra tokens?
A: Yes, transcription uses OpenAI’s audio endpoint, which may incur additional API usage and costs based on your account plan.

Q: Is my data secure?
A: All credentials are securely stored within n8n environment variables, and communication with APIs uses OAuth2 tokens. For additional privacy, consider self-hosting your n8n instance.

10. Conclusion

By following this workflow, you have created an AI-powered Telegram assistant that listens to your voice or text requests, fetches relevant emails, calendar events, and task info, then replies intelligently via Telegram. This automation can save you 1-2 hours daily managing communication and ensures you stay updated without scrambling.

Next steps? Expand Angie’s capabilities by integrating more apps like Slack or CRM systems, add language translation for international support, or include proactive reminders from your task database.

Happy automating!

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free