src/google/adk/integrations/slack/README.md
The ADK Slack integration provides a SlackRunner to easily deploy your agents
on Slack using Socket Mode.
Install the ADK with Slack support:
pip install "google-adk[slack]"
To use the SlackRunner, you need to set up a Slack App in the
Slack API Dashboard.
In your app settings, go to Socket Mode and toggle Enable Socket Mode to
on.
You will be prompted to generate an App-Level Token (starts with xapp-).
Ensure it has the connections:write scope.
Navigate to OAuth & Permissions and add the following Bot Token Scopes:
app_mentions:read: To receive mention events.chat:write: To send messages.im:history: To respond in Direct Messages.groups:history (Optional): To respond in private channels.channels:history (Optional): To respond in public channels.Go to Event Subscriptions:
on.app_mention: To respond when the bot is mentioned.message.im: To respond in Direct Messages.Install the app to your workspace to obtain the
Bot User OAuth Token (starts with xoxb-).
import asyncio
import os
from google.adk.runners import Runner
from google.adk.integrations.slack import SlackRunner
from slack_bolt.app.async_app import AsyncApp
async def main():
# 1. Initialize your ADK Runner (with your agent)
# runner = Runner(agent=my_agent, session_service=my_session_service)
# 2. Initialize Slack AsyncApp with your Bot Token
slack_app = AsyncApp(token=os.environ["SLACK_BOT_TOKEN"])
# 3. Initialize the SlackRunner
slack_runner = SlackRunner(runner=runner, slack_app=slack_app)
# 4. Start the runner in Socket Mode with your App Token
await slack_runner.start(app_token=os.environ["SLACK_APP_TOKEN"])
if __name__ == "__main__":
asyncio.run(main())
The SlackRunner automatically manages conversation sessions:
channel_id is used as the session ID.channel_id and thread_ts
(the timestamp of the parent message) is used as the session ID to maintain
thread context.ts) is used
with the channel_id to start a new threaded session if the user replies
in-thread.