Discord / Telegram bot

Build an AI Discord or Telegram bot

An AI bot for your clan, guild or community needs three things: a bot library that talks to Discord or Telegram, a cheap fast model for replies, and an always-on host. Bots hold a persistent connection, so serverless hosting is a poor fit. Use a small always-on container instead.

Recommended stack

Model

  • Google Gemini 3.8 Flash: Free tier available; paid ~$0.75 in / $3.75 out per 1M until 2026-12-31, then $1.50/$7.50 (verified 2026-10-14)
  • OpenAI GPT-6 Luna: ~$0.10 in / $0.50 out per 1M tokens (verified 2026-10-14)

Framework

Hosting

  • Railway: Free $0 w/ $1/mo credit; Hobby $5/mo incl. $5 usage (verified 2026-10-14)
  • Fly.io: No free tier for new users; pay-as-you-go, small VMs from ~ $2/mo (verified 2026-10-14)

No-code alternative

Rough monthly cost

$0–10/mo (Railway Hobby $5 + light model usage)Approximate

Difficulty

Beginner–Intermediate

Some links may be affiliate links. Disclosure

Why this stack

Step-by-step

  1. Create an application in the Discord Developer Portal (or talk to @BotFather on Telegram) and copy the token into an environment variable.
  2. Get a /ping slash command working before any AI.
  3. Add an /ask command that sends the message to your model with a short system prompt describing your community.
  4. Add per-user rate limits so one member can't burn your token budget.
  5. Deploy to Railway or Fly.io and watch logs for the first week.

Common pitfalls

Customise this stack in the picker →

📬 The Loadout

One weekly AI build loadout: a project idea, the stack to build it, and the tools worth knowing. Free, unsubscribe anytime.

Subscribe to The Loadout