
- Updated
Build a simple Telegram or Discord bot
This prompt writes a complete chat bot for Telegram or Discord, reads the token from an environment variable and explains how to create the token, run the bot and keep it online on a free or cheap host.
Act as a developer who builds chat bots in [LANGUAGE, e.g. Python]. Platform: [Telegram or Discord] The bot should: [e.g. reply with today's gold rate when someone types /gold] Commands: [LIST] Write the complete bot with a well-maintained, popular library, the token read from an environment variable (never hard-coded), clear replies for unknown commands, and basic rate limiting. Explain how to create the bot token, run it locally, and keep it running on a free or cheap host.
Never paste your real bot token into a chat or commit it to Git. Keep it in a .env file.
Get a better result
A complete bot using a popular, maintained library, with the token read from an environment variable, clear replies for unknown commands, basic rate limiting and steps to create the token, run it locally and host it cheaply.
The token is pasted straight into the code.
Fix: Keep it in an environment variable or a .env file, add that file to .gitignore, and revoke and replace the token at once if it ever leaks.
- The bot works on your PC and stops when you close it. Ask for hosting steps for a small always-on service, and check the free tier’s limits and sleep rules first.
- The data in replies, such as a price, is wrong or stale. Name a real source or API for the data and ask for a cache time and an error message if the source is down.
Ask for “one command only I can use, checked by my user ID, that shows how many people used the bot today”. Keep the ID in the environment settings too.
Add an unknown-command reply, a help command listing all commands, and a limit of five messages a minute for each user.
Guides that use this prompt
More chat & writing prompts
See all 465 →More like this
- Resolve a Git merge conflict safelyClaude · ChatGPT · Claude Code
- Write clear git commit messagesChatGPT · Gemini · Claude
- Fix a bug that works locally but fails in productionClaude · ChatGPT · Gemini
- Write a GitHub Actions workflowChatGPT · Gemini · Claude
- Speed up a slow SQL queryChatGPT · Gemini · Claude



