A Telegram AI chatbot powered by Convex. Default AI provider is Moonshot (Kimi K2). Also supports Claude, OpenAI, and Grok. Works in group chats and private messages.
- Bun
- A Telegram bot token from @BotFather
- A Moonshot API key (or Claude/OpenAI/xAI Grok)
bun installbunx convex dev --once --configure=newbunx convex env set TELEGRAM_BOT_TOKEN "your-token-from-botfather"
bunx convex env set TELEGRAM_WEBHOOK_SECRET "any-random-secret-string"
bunx convex env set AI_PROVIDER "moonshot"
bunx convex env set AI_API_KEY "your-moonshot-api-key"
bunx convex env set AI_MODEL "kimi-k2-0711-preview"
bunx convex env set BOT_USERNAME "nerdbot"
bunx convex env set ALLOWED_USER_IDS "comma-separated-telegram-user-ids"
bunx convex env set ALLOWED_GROUP_IDS "comma-separated-telegram-group-ids"Optional settings (have sensible defaults):
bunx convex env set RATE_LIMIT_PER_MINUTE "10"
bunx convex env set MAX_CONTEXT_MESSAGES "15"
bunx convex env set MAX_RETAINED_MESSAGES "100"
bunx convex env set WEB_SEARCH "true"
bunx convex env set AI_THINKING "disabled"
bunx convex env set GITHUB_TOKEN "your-github-pat"
bunx convex env set GITHUB_REPO "owner/repo"
bunx convex env set ALLOWED_ISSUE_USER_IDS "comma-separated-telegram-user-ids"bunx convex run telegram:registerWebhook/setprivacy-> Select your bot -> Disable (so the bot can read group messages for context)/setcommands-> Set:help - Show help message reset - Clear conversation history issue - Create a GitHub issue from conversation
bunx convex devbun run test # run all tests (unit + convex integration)
bun run test:unit # unit tests only (bun:test)
bun run test:convex # convex integration tests only (vitest + convex-test)Tests are in __tests__/:
__tests__/unit/— Unit tests for pure helpers, AI providers, Telegram API, env, and structured logging (bun:test)__tests__/convex/— Integration tests for Convex functions: message CRUD, webhook routing, rate limiting, and AI processing pipeline (vitest + convex-test)
bun run check # lint + format check + typecheckbunx convex deploy- Groups: Add @nerdbot to a group. Mention it with
@nerdbotto chat. Supports forum topics — replies in the same thread. - Private chat: Message the bot directly.
/resetclears conversation history for the current chat./issue <description>creates a GitHub issue by summarizing the conversation context + your description. RequiresGITHUB_TOKENandGITHUB_REPOto be set.- Messages older than the latest 100 per topic are automatically pruned daily (configurable via
MAX_RETAINED_MESSAGES). - Only whitelisted users and groups can interact with the bot — check Convex logs for blocked user/group IDs.
- Web search: When
WEB_SEARCHis enabled, the model can autonomously search the web to answer questions about current events or look up information. Supported by Moonshot, OpenAI, and Grok. - Thinking control (Moonshot): Set
AI_THINKINGtodisabled,enabled, orauto(e.g.disabledfor kimi-k2.5). - Structured logging: All logs are emitted as single JSON lines per request (wide events). Check the Convex dashboard for structured logs with fields like
event,chatId,userId,provider,inputTokens, etc.