Build a Slack bot
A Slack bot with a slash command, /items, backed by a placeholder model, and mentions answered by a model in their thread. A starting point: rename the model, change the command, and build your bot on it.
What you'll build
What it shows: Checking Slack's signature on every request, answering inside Slack's three seconds by moving anything slow to a job, a job keyed by Slack's event id so its retries reply once, and a model call through the ai client with no key to set.
Before you start
- The CLI:
npm i -g @inferencebureau/apps, thenib-apps loginonce. - A Slack workspace where you can add apps.
Create the app from the recipe
One command creates the app on Inference Bureau and downloads its files into ./my-slack-bot. Web is the default platform, so the recipe id is all it takes.
ib-apps create my-slack-bot --recipe slack-botTour what the recipe loaded
The recipe replaces the starter, keeping the coding-agent guidance. Here's where each piece lives.
| Where | What's there |
|---|---|
web/lib/slack.ts | verifySlack checks the signing secret and the request's age; slackCommand answers /items add and /items; slackEvent answers Slack's address check and queues a reply to each mention. |
web/app/api/slack/ | The two Request URLs: commands/ for the slash command, events/ for Event Subscriptions. |
api/actions/replyToMention.ts | The job: the model's answer, posted in the thread with SLACK_BOT_TOKEN. A refused post is logged rather than tried forever. |
api/models/item/ | The placeholder model, kept per workspace. |
web/app/page.tsx | /: the addresses and the Slack app's manifest, filled in with this app's address. |
tests/slack-bot.test.ts | The signature, the command, a retried mention, and a refused post, with the model mocked and Slack stubbed. |
export async function slackEvent(api: Api, payload: Record<string, any>) {
if (payload.type === "url_verification") return { challenge: String(payload.challenge ?? "") };
const e = payload.event;
if (payload.type !== "event_callback" || e?.type !== "app_mention" || e.bot_id) return null;
// Slack wants an answer in three seconds: the model runs in a job, once per event however often Slack retries.
await api.enqueue("replyToMention", { channel: e.channel, ts: e.thread_ts ?? e.ts, text: withoutMentions(e.text) },
{ dedupeKey: `slack:${payload.event_id}`, retries: 4 });
return null;
}Check what it set on the app
Nothing to do here: this is what the recipe configured, so you know where to look in Settings later.
anthropic/claude-haiku-5.5 through the ai clientSet its keys
On Settings → Environment variables, for development first:
| Name | Where it comes from |
|---|---|
SLACK_SIGNING_SECRET | the Slack app's Basic Information |
SLACK_BOT_TOKEN | the Slack app's OAuth & Permissions, after installing it |
Finish setup
- Open the app:
/shows the Slack app's manifest with this app's addresses - Create the Slack app from the manifest, then set
SLACK_SIGNING_SECRETand, once it's installed,SLACK_BOT_TOKEN - Run
/items add first tryin Slack, then mention the bot in a channel it's in
In development, point the Slack app at the development address; once production is live, change its URLs to production's.
Run it
ib-apps dev syncs both ways while you work and runs the development server.
cd my-slack-bot
ib-apps devTry it end to end
Make it yours
Rename item, change /items in the manifest and slackCommand, and the answer's prompt in replyToMention.ts.
See Calling models for the ai client.
ib-apps test runs its tests, then ib-apps deploy sends development to production; set the keys on production first. See Deploys.