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

# Slack toolkit integration

> Integrate with the Slack toolkit using LangChain Python.

This will help you get started with the Slack [toolkit](/oss/python/integrations/tools/slack). For detailed documentation of all `SlackToolkit` features and configurations head to the [API reference](https://reference.langchain.com/python/langchain-community/agent_toolkits/slack/toolkit/SlackToolkit).

## Setup

To use this toolkit, you will need to get a token as explained in the [Slack API docs](https://api.slack.com/tutorials/tracks/getting-a-token). Once you've received a SLACK\_USER\_TOKEN, you can input it as an environment variable below.

```python theme={null}
import getpass
import os

if not os.getenv("SLACK_USER_TOKEN"):
    os.environ["SLACK_USER_TOKEN"] = getpass.getpass("Enter your Slack user token: ")
```

To enable automated tracing of individual tools, set your [LangSmith](/langsmith/home) API key:

```python theme={null}
os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")
os.environ["LANGSMITH_TRACING"] = "true"
```

### Installation

This toolkit lives in the `langchain-community` package. We will also need the Slack SDK:

```python theme={null}
pip install -qU langchain-community slack_sdk
```

Optionally, we can install beautifulsoup4 to assist in parsing HTML messages:

```python theme={null}
pip install -qU beautifulsoup4 # This is optional but is useful for parsing HTML messages
```

## Instantiation

Now we can instantiate our toolkit:

```python theme={null}
from langchain_community.agent_toolkits import SlackToolkit

toolkit = SlackToolkit()
```

## Tools

View available tools:

```python theme={null}
tools = toolkit.get_tools()

tools
```

```text theme={null}
[SlackGetChannel(client=<slack_sdk.web.client.WebClient object at 0x113caa8c0>),
 SlackGetMessage(client=<slack_sdk.web.client.WebClient object at 0x113caa4d0>),
 SlackScheduleMessage(client=<slack_sdk.web.client.WebClient object at 0x113caa440>),
 SlackSendMessage(client=<slack_sdk.web.client.WebClient object at 0x113caa410>)]
```

This toolkit loads:

* [SlackGetChannel](https://reference.langchain.com/python/langchain-community/tools/slack/get_channel/SlackGetChannel)
* [SlackGetMessage](https://reference.langchain.com/python/langchain-community/tools/slack/get_message/SlackGetMessage)
* [SlackScheduleMessage](https://reference.langchain.com/python/langchain-community/tools/slack/schedule_message/SlackScheduleMessage)
* [SlackSendMessage](https://reference.langchain.com/python/langchain-community/tools/slack/send_message/SlackSendMessage)

## Use within an agent

Let's equip an agent with the Slack toolkit and query for information about a channel.

```python theme={null}
from langchain_openai import ChatOpenAI
from langchain.agents import create_agent


model = ChatOpenAI(model="gpt-5.4-mini")

agent_executor = create_agent(model, tools)
```

```python theme={null}
example_query = "When was the #general channel created?"

events = agent_executor.stream(
    {"messages": [("user", example_query)]},
    stream_mode="values",
)
for event in events:
    message = event["messages"][-1]
    if message.type != "tool":  # mask sensitive information
        event["messages"][-1].pretty_print()
```

```text theme={null}
================================ Human Message =================================

When was the #general channel created?
================================== Ai Message ==================================
Tool Calls:
  get_channelid_name_dict (call_NXDkALjoOx97uF1v0CoZTqtJ)
 Call ID: call_NXDkALjoOx97uF1v0CoZTqtJ
  Args:
================================== Ai Message ==================================

The #general channel was created on timestamp 1671043305.
```

```python theme={null}
example_query = "Send a friendly greeting to channel C072Q1LP4QM."

events = agent_executor.stream(
    {"messages": [("user", example_query)]},
    stream_mode="values",
)
for event in events:
    message = event["messages"][-1]
    if message.type != "tool":  # mask sensitive information
        event["messages"][-1].pretty_print()
```

```text theme={null}
================================ Human Message =================================

Send a friendly greeting to channel C072Q1LP4QM.
================================== Ai Message ==================================
Tool Calls:
  send_message (call_xQxpv4wFeAZNZgSBJRIuaizi)
 Call ID: call_xQxpv4wFeAZNZgSBJRIuaizi
  Args:
    message: Hello! Have a great day!
    channel: C072Q1LP4QM
================================== Ai Message ==================================

I have sent a friendly greeting to the channel C072Q1LP4QM.
```

***

## API reference

For detailed documentation of all `SlackToolkit` features and configurations head to the [API reference](https://reference.langchain.com/python/langchain-community/agent_toolkits/slack/toolkit/SlackToolkit).

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/tools/slack.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
