Skip to main content

Claude Prompt to Build a Discord or Slack AI Bot

Build an AI Discord or Slack bot with slash commands, threaded conversations, rate limiting, persistent context, and clean deployment.

Füllen Sie die Platzhalter aus

Edit the values, then copy your finished prompt.

Ihr Prompt
prompt.txt

                                

What this prompt does

This prompt builds an AI bot for [platform] (Discord or Slack) that handles [bot_purpose], written in [language]. It covers the full setup: API integration with correct permission scopes, slash command registration for [commands], thread-based conversations with context persistence, and AI responses via [model_provider].

The structure works because chat bots live or die on the boring infrastructure, not the AI call. Rate limiting of [rate_limit] requests per [rate_window] per user prevents abuse and cost blowouts, [storage] persists preferences and history across restarts, and admin commands give you usage stats and user blocking. The user-friendly error handling step — surfacing readable messages instead of leaking stack traces — is the small detail that separates a hobby bot from one a team actually trusts.

Rich message formatting and proper permission scopes are what make the bot feel native to [platform]. Embeds, buttons, and select menus turn flat text replies into interactive responses, while requesting only the scopes the bot needs keeps it secure and speeds up workspace approval. Deployment to [deploy_target] with automatic restart closes the loop, so a transient crash recovers on its own instead of leaving the bot silently offline until someone notices.

When to use it

  • Your team lives in Discord or Slack and you want AI help available where they already work.
  • You need slash commands like [commands] rather than a single catch-all prompt box.
  • You want threaded conversations that remember context within a thread.
  • You need per-user rate limiting to control cost and prevent abuse.
  • You want persistent storage so the bot keeps preferences and history across restarts.
  • You need a clean deployment to [deploy_target] with automatic restart.

Example output

Expect a deployable bot in [language]: slash command definitions, event handlers for messages and threads, the [model_provider] integration, rate-limiting middleware, [storage] schema for preferences and history, rich message formatting (embeds, buttons, select menus), admin commands, and environment-variable configuration. It usually includes the [deploy_target] setup with restart handling.

Pro tips

  • Request only the permission scopes you actually need; over-broad scopes are a security smell and slow team approval.
  • Set [rate_limit] and [rate_window] conservatively at first — it is easier to loosen limits than to recover from a cost spike.
  • Keep [storage] simple for small teams; the SQLite default is plenty before you need a hosted database.
  • Define [commands] with clear verbs and a short help string each, so users discover them without documentation.
  • Make error messages human-readable; never leak a stack trace into a channel where users will see it.
  • Pick [deploy_target] with built-in restart so a crash does not silently take the bot offline.
  • Use rich formatting (embeds, buttons, select menus) for replies that benefit from it, but keep simple answers plain to avoid clutter.
  • Add admin commands for usage stats and user blocking early; you will want them the moment the bot gets real traffic.

Frequently Asked Questions

Does this work for both Discord and Slack?
Yes, the `[platform]` variable covers either. The overall structure (slash commands, threads, rate limiting, storage) is shared, but the API specifics, permission scopes, and message-formatting primitives differ between Discord and Slack, so the generated code targets the one you select.
How does the bot remember context in a conversation?
It uses thread-based conversations with context persistence, so messages within a thread share history. Longer-term preferences and history are kept in `[storage]`, which means the bot retains user context even across restarts rather than forgetting everything on redeploy.
Why is rate limiting per user included?
Without it, a single user can spam requests and run up real AI costs or degrade the bot for everyone. Limiting to `[rate_limit]` requests per `[rate_window]` per user keeps usage and spend predictable, which is essential for any bot a team relies on.
What happens when the AI call fails?
The error-handling step surfaces a friendly, readable message to the user instead of dumping a stack trace into the channel. This keeps the bot feeling trustworthy and professional, and avoids leaking internal details that could expose how the bot is built.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

Mehr in AI Chatbot & Agent Building Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support