Agent Guidebook
Connect your Agent
Add to Slack

Add your agent to Slack

You can add your agent to Slack as a bot

Use the SlackTransport Mixin (opens in a new tab) to connect your agent to a Slack Bot.

A full working example is here (opens in a new tab). You can copy and paste this agent into your api.py file or use it as a reference.

Mixins

A Mixin is just a way to add a bundle of functionality to your AgentService. Mixins can include new API endpoints, async processing pipelines, and webhooks.

Adding the SlackTransport Mixin

  1. Add SlackTransport to the static USED_MIXIN_CLASSES list in your AgentService
  2. Register SlackTransport in your AgentService __init__ with
    self.add_mixin(SlackTransport(
        self.client,
        config=SlackTransportConfig(),
        self,
        self.agent
    ))

Connecting your Steamship Agent to Slack

With your Steamship agent running in either development or production:

  1. Visit the /slack_install_link method of your agent instance. This will generate a URL that will initiate Slack's installation process.
  2. Within the Slack admin console, complete the installation process.
  3. Within the Slack admin console, fetch your Slack API Token
  4. Invoke the /set_slack_access_token method of your agent instance with the body {"token": "YOUR TOKEN"}.
  5. From a Slack chatroom, mention your bot by name. It should respond!

Testing your Slack Connection

Python SDK Version

Version 2.17.18 or later of the Steamship SDK is required for this feature.

To use this version, update your `requirements.txt` file and then run `pip install -r requirements.txt`

You do not need to deploy your agent to test the Slack connection -- you can test with Slack directly from your local machine.

Run ship run local to run a local copy of your Agent with the provided configuration.

⚠️

An ngrok account is required to run ship run local. You can connect your account by running: ngrok config add-authtoken YOUR_NGROK_AUTH_TOKEN

It will automatically create a public URL using Ngrok that enables it to receive Slack notifications. Then follow the instructions above as if it were running in production.

Note that you will have to repeat the entire Slack installation process every time you stop your development server to update your agent's code. For this reason, we recommend testing your agent via the REPL, not Slack and then only testing against Slack just prior to final deployment. There is no need to use Slack in your Agent development loop.

Using your Slack Connection in Production

After deploying, when you create an instance from the web just follow the instructions above.