# SlackToolkit

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/agent_toolkits/slack/toolkit/SlackToolkit)

Toolkit for interacting with Slack.

## Signature

```python
SlackToolkit()
```

## Description

**Setup:**

Install ``slack_sdk`` and set environment variable ``SLACK_USER_TOKEN``.

.. code-block:: bash

    pip install -U slack_sdk
    export SLACK_USER_TOKEN="your-user-token"

**Key init args:**

client: slack_sdk.WebClient
The Slack client.

**Instantiate:**

.. code-block:: python

from langchain_community.agent_toolkits import SlackToolkit

# Using environment variables (default)
toolkit = SlackToolkit()

# Or with an existing WebClient instance
from slack_sdk import WebClient
client = WebClient(token="your-user-token")
toolkit = SlackToolkit(client=client)

**Tools:**

.. code-block:: python

    tools = toolkit.get_tools()
    tools

.. code-block:: none

    [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>)]

**Use within an agent:**

.. code-block:: python

    from langchain_openai import ChatOpenAI
    from langgraph.prebuilt import create_react_agent

    llm = ChatOpenAI(model="gpt-4o-mini")
    agent_executor = create_react_agent(llm, tools)

    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()

.. code-block:: none

     ================================[1m Human Message [0m=================================

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

    The #general channel was created on timestamp 1671043305.

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `client` | `unknown` | Yes | The Slack client. |

## Extends

- `BaseToolkit`

## Properties

- `client`
- `model_config`

## Methods

- [`get_tools()`](https://reference.langchain.com/python/langchain-community/agent_toolkits/slack/toolkit/SlackToolkit/get_tools)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/4b280287bd55b99b44db2dd849f02d66c89534d5/libs/community/langchain_community/agent_toolkits/slack/toolkit.py#L26)