Slack runner for ADK¶
Supported in ADKPython
ADK provides the SlackRunner class to easily deploy your agents directly on Slack using Socket Mode. This integration acts as an adapter that handles event listening, response dispatching, and automated conversation thread management.
Use cases¶
- Socket Mode deployment: Route workspace events securely to your agent without exposing public HTTP endpoints.
- Thread management: Maintain continuous conversation context across direct messages and nested thread replies.
- Event-driven triggers: Activate agent workflows automatically using direct messages or app mentions.
Prerequisites¶
- A Slack App configured in your Slack API Dashboard. You must sign in to your Slack account first.
- A Bot User OAuth Token (
xoxb-...) withapp_mentions:read,chat:write, andim:historybot token scopes. - A Websocket App-Level Token (
xapp-...) with theconnections:writescope.
Installation¶
Use with agent¶
import asyncio
import os
from google.adk.agents import Agent
from google.adk.runners import Runner
from google.adk.integrations.slack import SlackRunner
from slack_bolt.app.async_app import AsyncApp
# Define the core agent
root_agent = Agent(
model="gemini-flash-latest",
name="slack_agent",
instruction="You are a helpful team assistant running on Slack.",
)
#Wire it up to Slack over Socket Mode
runner = Runner(
app_name="slack_agent",
agent=root_agent,
session_service=InMemorySessionService(),
)
slack_app = AsyncApp(token=os.environ["SLACK_BOT_TOKEN"])
slack_runner = SlackRunner(runner, slack_app)
asyncio.run(slack_runner.start(os.environ["SLACK_APP_TOKEN"]))
Available tools¶
| Tool | Description |
|---|---|
__init__(runner, slack_app) |
Starts the Slack runner adapter with an ADK Runner and a Slack AsyncApp. |
start(app_token) |
Starts the Slack runner listener in Socket Mode using your app-level websocket token. |