Guides5 min read

Telegram AI Bot Setup Guide

Set up your AI chatbot on Telegram. Complete guide to deploying OpenClaw or OpenClaw with Telegram integration on your VPS.

Published: 27/01/2025

Overview

Telegram is the perfect interface for your personal AI assistant. Instead of switching between apps, chat with your AI directly in Telegram - the same app you use for messaging friends and family. Your VPS handles all the AI processing while Telegram provides a familiar, always-available interface.

Why Telegram?

| Feature | Benefit | |---------|---------| | Universal | Works on every device | | Fast | Instant message delivery | | Audio Messages | Send voice, get voice back | | Rich Media | Images, files, formatting | | Notifications | Never miss a response | | Private | End-to-end encryption available | | No New App | Use what you already have |

Architecture

Your Phone (Telegram App)
    ↓
[Telegram Bot API]
    ↓
[Your VPS - OpenClaw]
    ↓
[AI Provider (Claude/GPT)]
    ↓
Response back via Telegram

Setup Guide

Step 1: Create Telegram Bot

  1. Open Telegram and search for @BotFather
  2. Send /newbot
  3. Choose a name: "My AI Assistant"
  4. Choose username: myai_assistant_bot (must end in bot)
  5. Save the API token provided
✅ Done! Your bot is ready.
Token: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz

Step 2: VPS Configuration

# Telegram Settings
TELEGRAM_ENABLED=true
TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrsTUVwxyz

# Restrict to your user ID only (security)
TELEGRAM_ALLOWED_USERS=your_telegram_user_id

# AI Provider
AI_PROVIDER=anthropic
ANTHROPIC_API_KEY=your-key
AI_MODEL=claude-3-5-sonnet-20241022

Step 3: Find Your Telegram User ID

  1. Search for @userinfobot on Telegram
  2. Send any message to it
  3. It will reply with your user ID
  4. Add this to TELEGRAM_ALLOWED_USERS

Step 4: Start the Bot

cd /opt/openclaw
pm2 restart openclaw

# Verify it's running
pm2 logs openclaw

Step 5: Test Connection

Open your bot in Telegram and send:

Hello! Can you tell me who you are?

Features

Text Conversations

Standard chat works immediately:

You: What's the capital of France? Bot: The capital of France is Paris.

Voice Messages

Send voice notes and get voice responses back:

# Enable voice features
VOICE_ENABLED=true
WHISPER_API_KEY=your-groq-or-openai-key
ELEVENLABS_API_KEY=your-key  # For voice responses

You: 🎤 "Hey, what's on my calendar today?" Bot: 🎤 "You have three meetings scheduled..."

Image Understanding

Send images for analysis:

You: [Photo of a receipt] Bot: "This receipt shows a purchase of £45.99 at Tesco on January 15th. Items include milk, bread, and coffee."

Rich Formatting

Telegram supports Markdown:

**Bold text**
*Italic text*
`Code snippets`
• Bullet lists

Personalization

Give Your Bot a Personality

SYSTEM_PROMPT="You are Navi, a helpful personal assistant. You're knowledgeable, friendly, and slightly playful. You remember user preferences and past conversations. Address the user by name when appropriate."

BOT_NAME=Navi

Custom Commands

Set up slash commands via BotFather:

  1. Message @BotFather
  2. Send /setcommands
  3. Select your bot
  4. Send command list:
start - Start conversation
help - Show available commands
status - Check system status
clear - Clear conversation context
settings - View current settings

Advanced Configuration

Conversation Memory

# Remember past conversations
MEMORY_ENABLED=true
MEMORY_RETENTION_DAYS=30
MAX_CONTEXT_MESSAGES=50

Daily Briefings

Get morning reports automatically:

# Morning briefing at 7 AM
DAILY_BRIEFING_ENABLED=true
DAILY_BRIEFING_TIME=07:00
DAILY_BRIEFING_TIMEZONE=Europe/London

Bot sends at 7 AM:

☀️ Good morning! Here's your briefing:

📅 Calendar: 3 meetings today
✅ Tasks: 5 due today
🌤️ Weather: 12°C, partly cloudy

Have a great day!

Multi-User Setup

For family or team use:

# Allow multiple users
TELEGRAM_ALLOWED_USERS=123456789,987654321,456789123

# Optional: Different personas per user
MULTI_USER_PROFILES=true

Security

Essential Settings

# Only respond to authorized users
TELEGRAM_ALLOWED_USERS=your_id_here

# Rate limiting
MAX_MESSAGES_PER_MINUTE=10

# Don't respond in groups (optional)
TELEGRAM_PRIVATE_ONLY=true

Webhook vs Polling

Polling (Default): Bot checks for messages periodically

TELEGRAM_MODE=polling
TELEGRAM_POLL_INTERVAL=1000

Webhook (Better for production): Telegram sends messages to your server

TELEGRAM_MODE=webhook
TELEGRAM_WEBHOOK_URL=https://yourdomain.com/telegram/webhook

Webhook requires HTTPS. Use with nginx:

location /telegram/webhook {
    proxy_pass http://localhost:3000;
}

Integration Examples

Connect to Your Services

Your Telegram bot can access anything your VPS can:

# Home Assistant
HOME_ASSISTANT_URL=http://homeassistant:8123
HOME_ASSISTANT_TOKEN=your-token

# Notion
NOTION_API_KEY=your-key

# Todoist
TODOIST_API_KEY=your-key

You: "Add 'Buy milk' to my shopping list" Bot: "Added 'Buy milk' to your Todoist shopping list ✓"

You: "Turn off the living room lights" Bot: "Done! Living room lights are now off."

File Handling

Send and receive files:

You: [PDF document] Bot: "I've read the document. It's a 12-page report about Q4 sales. Key highlights: Revenue up 15%, new customer acquisition increased 23%..."

Troubleshooting

Bot not responding

# Check bot status
pm2 status openclaw

# View logs
pm2 logs openclaw --lines 50

# Test Telegram API
curl https://api.telegram.org/bot<YOUR_TOKEN>/getMe

"Unauthorized" errors

  • Verify your user ID is in TELEGRAM_ALLOWED_USERS
  • Check token is correct
  • Ensure bot hasn't been banned

Slow responses

  • Check AI provider status
  • Verify VPS has adequate resources
  • Consider Claude Haiku for faster responses

Messages not delivering

  1. Check bot is running: pm2 status
  2. Verify webhook URL (if using webhooks)
  3. Check firewall allows Telegram IPs

Tips for Best Experience

Quick Actions

Set up keyboard shortcuts:

// In bot config
const quickReplies = [
  ['📋 Tasks', '🏠 Home', '📅 Calendar'],
  ['💡 Lights', '🎵 Music', '⚙️ Settings']
];

Pin Important Chats

Pin your bot conversation in Telegram for quick access.

Use Telegram Desktop

For longer conversations, use Telegram Desktop on your computer for easier typing.

Cost Comparison

VPS + Telegram vs Subscription Services

| Service | Monthly Cost | |---------|--------------| | ChatGPT Plus | £20/month | | Claude Pro | £18/month | | Your VPS Bot | ~£15-30/month total |

With your VPS bot:

  • Unlimited conversations
  • Multiple integrations
  • Full customization
  • No feature restrictions

Related Guides

Need Help?

Setting up Telegram integration is straightforward, but connecting all your services requires expertise. Our setup service includes full Telegram configuration with your preferred integrations.

Need a VPS for Your Bot?

We recommend Hostinger KVM 2 VPS - reliable, fast, and perfect for AI chatbots. Get started with our recommended setup.

Get Hostinger VPS

Need Help With Setup?

Got your VPS? Let us handle the technical work. Professional setup and maintenance for OpenClaw (formerly Clawd.bot).