Skip to navigation

Slack integration

Install Living Brain in a Slack workspace and route brain notifications to channels.

Connecting Slack takes three steps: install the Slack app with OAuth, pick a channel, and choose which notifications it receives. Every call is scoped to a brain.

Install with OAuth

Installation is a browser redirect. Start OAuth to get a signed authorization URL, send the user to it, then confirm with the code and state Slack returns to your redirect URL.

const { authorizationUrl, expiresAt } = await client.slack.startOauth({ brainId });
// Redirect the user to authorizationUrl before expiresAt.
// In your OAuth callback handler:
const { installationId } = await client.slack.confirmOauth({ brainId, code, state });

The state value is signed and expires at expiresAt. Pass it back unchanged; an expired or altered state is rejected.

Check status

status returns every Slack workspace installed for the brain, plus its channel bindings.

const { installations, bindings } = await client.slack.status({ brainId });

Bind a channel

List the channels the bot can see in an installation, then bind one to the brain. isMember tells you whether the bot has already been added to the channel.

const channels = await client.slack.channels({ brainId, installationId });
const binding = await client.slack.bind({
brainId,
installationId,
channelId: channels[0].id,
});

Choose notifications

A binding can post daily briefs, new connections, and page changes. Fields you leave out are unchanged.

await client.slack.updateBinding({
brainId,
bindingId: binding.id,
notifyBriefs: true,
notifyConnections: false,
notifyChanges: true,
});

Disconnect

unbind removes one channel binding. disconnectInstallation removes the whole Slack workspace from the brain, along with all of its bindings.

await client.slack.unbind({ brainId, bindingId });
await client.slack.disconnectInstallation({ brainId, installationId });