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!