---
title: "Summarise Slack with LangGraph | EnConvert"
description: "Summarise Slack canvas pages inside a LangGraph agent with EnConvert Distill, which returns schema-defined fields for up to 50 URLs in one synchronous call"
canonical: "https://www.enconvert.com/solutions/summarise-slack-with-langgraph-enconvert"
locale: "en"
---

# How to Summarise Slack with LangGraph

A developer building a LangGraph agent that processes team communications needs structured content from Slack before the agent can surface decisions, action items, or unresolved threads. Slack pages mix message threads, participant names, reaction counts, channel metadata, and interface chrome in a layout that returns no clean structured text when fetched directly, and the Slack API requires a bot token with channel-specific scope grants before message content can be read programmatically. EnConvert Distill accepts a Slack page URL that opens without signing in, applies a schema the agent defines, and returns structured fields in one synchronous call. The agent gets schema-defined communication content ready for downstream reasoning with no Slack API token, for pages that are publicly accessible.

## Example

```python
import os

import requests
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langgraph.graph import START, MessagesState, StateGraph
from langgraph.prebuilt import ToolNode, tools_condition

# ChatOpenAI reads OPENAI_API_KEY from the environment
SLACK_PAGE_URL = os.environ["SLACK_PAGE_URL"]  # a public Slack canvas or archive page

BASE_URL = "https://api.enconvert.com/v2"
headers = {
    "X-API-Key": os.environ["ENCONVERT_API_KEY"],
    "Content-Type": "application/json",
}

# The fields the agent receives. The response keys match these names exactly.
# Each description tells the extractor to leave a field empty rather than guess.
SLACK_SCHEMA = {
    "channel_name": "The channel name shown on the page",
    "summary": (
        "A three sentence summary of the conversation, using only messages visible on the page. "
        "Return an empty string if no messages are visible."
    ),
    "key_decisions": (
        "Decisions that are stated in the messages, as a list. "
        "Return an empty list if none are stated or no messages are visible."
    ),
    "action_items": (
        "Action items stated in the messages, as a list, naming an owner only if a message names one. "
        "Return an empty list if none are stated or no messages are visible."
    ),
    "participants": (
        "The display names of people who posted visible messages, as a list. "
        "Return an empty list if no messages are visible."
    ),
    "date_range": "The earliest and latest message dates visible on the page, as written",
}

def as_text(value) -> str:
    if isinstance(value, list):
        return "; ".join(str(item) for item in value) or "not stated"
    return str(value) if value else "not stated"

@tool
def summarise_slack_pages(urls: list[str]) -> str:
    """Reads publicly accessible Slack pages and returns structured fields for each: channel,
    summary, decisions, action items, participants, and date range. Accepts up to 50 URLs.
    Private workspace channels behind a login cannot be read."""
    if len(urls) > 50:
        return "Too many URLs. Distill accepts at most 50 per call."

    # One synchronous call: no job_id, no polling, no download step
    response = requests.post(
        f"{BASE_URL}/distill",
        headers=headers,
        json={"urls": urls, "schema": SLACK_SCHEMA},
        timeout=300,
    )

    # Distill runs on paid plans only, and the free tier returns 402
    if response.status_code == 402:
        return "Distill requires a paid plan."
    response.raise_for_status()

    pages = []
    for result in response.json()["results"]:
        if result["status"] != "completed":
            pages.append(f"Source: {result['url']}\nCould not be read ({result['status']}).")
            continue

        # A low render_quality means a workspace login wall, which private channels sit behind
        render_quality = result.get("render_quality", 1.0)
        if render_quality < 0.5:
            pages.append(
                f"Source: {result['url']}\nLow render quality ({render_quality}), "
                "likely a workspace login page. Skipped."
            )
            continue

        data = result["data"]  # keys match SLACK_SCHEMA exactly

        # No summary means no messages were read, so do not report an empty record
        if not data.get("summary"):
            pages.append(f"Source: {result['url']}\nNo messages were found on the page.")
            continue

        pages.append(
            f"Source: {result['url']}\n"
            f"Channel: {as_text(data['channel_name'])}\n"
            f"Dates: {as_text(data['date_range'])}\n"
            f"Participants: {as_text(data['participants'])}\n"
            f"Key decisions: {as_text(data['key_decisions'])}\n"
            f"Action items: {as_text(data['action_items'])}\n"
            f"Summary: {data['summary']}"
        )
    return "\n\n---\n\n".join(pages)

tools = [summarise_slack_pages]
llm = ChatOpenAI(model="gpt-4.1").bind_tools(tools)

def agent_node(state: MessagesState):
    return {"messages": [llm.invoke(state["messages"])]}

# The graph: the agent calls the tool when it needs a page, then writes its answer
builder = StateGraph(MessagesState)
builder.add_node("agent", agent_node)
builder.add_node("tools", ToolNode(tools))
builder.add_edge(START, "agent")
builder.add_conditional_edges("agent", tools_condition)  # routes to "tools" or ends
builder.add_edge("tools", "agent")
graph = builder.compile()

result = graph.invoke(
    {
        "messages": [
            (
                "system",
                "You summarise team conversations. Use summarise_slack_pages to read the pages "
                "you need, report only what the tool returns, and cite the page URL for every "
                "statement. If a field is not stated, say so and do not guess.",
            ),
            (
                "user",
                f"Read {SLACK_PAGE_URL} and list the decisions "
                "that were made and any action items, naming an owner only where the messages do.",
            ),
        ]
    }
)
print(result["messages"][-1].content)
```

## Output

Distill returns schema-defined fields inline as structured JSON in the data object, with no polling and no job_id. The render_quality score lets the agent detect a workspace login wall before it reasons over incomplete content, and private channels that need Slack authentication come back with a low render quality and are skipped. Reading Slack content through the API requires a bot token with channel-specific scope grants and separate endpoint calls for messages and thread replies, while Distill returns schema-defined fields from the shared page URL in one call.

## Get started

[Get free API key — 500 ops per month, no card required. Note: Distill runs on paid plans. Free tier returns 402.](https://www.enconvert.com/auth?mode=signup)

## Related solutions

- [How to Summarise GitHub with Pydantic AI](https://www.enconvert.com/solutions/summarise-github-with-pydantic-ai-enconvert.md)
- [How to Summarise Google Docs with LangGraph](https://www.enconvert.com/solutions/summarise-google-docs-with-langgraph-enconvert.md)
- [How to Summarise GitHub with LlamaIndex](https://www.enconvert.com/solutions/summarise-github-with-llamaindex-enconvert.md)
- [How to Summarise Google Docs with Pydantic AI](https://www.enconvert.com/solutions/summarise-google-docs-with-pydantic-ai-enconvert.md)
- [How to Summarise YouTube Transcripts with LlamaIndex](https://www.enconvert.com/solutions/summarise-youtube-transcripts-with-llamaindex-enconvert.md)
- [How to Summarise GitHub Issues with CrewAI](https://www.enconvert.com/solutions/summarise-github-issues-with-crewai-enconvert.md)
