Creating a free Telegram bot with AI on Groq API
Next step
Open the bot or continue inside this section.
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
- Copy this prompt and send it to your AI chat.
- Attach your project or open the repository folder in the AI tool.
- 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)
- Go to https://openai.com/codex
- Press Download
- Open the downloaded file → install
- Launch the application
- Sign in with ChatGPT – use your login/password from chatgpt.com
- Done! Codex will open as a chat/agent window.
Step 2. Get a Groq API key
- Go to https://console.groq.com/keys
- If there is no account – Sign Up (email + password + confirm mail)
- Come in
- On the main or on the left menu, find API Keys
- Press Create API Key
- Give me a name like TelegramBotGroq
- Press Create
- Copy the key (starts with
gsk_...) - save it in notes. It only shows once!
Step 3. Create a Telegram bot and take a token
- On Telegram, find @BotFather
- Write
/newbot - The name of the bot is any, such as "Groq Smart Assistant."
- Username – ends in bot, such as
@GroqVibeBotor@SiauliaiAIBot - BotFather to give token:
1234567890:AAFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - Copy the token
Step 4. Give Codex the task - create and launch a bot!
- In Codex app, open a new window / project (New Thread or just chat)
- 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.)
- Send a prompt (Enter or Run/Start Agent button)
- 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
- Codex will create .env something like this:
code
BOT TOKEN=your telegram token here
GROQ API KEY=your gsk key here
Open .env in Codex (or Finder) → insert your keys → save
If the bot stops - in Codex write: "Reset the bot"
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