Slack bot
Apps/Recipes/Slack bot

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.

Web, no sign-inKind backendRecipe id slack-bot

What you'll build

Slack/items or a mentionSigned routeanswers within 3sreplyToMentiona job, once per eventReplyin the thread

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, then ib-apps login once.
  • 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-bot

Tour what the recipe loaded

The recipe replaces the starter, keeping the coding-agent guidance. Here's where each piece lives.

WhereWhat's there
web/lib/slack.tsverifySlack 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.tsThe 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.tsThe 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.

PlatformWeb, no sign-in
Modelanthropic/claude-haiku-5.5 through the ai client

Set its keys

On Settings → Environment variables, for development first:

NameWhere it comes from
SLACK_SIGNING_SECRETthe Slack app's Basic Information
SLACK_BOT_TOKENthe Slack app's OAuth & Permissions, after installing it

Finish setup

  1. Open the app: / shows the Slack app's manifest with this app's addresses
  2. Create the Slack app from the manifest, then set SLACK_SIGNING_SECRET and, once it's installed, SLACK_BOT_TOKEN
  3. Run /items add first try in 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 dev

Try it end to end

0 of 2 checked

Make it yours

Your bot

Rename item, change /items in the manifest and slackCommand, and the answer's prompt in replyToMention.ts.

Calling models

See Calling models for the ai client.

Ship it

ib-apps test runs its tests, then ib-apps deploy sends development to production; set the keys on production first. See Deploys.