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:
name: support
mode: text
llm: llm-fast
connectors:
- name: slack_bot
connection: acme-workspace # the label of your Slack bot connectionslack_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 six steps:
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.
Save the app's client
Give Stream the Slack app's Client ID, App ID (such as A012ABCD0A0), Client Secret and Signing Secret. The two secrets go on stdin, the Client Secret first:
curl -fsSL https://getstream.io/cli/beta/install.sh | bash # the agents commands are in the beta CLI
printf '%s\n%s\n' "$SLACK_CLIENT_SECRET" "$SLACK_SIGNING_SECRET" | getstream agents connectors client set slack_bot \
--client-id "$SLACK_CLIENT_ID" --provider-app-id A012ABCD0A0 --client-secret - --signing-secret -Redirect URI (add it at the provider): https://router.example.com/v1/agents/connectors/oauth/callback
Saved the OAuth client for slack_botDo this before step 4: Slack checks the Request URL at once, and Stream needs the signing secret to answer.
Add the redirect URI
Copy the redirect URI the CLI printed into the Slack app's OAuth & Permissions > Redirect URLs.
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.
Install the bot
In the Stream Dashboard, go to Agents > Library > Connectors, open Slack bot and click Create connection. Owner starts on Signed-in user: pick App. Type acme-workspace in Label, then click Create connection. Slack's consent opens in a pop-up. The connection stays pending until you allow it there.
Sync the agent
getstream agents sync supportTest 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.
In the Dashboard
Steps 2 and 3 work in the Dashboard too. In the Stream Dashboard, go to Agents > Library > Connectors and open Slack bot.
- Click Set OAuth client. The dialog shows the Redirect URI: copy it into the Slack app's OAuth & Permissions > Redirect URLs.
- Fill Client ID, Client secret, Provider app ID with the App ID, and Signing secret. Leave Token endpoint authentication on Connector default, then click Save client.
With the API
Your server can save the client instead of the CLI. $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.