Back to Resources
Tutorial

Building a master agent for Telegram with n8n

January 14, 202510 min read

The vision: one assistant to rule them all

What if you could have a single AI assistant that handles your entire digital life through Telegram? That's exactly what I built with n8n: a Master Agent that orchestrates 10+ specialized sub-agents, each expert in their domain.

The architecture

The system follows a hub-and-spoke model:

Master Agent: The central coordinator powered by Claude Haiku 4.5
Specialized Agents: Gmail, Google Calendar, Google Contacts, Spotify, Google Drive, Weather, Tasks, and more
Memory Layer: Postgres-based chat memory via Supabase for context retention
Voice Support: Full voice-to-text and text-to-voice capabilities

How it works

1.Input Processing: The Telegram trigger captures both text and voice messages
2.Voice Transcription: Voice notes are transcribed via OpenAI Whisper, then cleaned up by Claude
3.Agent Routing: The Master Agent analyzes the request and delegates to the appropriate sub-agent
4.Response Delivery: Results are sent back as text or synthesized speech

The sub-agents

Each sub-agent is a separate n8n workflow with its own specialized tools:

Gmail Agent: Send, read, label, reply to emails
Google Calendar Agent: Create, update, check events and availability
Google Contacts Agent: Find contact info, resolve aliases ("my wife", "cousin")
Spotify Agent: Control playback, search tracks, manage playlists
Google Drive Agent: Search and manage files
Weather Agent: Current conditions and 10-day forecasts
Data Analyst Agent: Query and analyze Google Sheets data
Google Tasks Agent: Manage to-do lists

Key design decisions

Session Management: Each conversation gets a unique session ID stored in n8n's Data Table. After 10 minutes of inactivity, a new session starts to keep context fresh.

Natural Language: The system prompt instructs the agent to respond conversationally, never exposing technical details or JSON traces.

Time Awareness: The current date/time is injected into every prompt, enabling accurate handling of relative dates ("tomorrow", "next week").

Graceful Failures: When an agent can't find information, it says so directly without suggesting alternatives.

The results

This Master Agent has become my daily companion:

Check calendar while walking
Send voice-dictated emails
Control Spotify hands-free
Get weather updates before trips
Manage tasks on the go

All through a single Telegram conversation.

Want to build your own?

The beauty of n8n is that you can start simple and add agents incrementally. Begin with one or two integrations, nail the UX, then expand. The Master Agent pattern scales beautifully—just add new sub-agents as workflow tools.

Ready to automate your workflows?

Let's discuss how we can help you build scalable revenue workflows.