Cairn Developers

DEVELOPERS · PREVIEW

Building apps for Cairn

This is the specification for apps that post cards (Block Kit–compatible messages) to Cairn channels as a bot and receive button, select and modal interactions. The wire format follows Slack, so that an app written with Bolt for JavaScript can run against Cairn by changing only the API endpoint.

This specification is a preview. External developers cannot register apps or issue bot tokens yet (only first-party apps run today). Details may change before registration opens.

How apps work

An app talks to Cairn over three paths.

DirectionPathDetails
App → CairnCall POST /api/app-api/<method> with a bot token (post, update, open modals)Bot Web API
Cairn → AppButton presses, selections, modal submissions and menu launches are POSTed, signed, to your Request URLInteractions
PeopleMembers use the cards in a channel and fill in the modals your app opens (web, desktop, iOS / Android)Cards

An app is installed into a workspace, and each installation has its own bot (the sender) and bot token. A bot can only post to channels that members have added it to. Messages from a bot always carry an “App” badge so they are never mistaken for a person.

Using Bolt for JavaScript

Point Bolt’s clientOptions.slackApiUrl at Cairn and client.chat.postMessage and friends call Cairn directly. Interactions are signed with the same X-Slack-Signature header as Slack, so Bolt’s signature verification works unchanged.

const { App } = require('@slack/bolt')

const app = new App({
  token: process.env.CAIRN_BOT_TOKEN, // cairn_bot_...
  signingSecret: process.env.CAIRN_SIGNING_SECRET,
  // Point the Web API at Cairn (keep the trailing slash)
  clientOptions: { slackApiUrl: 'https://oss-cairn.com/api/app-api/' },
})

app.action('vote', async ({ ack, body, client }) => {
  await ack()
  await client.chat.update({
    channel: body.channel.id,
    ts: body.message.ts,
    text: 'Thanks for voting',
    blocks: [{ type: 'section', text: { type: 'mrkdwn', text: '*Voted!*' } }],
  })
})

app.start(3000)

Cairn supports a subset of the Slack API. See Differences from Slack for the supported methods and blocks and for behaviour that differs.

Scopes and permissions

Scope names follow Slack.

ScopeAllows
chat:writePosting to channels the bot is in, and updating or deleting its own messages
users:readReading the ID, display name and avatar of active workspace members
channels:readListing the members of channels the bot is in
  • auth.test, views.open and views.update need no scope (a modal can only be opened while a trigger_id issued by a member’s action is valid)
  • Receiving interactions is enabled by registering a Request URL, not by a scope
  • Workspace owners and admins install and uninstall apps
  • Any member with access to a channel can add the bot to it or remove it. Bots cannot be added to DMs
  • Anyone who can read the channel (guests included) can use its cards. Deactivated members cannot

Tokens and IDs

  • Bot tokens start with cairn_bot_ (not Slack’s xoxb-). Send them in an Authorization: Bearer <token> header or as a token field in the body
  • Workspace, user, channel and message IDs are UUIDs. A message’s ts is also the message UUID (not Slack’s 1700000000.000100 format)
  • IDs may move to a more Slack-like format in the future. So that you can keep reading UUIDs when that happens, payloads also carry them in a Cairn-specific cairn object

In this guide