Build Log: Telegram AI Agent Bot Powered by Hermes Agent
TL;DR: We built a Telegram bot powered by Hermes Agent that answers technical questions, summarizes links, and runs scheduled research tasks. Deployed on a $12/month VPS with an 8B local model. Average response time: 2.3 seconds. 100% uptime over 14 days. Total infrastructure cost: $12.50.
The Problem
Our team uses Telegram as the primary communication channel. When someone asks "what's the latest on Hermes Agent v0.12?" or "can you summarize that GitHub issue?", the answer requires searching documentation, reading threads, and synthesizing information โ exactly the kind of task an AI agent should handle but a human shouldn't waste time on.
Build Log Review 2026
Existing Telegram bots could only handle predefined commands or single-prompt responses. We needed something that could maintain conversation context, use tools (web search, file reading, code execution), and learn from repeated tasks over time. Hermes Agent's self-improvement loop made it the ideal foundation.
What We Built
A Telegram-native AI agent bot with three capabilities:
- Conversational Q&A: Ask technical questions, get answers grounded in documentation and web search results
- Link summarization: Share a URL, the agent reads the page and posts a summary to the group
- Scheduled research: A cron job that scans Hacker News and GitHub trending each morning and posts a briefing
Architecture
| Component | Technology | Purpose |
|---|---|---|
| Agent framework | Hermes Agent v0.12 | Orchestration, memory, skill learning |
| LLM | Llama 3.1 8B (via Ollama) | Local reasoning โ no API costs |
| Messaging | Telegram Bot API (python-telegram-bot) | User interface |
| Hosting | DigitalOcean VPS (2 vCPU, 4GB RAM) | Always-on runtime |
| Storage | SQLite (Hermes built-in) | Memory persistence |
| Web search | DuckDuckGo API (free) | Real-time information retrieval |
Implementation
Step 1: Telegram Bot Setup
Registered the bot with BotFather and configured Hermes Agent's Telegram integration:
class="language-yaml"># ~/.hermes/config.yaml
messaging:
telegram:
enabled: true
bot_token: "${TELEGRAM_BOT_TOKEN}"
allowed_users:
- "your_telegram_id"
- "team_member_id"
Step 2: VPS Deployment
We used a $12/month DigitalOcean droplet running Ubuntu 24.04. Hermes Agent was installed and configured as a systemd service with auto-restart:
class="language-bash"># Deploy script ssh root@droplet-ip curl -fsSL https://hermes-agent.sh/install.sh | bash hermes init hermes config set inference_provider ollama hermes config set ollama_model llama3.1:8b ollama pull llama3.1:8bConfigure systemd for auto-restart
cat > /etc/systemd/system/hermes.service << โEOFโ [Unit] Description=Hermes Agent After=network.target
[Service] Type=simple User=hermes ExecStart=/home/hermes/.hermes/venv/bin/hermes run Restart=always RestartSec=10
[Install] WantedBy=multi-user.target EOF
systemctl enable hermes systemctl start hermes
Step 3: Cron Research Briefing
Added a daily research task that runs automatically:
class="language-bash">hermes cron add --schedule "0 7 * * 1-5" \
--task "Scan Hacker News front page and GitHub trending/ai. \
Find top 3 AI agent stories. Summarize each in 2-3 sentences. \
Post the briefing to #research channel."
Results
| Metric | Value |
|---|---|
| Total uptime | 14 days (336 hours) |
| Uptime percentage | 100% |
| Average response time | 2.3 seconds |
| Median response time | 1.8 seconds |
| Slowest response | 8.7 seconds (complex web search + synthesis) |
| Total conversations | 247 |
| Total messages processed | 1,843 |
| Skills auto-created | 3 (link summary, tech briefing, code lookup) |
| Infrastructure cost | $12.50 (VPS + domain) |
| API costs | $0.00 (fully local inference) |
Response Time Breakdown
| Request Type | Avg Time | 95th Percentile |
|---|---|---|
| Simple Q&A (no tools) | 1.2s | 2.1s |
| Link summarization | 3.4s | 5.8s |
| Web search + synthesis | 5.1s | 8.7s |
| Cron briefing (automated) | 45s | 72s |
Lessons Learned
- An 8B model is sufficient for technical Q&A. Llama 3.1 8B handles documentation queries, link summaries, and code explanations without noticeable quality gaps compared to larger models. For complex reasoning (architecture decisions, multi-step planning), a larger model or API-based inference would help โ but for the daily use cases, the local 8B model works well.
- Skills auto-creation is the killer feature. Within the first week, Hermes created three skills from repeated patterns. The "link summary" skill now runs in 3.4s average compared to 5.2s on the first manual requests โ a 35% improvement from iteration alone.
- Telegram messaging latency is negligible. The bottleneck is model inference and web search, not the messaging layer. Telegram API round-trips add about 50-100ms.
- VPS memory is the constraint, not CPU. At 4GB RAM, the 8B model uses ~5.2GB with system overhead, forcing swap usage. Upgrading to an 8GB VPS ($24/month) would eliminate swap entirely and likely reduce response times by 20-30%.
- Allowlists prevent abuse. Configuring
TELEGRAM_ALLOWED_USERSin environment variables prevented unauthorized access attempts (logged 12 failed authentication attempts in 14 days). Without this, any Telegram user who finds the bot can query the agent โ including sending it destructive commands. - Cron safety rules work. Hermes enforces that cron-initiated sessions cannot create new cron jobs. This prevented a runaway loop when the morning briefing agent tried to schedule its own recurrence. The built-in guardrail caught it.
Cost Analysis
Total 14-day cost: $12.50. Breakdown:
- $12.00 โ DigitalOcean VPS (2 vCPU, 4GB RAM, 40GB SSD)
- $0.50 โ Domain DNS (prorated)
- $0.00 โ Ollama inference (local, no API calls)
- $0.00 โ DuckDuckGo search (free tier)
- $0.00 โ Telegram API (free)
Compared to using GPT-4o via API for the same volume (~1,843 messages ร ~500 avg tokens = ~922K tokens at $2.50/1M input tokens), the API cost alone would be roughly $2.30 โ cheap per-message but adds up. More importantly, the local model keeps all conversation data on the VPS, never sending team discussions to a third-party API.
Future Improvements
- Upgrade to 8GB RAM VPS for swap-free inference (est. 20-30% faster responses)
- Add RAG pipeline with project documentation for more accurate technical answers
- Implement credential pools for automatic API key rotation on the web search tool
- Set up log forwarding to a centralized monitoring dashboard
Built a Telegram AI agent? Share your setup in the comments or tag us on X. For setup details, see our Hermes production deployment guide and automation workflows guide.
Tags: Builds, Case Studies, AI, Open Source, Productivity
Tool: Hermes Agent / Ollama / Telegram / DigitalOcean
โ Back to all posts