Example result: Build a simple Telegram or Discord bot
AI-generated example · Build · Bot
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.

text-code-telegram-bot-builder — claude — 78 words

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

What you will get

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.

Common mistake

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.

Also watch for
  • 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.
Try a variation: add an admin command

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.

Still not right? Reply with this

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 →