Telegram bot: free to send, cheap to run

Telegram does not charge per message, and you need no middleman. The only costs are the server and the AI model, if the bot should write its own answers. Here is a complete Python recipe, written the way we would write it today.

Last checked:

Step by stepThe recipe step by step
  1. @BotFather
  2. Create a Telegram group for staff, add the bot and find the group id. Questions the bot cannot answer land here
  3. Write your facts in faq_da.md: opening hours, prices, address, delivery, returns. Short and concrete
  4. Install aiogram and openai in a virtual environment. The code below was tested with aiogram 3.32 and openai 3.55 on Python 3.12
  5. Run the bot on a server with python bot.py. Polling needs no public address. Switch to a webhook later if you get many users

Why Telegram – and when not

Telegram is strong for communities, internal tools and customers from Eastern Europe, where many people use Telegram before WhatsApp. We have built several bots in Python with aiogram: five versions of a community bot for a Ukrainian-European business network with moderation, broadcasts, event creation, an OpenAI assistant and Google Sheets, an AI bot that moderates messages, and a bot that watches flight prices. The owner’s own assistant sends a morning brief in Telegram at 07:30 with buttons to approve or reject. It uses no AI tokens and finishes in about 3 seconds.

If your customers do not already use Telegram, do not make it your only channel. Most Danish consumers would rather write on your website or on WhatsApp.

What does it cost?

Telegram itself is free: bots can message users at no cost. There are speed limits: about one message per second in a single chat, 20 messages a minute in a group and roughly 30 a second for broadcasts. If you need to send faster, paid broadcasts cost 0.1 Telegram Stars per message above the free amount.

The AI part is cheap. With gpt-6-luna one million input tokens cost $0.10 and one million output tokens $0.50. An answer grounded in a FAQ of a couple of pages therefore costs a fraction of an øre. We always pick the cheapest model that does the job, and each project has its own API key. The real cost is a small server and the time it takes to keep the FAQ up to date.

The recipe step by step

  1. Message @BotFather in Telegram, choose /newbot and keep the token you get. It is a password, so it belongs in a .env file, not in the code.
  2. Create a Telegram group for staff, add the bot and find the group id. Questions the bot cannot answer land here.
  3. Write your facts in faq_da.md: opening hours, prices, address, delivery, returns. Short and concrete.
  4. Install aiogram and openai in a virtual environment. The code below was tested with aiogram 3.32 and openai 3.55 on Python 3.12.
  5. Run the bot on a server with python bot.py. Polling needs no public address. Switch to a webhook later if you get many users.

The instruction to the model is in English while the answer to the customer is in the customer’s language. That is a fixed rule for us, because models follow English instructions most consistently.

bot.py – Telegram bot with AI disclosure, FAQ, handover and a daily cap (aiogram 3)

import asyncio
import datetime as dt
import os
import pathlib
import re

from aiogram import Bot, Dispatcher, F
from aiogram.filters import CommandStart
from aiogram.types import Message
from openai import AsyncOpenAI

bot = Bot(os.environ["TG_TOKEN"])
dp = Dispatcher()
llm = AsyncOpenAI()  # reads OPENAI_API_KEY – the project's own key
STAFF_CHAT = int(os.environ["STAFF_CHAT_ID"])  # group where staff take over
FAQ = pathlib.Path("faq_da.md").read_text(encoding="utf-8")  # prices, opening hours, address
DAILY_LIMIT = int(os.environ.get("DAILY_LIMIT", "300"))  # cap on AI replies per day
DISCLOSURE = "Hej! Jeg er en AI-assistent. Skriv 'medarbejder', hvis du vil tale med et menneske."
HANDOFF = "[HANDOFF]"
INSTRUCTIONS = (
    "You answer customers of a Danish small business. Reply in the customer's language, "
    "Danish by default, short and polite, using 'du'. Use ONLY the facts below. Prices in kr. "
    f"with moms unless stated. If the answer is not in the facts, reply exactly {HANDOFF}.\n\n{FAQ}"
)
usage = {"day": dt.date.today(), "count": 0}


async def hand_over(m: Message) -> None:
    await bot.send_message(STAFF_CHAT, f"Kunde {m.from_user.full_name} (id {m.chat.id}) skriver:\n{m.text}")
    await m.answer("Jeg sender dit spørgsmål videre til en medarbejder, som svarer dig her i chatten.")


@dp.message(CommandStart())
async def start(m: Message) -> None:
    await m.answer(DISCLOSURE)  # AI disclosure from the first message (AI Act Art. 50)


@dp.message(F.chat.id == STAFF_CHAT, F.reply_to_message.text)
async def staff_reply(m: Message) -> None:
    # Staff reply to the bot's message in the group; the reply goes to the customer
    found = re.search(r"\(id (-?\d+)\)", m.reply_to_message.text)
    if found and m.text:
        await bot.send_message(int(found.group(1)), m.text)


@dp.message(F.text, F.chat.id != STAFF_CHAT)
async def answer(m: Message) -> None:
    if "medarbejder" in m.text.lower():
        return await hand_over(m)
    if usage["day"] != dt.date.today():
        usage.update(day=dt.date.today(), count=0)
    if usage["count"] >= DAILY_LIMIT:
        return await hand_over(m)
    usage["count"] += 1
    r = await llm.responses.create(
        model="gpt-6-luna", instructions=INSTRUCTIONS, input=m.text, max_output_tokens=300
    )
    text = r.output_text.strip()
    if HANDOFF in text or not text:
        return await hand_over(m)
    await m.answer(text)


async def main() -> None:
    await dp.start_polling(bot)


if __name__ == "__main__":
    asyncio.run(main())

What the code does – and why

  • AI disclosure from the first message. /start says it is an AI and how to reach a person. Article 50 of the AI Act requires this from 2 August 2026 , and in our own standard a bot cannot be saved without it.
  • Only your own facts. If the answer is not in the FAQ, the model replies with a fixed marker and the question goes to the staff group. This is the most important line in the code: we have seen a bot invent facts when the knowledge base was empty.
  • A person can take over. Staff reply to the bot’s message in the group and the reply goes straight to the customer. In cbot.dk the same idea is extended with rules for when the bot gives up by itself.
  • A cap on spending. After a fixed number of AI replies per day everything goes to staff. Our own assistant has a cap of 2 dollars a day.

Two things that surprised us

Groups do not remember for new members. If you add a person or a bot to a basic group, it cannot read messages from before. That setting exists only in supergroups. Message ids in basic groups come from an account-wide counter, so they say nothing about the size of the history.

Many small bots turn into a mess. We ended up with five versions of the same community bot and are now merging them into one. Our Telegram Mini App for the Ukrainian community had about 300 users but has been frozen since 6 November 2026. The lesson: build one bot with modules, and decide from day one who owns it.

Sources

Last reviewed: 2026-12-03

Questions about Telegram bots

Is it free to make a Telegram bot?

Yes. Telegram does not charge for the bot’s messages to users. You pay only for the server and, if used, an AI model.

Does the bot have to run all the time?

Yes, the program must run on a server that stays on. A small virtual server is enough for most small businesses.

Can the bot answer in Danish and Ukrainian?

Yes. The instruction asks the model to reply in the customer’s language. Test both languages with your own questions before going live.

What do we do with the BotFather token?

Store it in a .env file with restricted permissions and never commit it to git. If it leaks, create a new one through BotFather.

Fixed price, no commitment

Get a fixed price for your chatbot

Tell us briefly what you use today and what you want to achieve. A person answers by e-mail with a proposal and a fixed price before any work starts.

  • A fixed price before we start
  • An answer by e-mail, no calls
  • Your details are used only to answer you

Fields marked with * are required.

What is it about?