docs/content/cookbooks/slack-summariser.mdx
This cookbook builds a standalone Python script that connects to a Slack workspace, fetches recent messages from a channel, and summarizes the key topics, decisions, and action items. We'll use scoped sessions to limit the agent to Slack tools only.
Create a new project and install dependencies:
mkdir composio-slack-summarizer && cd composio-slack-summarizer
uv init && uv add composio composio-openai-agents openai-agents
Add your API keys to a .env file:
COMPOSIO_API_KEY=your_composio_api_key
OPENAI_API_KEY=your_openai_api_key
Composio takes an OpenAIAgentsProvider so that tools come back in the format the OpenAI Agents SDK expects.
<include>../../examples/slack-summariser/main.py#setup</include>
Before summarizing, we need to make sure the user has connected their Slack workspace. The connect function creates a scoped session with toolkits=["slack"] and checks the connection status via session.toolkits(). If Slack is not connected, session.authorize("slack") starts the OAuth flow and returns a URL for the user to visit. wait_for_connection() blocks until they complete it.
<include>../../examples/slack-summariser/main.py#connect</include>
With Slack connected, the summarize function creates a session and grabs the tools. We hand them to an agent with focused summarization instructions. Runner.run_sync handles the agentic loop: the agent calls the Slack tool to fetch messages and produces a summary.
<include>../../examples/slack-summariser/main.py#summarize</include>
Here is everything together:
<include>../../examples/slack-summariser/main.py</include>
First, connect your Slack workspace:
uv run --env-file .env python main.py connect default
If Slack is not connected yet, you'll get an OAuth URL. Open it in your browser and authorize the app. If you've already connected, the script will print "Slack is already connected."
Then run the summarizer:
uv run --env-file .env python main.py summarize default general
Replace general with any channel name you want to summarize.
The summarizer reads from one channel, but the same pattern scales to broader workflows:
#daily-summary channel