vibecode.wiki
RU EN
~/wiki / telegram-boty / создание-бесплатного-telegram-бота-с-ии-на-groq-api

Creating a free Telegram bot with AI on Groq API

◷ 4 min read 2/12/2026

Next step

Open the bot or continue inside this section.

$ cd section/ $ open @mmorecil_bot

Article -> plan in AI

Paste this article URL into any AI and get an implementation plan for your project.

Read this article: https://vibecode.morecil.ru/en/telegram-boty/%D1%81%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5-%D0%B1%D0%B5%D1%81%D0%BF%D0%BB%D0%B0%D1%82%D0%BD%D0%BE%D0%B3%D0%BE-telegram-%D0%B1%D0%BE%D1%82%D0%B0-%D1%81-%D0%B8%D0%B8-%D0%BD%D0%B0-groq-api/ Work in my current project context. Create an implementation plan for this stack: 1) what to change 2) which files to edit 3) risks and typical mistakes 4) how to verify everything works If there are options, provide "quick" and "production-ready".
How to use
  1. Copy this prompt and send it to your AI chat.
  2. Attach your project or open the repository folder in the AI tool.
  3. Ask for file-level changes, risks, and a quick verification checklist.

If you’ve already made a simple bot on Telegram, now let’s make it *smart with answers from Groq (very fast and free AI).

What you need in advance:

  • Installed Codex app (Cursor, VScode)
  • Groq API key (free)
  • Telegram

Step 1. Install Codex app (you can use analogues)

  1. Go to https://openai.com/codex
  2. Press Download
  3. Open the downloaded file → install
  4. Launch the application
  5. Sign in with ChatGPT – use your login/password from chatgpt.com
  6. Done! Codex will open as a chat/agent window.

Step 2. Get a Groq API key

  1. Go to https://console.groq.com/keys
  2. If there is no account – Sign Up (email + password + confirm mail)
  3. Come in
  4. On the main or on the left menu, find API Keys
  5. Press Create API Key
  6. Give me a name like TelegramBotGroq
  7. Press Create
  8. Copy the key (starts with gsk_...) - save it in notes. It only shows once!

Step 3. Create a Telegram bot and take a token

  1. On Telegram, find @BotFather
  2. Write /newbot
  3. The name of the bot is any, such as "Groq Smart Assistant."
  4. Username – ends in bot, such as @GroqVibeBot or @SiauliaiAIBot
  5. BotFather to give token: 1234567890:AAFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  6. Copy the token

Step 4. Give Codex the task - create and launch a bot!

  1. In Codex app, open a new window / project (New Thread or just chat)
  2. Enter ** this prompt in its entirety** (you can and should adjust):
code
Create and run a full Telegram bot in Python with Groq API integration for smart answers. Do it yourself inside Codex without me doing it.

Requirements:
Libraries: python-telegram-bot (async version), requests, python-dotenv
- Files: bot.py + .env
- In .env: BOT TOKEN=telegram token here and GROQ API KEY=groq key here (with placeholders)
- Bot:
- /start: Hello! I'm a Groq AI bot. Ask any question 🙂
- /help: "Just write - I will answer quickly through Groq"
- any message: first, "I think ..."  , then query to Groq, reply to the user
- Groq: endpoint https://api.groq.com/openai/v1/chat/completions
Headers: Authorization: Bearer
Body: {"messages": [{"role": "user", "content": text}], "model": model}
Choose 2-3 Groq models (llama3-8b-8192, llama-3.1-70b-versatile, mixtral-8x7b-32768, gemma2-9b-it, etc.)
- Before the final code, test each model on the query "Hi, tell a joke!" - show the results in the chat (which answered normally, which with an error)
Choose the fastest and most stable bot model
- Handle Groq errors: "Groq is busy now " Try later"
- Launch: polling (app.run polling())
At launch: print("Bot launched!") Write him on Telegram.
- Code with comments in Russian
Create a project yourself, install dependencies in a sandbox, test models, run a bot
- After launch, say "Bot working!" Check Telegram.

GROQ API KEY for model testing: insert your key here (replace in .env)

(In the prompt, insert your real Groq key for model testing only - Codex will test privately, in the final .env key will be a placeholder.)

  1. Send a prompt (Enter or Run/Start Agent button)
  2. Codex will start working:
    • Create a sandbox project
    • Install the packages
    • Tests Groq models (you will see in the chat which worked)
    • Write code
    • Launch the bot
    • The logs will say, "Bot's running!"

Step 5. Final steps in .env and test

  1. Codex will create .env something like this:
code
BOT TOKEN=your telegram token here
GROQ API KEY=your gsk key here
  1. Open .env in Codex (or Finder) → insert your keys → save

  2. If the bot stops - in Codex write: "Reset the bot"

  3. In Telegram, find a bot → /start → ask a question

The bot must respond via Groq

If there's a problem

  • The model doesn’t work in Codex: “Groq model broke, here’s the mistake: [insert].” Choose another and restart
  • Key Error: "Check .env and restart"
  • Copy the log from Codex and paste it into a new prompt: "Fix this mistake"

Your bot with Groq AI launched fully automatically via Codex