Skip to main content

Python Prompt to Build a Slack or Discord Bot with Commands and Tasks

Build a Python Slack or Discord bot with slash commands, interactive messages, scheduled tasks and external API integrations.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt builds a [platform] bot in Python for a [team_type], designed to [bot_purpose] and handle [expected_users] concurrent users. It lays out a modular architecture and works through the parts that actually matter in production: lifecycle handling with reconnection, [command_count] slash commands with cooldowns, interactive components with a state machine, scheduled tasks that survive restarts, external API integration, an admin system with an audit log, and robust error handling. The emphasis on reconnects, cooldowns, and persistent state is what separates a real ops tool from a toy.

The variables define the bot's surface and resilience. [bot_framework] and [auth_method] set the foundation, [command_count] and [primary_commands] define the command set with [cooldown_duration] rate limiting, and [interactive_elements] plus [conversation_flow] drive multi-step interactions via a state machine that expires after [session_timeout]. [scheduler_library], [scheduled_tasks], and [storage_backend] handle recurring jobs whose state outlives restarts, while [external_apis] and [admin_roles] cover integrations and permissions.

When to use it

  • Building an internal Slack or Discord bot to offload repetitive ops work.
  • Implementing slash commands with per-user [cooldown_duration] cooldowns to prevent spam.
  • Driving multi-step flows like incident creation with a state machine that expires.
  • Running scheduled jobs whose state survives bot restarts via [storage_backend].
  • Integrating external services like [external_apis] with caching and rate-limit handling.
  • Adding an admin system with [admin_roles] and an audit log for accountability.

Example output

You get a modular bot implementation with code: a project structure separating commands, events, tasks, and services; lifecycle handling with [auth_method] auth, graceful shutdown, and auto-reconnection; [command_count] slash commands ([primary_commands]) with type validation and [cooldown_duration] cooldowns; interactive components using [interactive_elements] and a state machine for [conversation_flow] expiring after [session_timeout]; [scheduler_library] jobs for [scheduled_tasks] with state in [storage_backend]; a service layer integrating [external_apis] with caching; an admin system with [admin_roles] and an audit log; and error handling routing failures to [error_channel].

Pro tips

  • Make auto-reconnection non-negotiable; a bot that dies on a brief disconnect is useless for ops, so the lifecycle step must handle it.
  • Add [cooldown_duration] cooldowns to every command in [primary_commands]; without them, one impatient user can spam your integrations.
  • Persist state to [storage_backend] so [scheduled_tasks] and in-flight [conversation_flow] sessions survive a restart instead of vanishing.
  • Cache [external_apis] responses for the configured duration and handle their rate limits, or the bot will get throttled under load.
  • Keep an audit log of admin actions; for a bot wired into deployments and on-call, accountability is essential.
  • Set a [session_timeout] on multi-step flows so abandoned conversations clean themselves up instead of lingering.
  • Route unhandled exceptions to [error_channel] with friendly user-facing messages, so the bot never crashes silently and the team sees failures fast.

Frequently Asked Questions

Does this work for both Slack and Discord?
Yes. The `[platform]` variable selects the target, defaulting to Slack with slack-bolt. The architecture, command, scheduling, and admin patterns transfer to Discord, though you swap the `[bot_framework]` and adjust the platform-specific interaction APIs accordingly.
How does the bot survive restarts without losing state?
Scheduled task state and in-progress conversations are stored in `[storage_backend]` rather than memory. So when the bot restarts, `[scheduled_tasks]` resume on schedule and the audit log persists, which is the difference between a durable tool and a fragile prototype.
What stops users from spamming commands?
Each command enforces a `[cooldown_duration]` per-user cooldown. This prevents a single user from hammering integrations like `[external_apis]`, which both protects downstream rate limits and keeps the bot responsive for everyone else on the team.
How are multi-step interactions handled?
Through a state machine that tracks user progress across steps, such as the `[conversation_flow]` incident creation flow. Sessions expire after `[session_timeout]` so abandoned interactions clean up automatically rather than leaving the bot waiting on input that never arrives.
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.

More in Python & Automation 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