Talk to Your AI from Anywhere
What this gives you: A Telegram group where you message different topics and the right AI agent responds. LinkedIn questions go to your LinkedIn agent. Revenue questions go to your accountant. All from your phone.
Your AI assistant should follow you everywhere. Not sit on a laptop waiting. This guide connects Jarvis to Telegram so you can fire off instructions from your phone, get responses in seconds, and have the right specialist handle each topic automatically.
Why Telegram
Most people reach for WhatsApp or iMessage when they think about messaging. But Telegram has one feature that makes it the right choice for AI assistants: Topics.
Topics let you create thread channels inside a single group. One group, multiple topic threads, each acting like a separate chat. This maps perfectly to a multi-agent setup. Your LinkedIn agent lives in the LinkedIn topic. Your accountant lives in the Accountant topic. Messages automatically route to the right agent based on which topic you post in.
Beyond that: Telegram is free, has a rock-solid Bot API, supports voice messages, works on every platform, and has no message size limits that matter. The API is simple, well-documented, and has excellent TypeScript libraries.
Step 1: Create Your Telegram Bot
Every Telegram bot starts with BotFather. This is Telegram's official bot creation tool.
- Open Telegram and search for @BotFather (the verified one with a blue tick)
- Send the command
/newbot - When prompted, give your bot a display name - something like Jarvis AI
- When prompted for a username, it must end in
bot- for examplejarvis_rahul_bot - BotFather will reply with your bot token. It looks like:
7812345678:AAGxyz...
.env file immediately, never in code.Add the token to your environment file:
Test that the token works by hitting the Telegram API directly:
You should get back a JSON response with your bot's name and username. If you see "ok":true, the token is valid and the bot is live.
Step 2: Create a Group with Topics
The bot needs a home. That home is a Telegram group with Topics enabled.
- In Telegram, tap the pencil icon to start a new chat, then select New Group
- Add at least one other contact to create the group (you can remove them later)
- Give the group a name - something like Jarvis HQ
- Once inside the group, tap the group name at the top to open settings
- Tap the edit (pencil) icon, then scroll to find Topics and enable it
- Now add your bot as a member: tap the group name again, then Add Members, search for your bot's username
- Make the bot an admin: tap the bot in the member list, then Promote to Admin. Enable Post Messages and Manage Topics at minimum
Now create your topic threads. Tap the group name, then the Topics section, and create each of these:
| Topic Name | Purpose |
|---|---|
| General | Catch-all, admin tasks, anything unclassified |
| Posts, comments, connection messages | |
| YouTube | Scripts, titles, thumbnails, analytics |
| Newsletter | Email content, subject lines, sequences |
| Accountant | Revenue, expenses, invoices, Stripe data |
| Strategy | Planning, decisions, research, quarterly goals |
Step 3: Get Your Chat ID
To send messages back to your group, the bot needs the group's chat ID. Here is how to find it.
First, send any message in your Telegram group. Then run this curl command with your bot token:
Look through the JSON response for the chat object. The id field inside it is your chat ID. Group IDs are negative numbers, like -1001234567890.
Note the message_thread_id for each topic. Send a message in each topic thread and run getUpdates again to collect all the IDs. You will need these for the router in Step 6.
Step 4: Install Grammy
Grammy is the TypeScript framework for building Telegram bots. It handles the connection to Telegram's API, message parsing, and sending replies. Clean, well-maintained, and works perfectly with Bun.
Create the entry point for your bot:
Step 5: Map Your Topic Thread IDs
Before writing the router, you need to collect the thread ID for every topic. Send a test message in each topic, run getUpdates, and record the message_thread_id values.
message_thread_id: 1 or appears without a thread ID. Test this by sending a message in General and checking getUpdates to confirm.Step 6: Route Messages by Topic
The router is the core of the gateway. It listens for every message in the group, checks which topic thread it came from, and calls the matching agent.
Step 7: Connect to Claude
The agent runner spawns a claude -p process with the right system prompt for each agent. Each agent's system prompt lives in its own markdown file.
Create the agent prompt files. Here is a minimal example to get you started:
Step 8: Deploy with pm2
pm2 keeps your bot running permanently. If it crashes, pm2 restarts it automatically. If the VPS reboots, pm2 brings everything back up.
Common pm2 commands you will use daily:
pm2 logs in one terminal while you test the bot in another. You will see exactly what the bot receives and what Claude returns, which makes debugging straightforward.Voice Messages
Typing on mobile is slow. Voice messages let you speak instructions and have them transcribed and passed to the right agent. Grammy receives the voice file, you transcribe it with OpenAI Whisper, then pass the text through the same routing pipeline.
Add the OpenAI key to your environment file:
Testing
Work through each topic in order. For each one, send a simple test message and confirm the bot replies in the same topic thread.
| Topic | Test message | Expected response |
|---|---|---|
| "Write me a one-line hook about AI for service businesses" | A single sharp hook line | |
| YouTube | "Give me 3 title ideas for a video about Telegram bots" | 3 formatted title ideas |
| Accountant | "What should I track for MRR?" | A list of MRR metrics |
| Strategy | "What is the 80/20 for a solo agency owner?" | A focused strategic answer |
Common Issues
Bot does not reply at all
- Check
pm2 status- is the gateway running? - Run
pm2 logs jarvis-gatewayand look for connection errors - Verify
TELEGRAM_BOT_TOKENis set correctly in your environment
Bot replies but in the wrong topic
- Your
TOPIC_ROUTESmapping probably has incorrect thread IDs - Send a message in each topic, run
getUpdates, and re-check themessage_thread_idvalues
Bot is not admin - messages are received but cannot reply
- Go to group settings, tap the bot in the member list, and promote to admin
- Enable at minimum: Post Messages and Manage Topics
Topics not showing up in the group
- The group must be a supergroup for Topics to work. Telegram upgrades it automatically when Topics is enabled, but sometimes this takes a moment
- Leave and rejoin the group if topics still do not appear
Claude command not found
- Run
which claudeon your VPS to confirm Claude Code is installed - If not, follow the VPS Setup guide first and install Claude Code on the server