Dashboard

How to Build a Slack Bot With AI

Pick the right trigger, request only the scopes you need, and scaffold a real standup bot with an AI coding tool. A worked example and rollout steps.

Steve Jefferson
Steve Jefferson
Developer Advocate
2 September 20261 min read

A Slack bot is three pieces: a trigger (a slash command or an event Slack sends you), a small server that receives it and decides what to do, and whatever permissions (scopes) it needs to post back or read data. AI coding tools are genuinely good at scaffolding all three once you have decided which trigger type fits what you are building, which is a five-minute decision most people skip and then rebuild around later.

Pick the trigger type first

Trigger

Good for

User experience

Slash command

On-demand actions (/standup, /deploy-status)

User types the command, gets a response

Event subscription

Reacting automatically (new message, reaction added)

Runs without anyone asking

Scheduled job

Recurring posts (daily standup prompt, weekly report)

Runs on a timer, posts unprompted

Interactive component

Buttons and forms inside a message

User clicks instead of types

Most first bots want a slash command plus a scheduled job. A standup bot, for instance, is a scheduled job (post the prompt at 9am) plus an event subscription (listen for replies in the thread) rather than a slash command at all, which trips people up because "bot" and "slash command" get used interchangeably even though they are different mechanisms.

Request only the scopes you need

Slack scopes are granular and worth taking seriously, since an over-scoped app is a real security liability if the bot token ever leaks. A standup bot needs roughly this and nothing more:

  • chat:write, to post messages

  • commands, only if you are also adding a slash command

  • channels:history, to read replies in the thread it started (channel-scoped, not workspace-wide)

Skip channels:read, users:read.email, and anything with an admin prefix unless you have a specific, named reason. A bot that requests broad read access to get a simple job done is the kind of thing that fails a workspace admin's review, and rightly so.

A worked example: the standup bot

Here is the scaffolding prompt for the full loop, posting a prompt, collecting thread replies, and summarizing them, given to an AI coding tool once the scopes above are set up in Slack's app configuration:

Build a Slack bot with two functions:

1. A scheduled job that runs weekdays at 9am (workspace timezone) and
posts 'Good morning! Reply in this thread with: what you did
yesterday, what you're doing today, any blockers.' to the #standup
channel.

2. A function that runs at 10am the same day, reads all thread
replies from that morning's post using the Slack API, and posts a
single summary message grouping responses under 'Yesterday',
'Today', and 'Blockers' headers, with each person's name next to
their line. Use the Slack Bolt SDK. Store the message timestamp of
the morning post so the 10am job knows which thread to read.

The instruction to store the message timestamp matters. Without a stable reference to which thread to read, the summary job has no reliable way to find the right conversation, especially in an active channel with other messages between 9am and 10am.

Where it actually runs

A Slack bot needs a server reachable from the internet to receive events and slash commands, it cannot run purely on your laptop. A serverless function (a single endpoint that wakes up when Slack calls it) is the right shape for almost every small bot, since it avoids paying for a server that sits idle between events. An AI app builder can scaffold this endpoint directly as part of the same build, deployed and given a public URL to register in Slack's app settings, without you separately setting up hosting.

Test before rolling out

Install the bot into a private test channel with two or three people before adding it to a busy channel. The failure modes that matter, the scheduled job firing at the wrong time due to a timezone mismatch, the summary missing someone's reply because they used a reaction instead of a text reply, only show up with real use, and they are much cheaper to catch with three people watching than after a whole team has learned to ignore a broken bot.

Common mistakes in a first bot

  • Hardcoding the bot token in the code instead of an environment variable. If the code ever ends up in a public repository, a hardcoded token is a live credential leak, not a hypothetical one.

  • Not verifying Slack's request signature on incoming events. Without this check, anyone who finds your endpoint URL can send it fake events, since the URL itself is not a secret.

  • Building the summary logic to expect exactly one reply format. Real thread replies are messy, some people write three lines, some write one, some react with an emoji instead of replying at all. Ask the model to handle missing sections gracefully (skip a person under 'Blockers' if they said none) rather than assuming a rigid format.

  • Rolling out to a large channel before confirming the scheduled job's timezone actually matches the team's, not the server's default UTC.

FAQ

Do I need to know how Slack's API works to build this?

Not in detail. Describing the desired behavior (scheduled post, read thread replies, summarize) to an AI coding tool that knows the Slack Bolt SDK gets you most of the way. You do need to create the Slack app itself and configure scopes in Slack's own dashboard, which is a manual step no AI tool can do for you.

How much does hosting a Slack bot cost?

For a single-team internal bot with light usage, a serverless function typically runs free or a few dollars a month on most platforms' free or low tiers, since it only executes when triggered rather than running continuously.

Can the bot post to multiple channels?

Yes, if chat:write scope is granted and the bot is invited to each channel. Slack bots cannot post to channels they have not been added to, which is a deliberate privacy boundary, not a limitation to work around.

For the underlying build workflow, how to build an app with AI covers the general process this assumes. For the automated posting piece specifically, how to add scheduled tasks to an AI-built app and how to add webhooks to an AI-built app go deeper on the mechanics underneath a trigger-based bot. For securing secrets like your bot token, see environment variables and secrets in an AI-built app.

How did this land?

About the author

Steve Jefferson
Steve Jefferson

Developer Advocate

Steve builds something with Swarmz every week and writes up what worked, what broke, and what he'd do differently. Tutorials and hands-on guides are his lane.

Share

Get the next post in your inbox

One email a month. Product updates, engineering posts, and the best of Built with Swarmz.

I agree to receive emails about AI building tips and Swarmz product news. Unsubscribe any time.