# Product recipe: Telegram bot with AI (AgentGid)

For a Telegram bot that chats with a model, remembers users, and runs around the clock.

Parts were picked from AgentGid's catalog by rules: free tier, official MCP server, use in public projects built with AI agents, downloads, price. Prices are list prices from the official pages (see each card for the check date); confirm before you commit.

## What it costs
- Start: $0 a month on the free tiers of the first picks (their limits apply).
- If you outgrow the free tiers, the lowest paid plans of the first picks are Supermemory $19, Vercel $20, LangSmith $39 (together about $78/month); usage beyond a plan's credits is billed on top.
- Billed by usage (grows with traffic): Telegram Bot API, OpenRouter, Neon.
- Model, default: fast and cheap: about $0.35 per 1,000 messages with Claude Haiku 5.5 (AgentGid estimate at ~2,000 input + 300 output tokens each).
- Model, harder questions: about $2.62 per 1,000 messages with Gemini 3.8 Flash (AgentGid estimate at ~2,000 input + 300 output tokens each).
- Prices of the picks below were checked on the official pages between 2026-10-09 and 2026-10-22.

## How it fits together
1. Create the bot with @BotFather and keep its token on the server.
2. Receive updates by webhook (serverless hosting works) or long polling (needs an always-on worker).
3. Key memory and history by the Telegram user id; send recent context to the model through the gateway.
4. Rate-limit per user and cap spending at the gateway.

## Telegram Bot API
- Telegram Bot API: free: Bots are able to message their users at no cost (about 30 messages per second broadcast limit) · usage: Paid broadcasts: 0.1 Stars per message over the free 30 per second (up to 1000 messages per second) · card https://agentgid.com/apis/telegram-bot-api/agent.md

## LLM gateway (one key, many models)
- OpenRouter: free: 25+ free models, 50 requests/day · usage: Provider list price per token (no markup); fee on credit purchases: 5.5% Standard, 8% Business · official MCP https://mcp.openrouter.ai/mcp · npm @openrouter/sdk · pip openrouter · card https://agentgid.com/apis/openrouter/agent.md
- LiteLLM: free: Open-source gateway free to self-host · pip litellm · card https://agentgid.com/apis/litellm/agent.md
- Also fits: Vercel AI Gateway, Cloudflare AI Gateway, Portkey, Helicone (https://agentgid.com/apis/llm-gateway/)

## Memory for the bot
- Supermemory: free: $5 of credits/month · paid from $19/mo · usage: Memory $5 per 1M SM tokens (plain text), $10 (rich); SuperRAG $1-$2 per 1M tokens; search $5 per 1M queries · official MCP https://mcp.supermemory.ai/mcp · npm supermemory · pip supermemory · card https://agentgid.com/apis/supermemory/agent.md
- Mem0: free: Hobby: 10,000 add requests and 1,000 retrieval requests/month · paid from $19/mo · usage: Starter $19/month: 50,000 adds + 5,000 retrievals; Pro $249/month: 500,000 adds + 50,000 retrievals · official MCP https://mcp.mem0.ai/mcp · npm mem0ai · pip mem0ai · card https://agentgid.com/apis/mem0/agent.md
- Also fits: Letta, Zep (https://agentgid.com/apis/memory/)

## Database
- Neon: free: 1 GB storage, 100 CU-hours compute/month per project, 100 projects, 5 GB Object Storage, 1M function invocations · usage: $0.106 per CU-hr (Launch), $0.222 per CU-hr (Scale); $0.35 per GB-month storage; $0.023 per GB-month Object Storage; $0.60 per 1M invocations · official MCP · npm @neondatabase/serverless · card https://agentgid.com/apis/neon/agent.md
- Upstash Redis: free: 250 MB data, 500K commands/month · paid from $10/mo · usage: $0.20 per 100K commands, $0.25 per GB storage (after 1GB free), $0.03 per GB bandwidth (after 200GB free) · npm @upstash/redis · card https://agentgid.com/apis/upstash/agent.md
- Also fits: Redis, Convex, Firebase, Appwrite (https://agentgid.com/apis/backend-db/)

## Hosting (webhook or always-on worker)
- Vercel: free: Hobby: $0/month · paid from $20/mo · official MCP https://mcp.vercel.com · npm vercel · card https://agentgid.com/apis/vercel/agent.md
- Azure Functions: free: Flex Consumption: 250,000 executions and 100,000 GB-s per month (Consumption plan: 1 million executions and 400,000 GB-s) · usage: Flex Consumption on-demand (East US): $0.000026 per GB-s, $0.40 per million executions; Consumption plan: $0.000016 per GB-s, $0.20 per million executions · official MCP @azure/mcp · npm @azure/functions · pip azure-functions · card https://agentgid.com/apis/azure-functions/agent.md · MCP server card https://agentgid.com/mcp/servers/com-microsoft-azure/agent.md
- Also fits: DigitalOcean App Platform, Netlify, Heroku, Cloudflare Workers (https://agentgid.com/apis/hosting/)

## Traces and evals
- LangSmith: free: Developer plan: 1 seat, up to 5k base traces / mo, then pay-as-you-go · paid from $39/mo · usage: Plus: $39 / seat per month incl. up to 10k base traces / mo; trace overage is pay-as-you-go (rate not listed on pricing page); 1 LSU = $1 (Deployment/Fleet/Sandbox usage) · official MCP https://docs.langchain.com/langsmith/langsmith-mcp-server · npm langsmith · pip langsmith · card https://agentgid.com/apis/langsmith/agent.md
- Also fits: LangWatch, W&B Weave, Ragas, Pydantic Logfire (https://agentgid.com/apis/observability/)

## Model (all of these can call tools; prices per 1M tokens)
- Default: fast and cheap: Claude Haiku 5.5 ($0.1 in / $0.5 out) · https://agentgid.com/models/claude-haiku-5-5/agent.md · or GPT-6 Luna, MiMo V2.6 Flash
- Harder questions: Gemini 3.8 Flash ($0.75 in / $3.75 out) · https://agentgid.com/models/gemini-3-8-flash/agent.md · or Kimi K2.7 Code, DeepSeek V4 Pro
- Hardest work: Kimi K3 ($3 in / $15 out) · https://agentgid.com/models/kimi-k3/agent.md · or Claude Opus 5.5, Claude Fable 5.1

## Libraries
- `pip install aiogram`: aiogram (MIT) · https://agentgid.com/tools/aiogram/agent.md
- `pip install python-telegram-bot`: python-telegram-bot (LGPL-3.0-only) · https://agentgid.com/tools/python-telegram-bot/agent.md
- `npm install grammy`: grammY (MIT) · https://agentgid.com/tools/grammy/agent.md
- `npm install telegraf`: Telegraf (MIT) · https://agentgid.com/tools/telegraf/agent.md

## Coding agent to build it
- OpenAI Codex: free tier, from $8/mo · https://agentgid.com/agents/openai-codex/agent.md
- Claude Code: from $20/mo · https://agentgid.com/agents/claude-code/agent.md
- OpenCode: free tier, from $10/mo · https://agentgid.com/agents/opencode/agent.md

## Also on AgentGid
- Telegram news bot kit: https://agentgid.com/build/kits/news-bot/

## Before you ship
- Keep API keys on the server, never in the client; set spending limits where the provider offers them.
- Read each service's terms for your use (data retention, commercial use, rate limits).
- Log model calls (traces) and test with your own real inputs before launch.

Recipe page: https://agentgid.com/build/recipes/telegram-ai-bot/ · all product recipes: https://agentgid.com/build/recipes/agent.md
