Skip to content

The Slack app

Once a day, each person who connects gets one Slack message with the few new items that need them. Each item has a button that deals with it in Slack, and Undo. Claude answers their DMs, using your API as them. The Slack app runs inside the hosted MCP server and needs an oryva key.

The examples continue the notebook API from Hosted mode.

Configure it

Add x-oryva-chat to the spec's info, next to x-oryva-gateway:

info:
  x-oryva-chat:
    name: Notebook                    # the app's name in Slack, at most 35 characters
    feed:                             # optional: items from a list, sent to each person
      operation: notes_list           # a hosted tool that needs no inputs beyond bound ones
      items: data                     # dotted path to the list in its response
      every: 15m                      # how often to look for urgent items and due digests
      priority: {field: priority, order: [urgent, high, normal], urgent: [urgent]}
      digest: {at: "08:30", days: weekdays, limit: 3, prefer: quick}
      card:                           # dotted paths into one item
        id: id                        # tells items apart
        title: title
        text: body                    # optional
        link: url                     # optional: an Open button
        preview: {before: fix.before, after: fix.after}  # optional: shown as before and after
      apply:                          # optional: the main button
        when: quick                   # only where this flag holds; others get Open
        label: fix.buttonLabel
        operation: notes_apply_fix    # a hosted tool, called as the person who clicks
        args: {noteId: "{id}"}        # "{path}" takes a value from the item; others are sent as is
        done: "{result.label}"        # replaces the card once it worked
        undo: {operation: notes_undo_fix, args: {noteId: "{id}"}, done: Put back.}
      actions:                        # optional: under the card's More menu
        - {label: Snooze a week, operation: notes_snooze, args: {noteId: "{id}", days: 7}, done: Snoozed for a week.}
    home:                             # optional: progress rows on the Home tab
      stats:
        - operation: folders_progress
          items: data
          title: name
          progress: {done: reviewed, of: total}
    ask:                              # optional: DMs answered by Claude with the hosted tools
      instructions: You help members with their workspace's notes. Answer briefly and link to notes.
      prompts: [Which notes need me?]

You need feed, ask or both. Spec extensions describes every key, including digest grouping, button choices and actions on Home tab rows.

oryva generate checks every key against the spec and writes slack-manifest.json next to the MCP server. When something is wrong, it stops and names the key. It checks that:

  • x-oryva-gateway is there;
  • every operation exists, is not deprecated, and is a hosted tool;
  • the feed operation needs no input that isn't bound, and returns JSON;
  • every path is in the response's schema, and every parses;
  • an action's args name only known, unbound inputs, include every required one, and use each placeholder as a whole value.

What people see

The digest. Once a day, the app sends each person one message with the best few new items, ranked by priority. It goes out at digest.at in their Slack time zone, or at a time they pick on the Home tab. Items that prefer flags come first; the others wait until none of those are new. A digest goes out only when something is new. The first one, sent when they connect, doubles as the welcome. Urgent items don't wait for the digest: each goes out at once, on its own.

Buttons. apply is the card's main button. It calls the operation as the person who clicks, and the card turns into the done text. Items where when doesn't hold get an Open button instead, which opens card.link. actions go under the card's More menu.

The Home tab shows what is waiting, the home.stats progress rows, and what the person finished this week.

DMs. With ask, Claude answers each person's DMs with the hosted tools, acting as them. It asks before calling a tool that changes anything.

Connecting an account

Each person clicks Connect once, in the app's Home tab or a DM, and signs in with Slack. The app connects their account only if they are the Slack user the button was for. So a Connect link that someone forwards connects no one, and each link works once.

With connect in x-oryva-gateway, they then sign in on your app's own page. Slack sign-ins come back to the same /connect/return as other clients, with the client name Slack.

When the API refuses someone's credential, the app forgets it and asks them to reconnect.

Set it up

On Cloud Run, deploy/setup-gcp.sh creates the Slack app from its manifest and stores its credentials; see Deploying. By hand:

  1. Create an app from slack-manifest.json at https://api.slack.com/apps, with the server's URL in place of https://<gateway>, and install it to your workspace.
  2. Install the server with the slack extra. Run it with the app's credentials and the hosted-mode settings.
pip install out/notebook/python 'out/notebook/mcp[slack]'
export SLACK_SIGNING_SECRET=...     # Basic Information: checks that requests come from Slack
export SLACK_CLIENT_ID=...          # Basic Information: for Sign in with Slack
export SLACK_CLIENT_SECRET=...
export SLACK_BOT_TOKEN=xoxb-...     # OAuth & Permissions
export ANTHROPIC_API_KEY=...        # for ask
notebook-mcp serve --host 0.0.0.0 --port 8000

Slack sends events to /slack/events on the server and clicks to /slack/interactions.

The manifest asks for these scopes:

  • chat:write and im:write, always.
  • im:history, with ask.
  • users:read, with feed, to read each person's time zone.
  • The user scope openid, for Sign in with Slack.

To run the app on your own machine without a public URL, turn on Socket Mode in the app's settings. Then set SLACK_APP_TOKEN, an app-level token with connections:write, instead of SLACK_SIGNING_SECRET.

Let any workspace add it

Under Manage Distribution in the Slack app's settings, activate public distribution. You can then leave out SLACK_BOT_TOKEN. /slack/install on the server becomes the link behind an "Add to Slack" button. The person approves on Slack's page and lands in the app's DM, with an invitation to connect. The database keeps each workspace's bot token, sealed.

With connect, link to /slack/install?grant=... with a grant from your connect flow. The page says whose account the grant connects. Whoever then adds the app from that browser arrives already connected. A grant works once.

The database

ORYVA_CHAT_DB records who connected, with their credentials sealed by the gateway secret, and which items each person was sent.

  • A SQLite file, ./oryva-chat.db by default, serves one instance.
  • A Postgres URL (postgresql://...) serves any number of instances. Install the postgres extra too: 'out/notebook/mcp[slack,postgres]'.

Every instance runs the feed. The database makes sure each digest, urgent item, repeated Slack event and click is handled once. The digests are sent from inside the server, so with a feed, keep one instance running at all times.

ORYVA_CHAT_MODEL picks the Claude model for ask. The default is claude-opus-5-5.