Slack

It's common to want your agent in your team's Slack. For instance, your support team can @mention it in a channel, and it answers in the thread.

Answer in Slack

Use the slack_bot connector with the workspace the bot is installed in:

agents/support/agent.yaml
name: support
mode: text
llm: llm-fast
connectors:
  - name: slack_bot
    connection: acme-workspace # the label of your Slack bot connection

slack_bot gives the agent no tools. For Slack tools, such as searching the workspace, use the slack connector.

The bot is a Slack app of your own, in a workspace where you can create apps. Setting it up takes five steps:

  1. Create the Slack app. At api.slack.com/apps, create an app named Acme Support in your workspace. Under OAuth & Permissions, add the bot scopes chat:write, channels:history and im:history. Under App Home, turn on the Messages Tab.
  2. Add the redirect URI. On the Stream Dashboard, open Library > Connectors, then Slack bot. Its OAuth client section shows the Redirect URI. Copy it into the Slack app's OAuth & Permissions > Redirect URLs.
  3. Save the app's client. On the same page, choose Set OAuth client and enter the Slack app's Client ID, Client Secret, App ID (as Provider app ID, such as A012ABCD0A0) and Signing Secret. Do this before step 4: Slack checks the Request URL at once, and Stream needs the signing secret to answer.
  4. Turn on events. In the Slack app's Event Subscriptions, turn events on and set the Request URL: the redirect URI with /v1/agents/connectors/oauth/callback replaced by /v1/connectors/events/slack_bot/ and your Slack App ID. For a redirect URI of https://router.example.com/v1/agents/connectors/oauth/callback, that is https://router.example.com/v1/connectors/events/slack_bot/A012ABCD0A0. Then add the bot events message.channels, message.im and tokens_revoked.
  5. Install the bot. Back on the Slack bot connector, choose Create connection, with App as the owner and acme-workspace as the label.

Then sync the agent:

curl -fsSL https://getstream.io/cli/beta/install.sh | bash # the agents commands are in the beta CLI
getstream agents sync support

Test it in Slack itself. Add the bot to a public channel and write: "@Acme Support What is our return policy?". The agent answers in that message's thread. Reply in the thread without the mention, and it answers again. The thread is one conversation, shared by everyone who writes in it.

From your backend

Your backend can save the client instead of the dashboard. $STREAM_ACCELERATION_URL is your router's URL, and $SERVER_TOKEN is a server token. GET /v1/agents/connectors/slack_bot returns the redirect URI as redirect_uri. Then:

curl -X PUT "$STREAM_ACCELERATION_URL/v1/agents/connectors/slack_bot/oauth-client" \
  -H "api_key: $STREAM_API_KEY" -H "stream-auth-type: jwt" \
  -H "Authorization: Bearer $SERVER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"client_id": "...", "client_secret": "...", "provider_app_id": "A012ABCD0A0", "signing_secret": "..."}'

Both secrets are encrypted and never returned.

Limitations

One agent answers per connection. A second agent that uses the same connection is refused.

Going further