> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-naomid-1770324835-64a7eea.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect an agent to Slack

> Set up bidirectional communication between your agent and a Slack channel.

This guide shows you how to connect an agent to Slack so it can:

* **Listen** to messages in a Slack channel (via a trigger)
* **Respond** in Slack (via Slack tools)

By the end, you'll have an agent that automatically responds when users message in your Slack channel.

## Prerequisites

* An existing agent in Agent Builder (see [Quickstart](/langsmith/agent-builder-quickstart) to create one)
* Admin access to a Slack workspace, or permission to install apps

## Step 1: Connect to Slack

First, authorize LangSmith to access your Slack workspace and invite the bot to your channel.

<Steps>
  <Step title="Open your agent">
    1. In LangSmith, navigate to **Agent Builder**.
    2. Select your agent from **My Agents**.
    3. Click <Icon icon="pencil" /> **Edit Agent**.
  </Step>

  <Step title="Start adding the Slack trigger">
    1. Scroll down to the **Triggers** section.
    2. Click **+ Add trigger**.
    3. Select **Slack - Message Received**.
  </Step>

  <Step title="Authorize Slack">
    1. Click **Connect** to authorize the Slack connection.
    2. Sign in to your Slack workspace.
    3. Review the permissions and click **Allow**.
    4. You'll be redirected back to LangSmith.
  </Step>

  <Step title="Invite the bot to your channel">
    Before selecting a channel, invite the bot to the channel you want to use. In Slack, go to that channel and type:

    ```txt theme={null}
    /invite @LangSmith Agent Builder
    ```
  </Step>

  <Step title="Select the channel">
    1. Back in LangSmith, choose the Slack channel you invited the bot to.
    2. Click **Save**.
  </Step>
</Steps>

Your agent will now be triggered whenever a message is posted in that channel.

## Step 2: Add Slack tools

Tools let your agent take actions. To respond in Slack, you need to add Slack tools.

<Tip>
  You can also ask your agent to add these tools itself! In the agent chat, try: "Add the Slack tools so you can respond to messages."
</Tip>

<Steps>
  <Step title="Add Slack tools">
    1. In the agent editor, scroll to the **Tools** section.
    2. Click **+ Add tool**.
    3. Search for "Slack" and add the tools you need:
       * **slack\_send\_channel\_message** - Post messages to a channel
       * **slack\_reply\_to\_message** - Reply in a thread
       * **slack\_write\_private\_message** - Send direct messages
       * **slack\_read\_channel\_history** - Read recent messages
       * **slack\_read\_thread\_messages** - Read thread replies
  </Step>

  <Step title="Authorize tools (if needed)">
    If prompted, click **Connect** to authorize the Slack tools. This may use the same authorization from Step 1.
  </Step>

  <Step title="Save your agent">
    Click **Save changes** to save your agent configuration.
  </Step>
</Steps>

## Step 3: Configure agent behavior (optional)

Your agent needs to know how to handle incoming Slack messages. You can update its instructions by prompting it directly.

In the agent chat, try something like:

```
Update your instructions to handle the Slack Trigger and Slack Tools
for bidirectional communication
```

Adjust the instructions based on your use case - for example, you might want the agent to only respond to certain types of questions, or to pull information from specific sources before replying.

## Step 4: Test the integration

<Steps>
  <Step title="Send a test message">
    In your Slack channel, send a message to test the agent:

    > *Hello, can you help me?*
  </Step>

  <Step title="Verify the response">
    Your agent should respond in the channel. You can view the agent's activity in the **Feed** tab in Agent Builder.
  </Step>

  <Step title="Troubleshoot if needed">
    If your agent doesn't respond:

    * Verify the bot was invited to the channel
    * Check the **Feed** tab for any errors
    * Ensure the trigger is not paused (check the toggle in the Triggers section)
  </Step>
</Steps>

## How it works

When a message is posted in your monitored Slack channel:

1. Slack sends an event to LangSmith
2. The trigger activates your agent with the message content
3. Your agent processes the message and uses Slack tools to respond
4. The response appears in Slack (in the same thread if replying to a thread)

Your agent receives the full thread context when responding to threaded messages, so it can provide contextually relevant responses.

## Next steps

<CardGroup cols={2}>
  <Card title="Slack app reference" icon="slack" href="/langsmith/agent-builder-slack-app">
    Learn about permissions and privacy
  </Card>

  <Card title="Add more tools" icon="puzzle-piece" href="/langsmith/agent-builder-tools">
    Connect additional services to your agent
  </Card>

  <Card title="Add more triggers" icon="bolt" href="/langsmith/agent-builder-essentials#triggers">
    Set up email, schedule, or webhook triggers
  </Card>

  <Card title="Use templates" icon="shapes" href="/langsmith/agent-builder-templates">
    Start from a pre-built agent template
  </Card>
</CardGroup>

***

<Callout icon="pen-to-square" iconType="regular">
  [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/connect-agent-to-slack.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
</Callout>

<Tip icon="terminal" iconType="regular">
  [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
</Tip>
