Skip to main content

A Python adapter for integrating Google Agent Development Kit (ADK) agents with Slack

Project description

ADK Slack Adapter

A Python library for integrating Google Agent Development Kit (ADK) agents with Slack through Socket Mode. This adapter enables seamless communication between your ADK-powered AI agents and Slack workspaces.

Features

  • Real-time Communication: Uses Slack Socket Mode for instant message processing
  • Thread-aware Conversations: Maintains conversation context within Slack threads
  • Session Management: Automatic session handling per user and thread
  • Streaming Responses: Real-time streaming of agent responses to Slack
  • Flexible Configuration: Environment-based configuration with validation
  • Event Filtering: Smart handling of direct messages, mentions, and thread replies

Installation

Install from PyPI:

pip install adk-slack-adapter

Or with uv:

uv add adk-slack-adapter

Quick Start

1. Setup Slack App

Create a Slack app with the following settings:

  • Socket Mode: Enabled
  • Bot Token Scopes: chat:write, channels:read, groups:read, im:read, mpim:read
  • Event Subscriptions: message.channels, message.groups, message.im, message.mpim, app_mention

2. Environment Variables

Set the required environment variables:

export SLACK_BOT_TOKEN="xoxb-your-bot-token"
export SLACK_APP_TOKEN="xapp-your-app-token"  
export SLACK_BOT_USER_ID="U01234567"
export ADK_APP_NAME="my-adk-agent"  # optional
export LOGGING_LEVEL="INFO"  # optional

3. Basic Usage

import asyncio
from google.adk.agents import Agent
from adk_slack_adapter import AdkSlackAppRunner

# Create your ADK agent
agent = Agent(
    # Your agent configuration
)

# Create and start the Slack adapter
async def main():
    runner = AdkSlackAppRunner(agent_instance=agent)
    await runner.start()

if __name__ == "__main__":
    asyncio.run(main())

4. Advanced Configuration

from adk_slack_adapter import AdkSlackAppRunner, AdkSlackConfig

# Custom configuration
config = AdkSlackConfig(
    slack_bot_token="xoxb-your-token",
    slack_app_token="xapp-your-token", 
    slack_bot_user_id="U01234567",
    adk_app_name="my-custom-agent",
    logging_level="DEBUG"
)

runner = AdkSlackAppRunner(
    agent_instance=agent,
    config=config
)

How It Works

The adapter follows a layered architecture:

  1. SlackAdapter: Handles Slack Socket Mode connection and events
  2. SlackEventProcessor: Filters and processes relevant messages
  3. InteractionFlow: Orchestrates message flow between Slack and ADK
  4. AdkAdapter: Manages ADK agent sessions and streaming responses

Message Flow

  1. User sends message in Slack (DM, mention, or thread reply)
  2. SlackAdapter receives event via Socket Mode
  3. SlackEventProcessor filters relevant messages
  4. InteractionFlow coordinates with AdkAdapter
  5. AdkAdapter streams responses from ADK agent
  6. Responses are sent back to Slack in real-time

Session Management

  • Sessions are created per Slack thread: slack_{user_id}_{thread_id}
  • Uses ADK's built-in session management for conversation continuity
  • Automatic cleanup and memory management

Event Handling

The adapter intelligently handles different types of Slack events:

  • Direct Messages: Processes all DMs automatically
  • Channel Mentions: Responds when bot is @mentioned
  • Thread Conversations: Continues conversations in threads where bot was initially mentioned
  • Bot Loop Prevention: Ignores bot's own messages

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/ktagashira/adk-slack-adapter.git
cd adk-slack-adapter

# Install dependencies
uv sync

# Install development dependencies
uv sync --group dev

Running Tests

uv run pytest

Code Quality

# Format code
uv run black .
uv run isort .

# Lint code  
uv run ruff check .

# Type checking
uv run mypy .

Requirements

  • Python 3.11+
  • Google Agent Development Kit (ADK) 1.2.1+
  • Slack Bolt SDK 1.23.0+

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For questions and support:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adk_slack_adapter-0.2.1.tar.gz (222.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adk_slack_adapter-0.2.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file adk_slack_adapter-0.2.1.tar.gz.

File metadata

  • Download URL: adk_slack_adapter-0.2.1.tar.gz
  • Upload date:
  • Size: 222.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for adk_slack_adapter-0.2.1.tar.gz
Algorithm Hash digest
SHA256 cc97d5b6f999ed9c0c4bdfc38bff02bfb1210fc54d1adeebed76f15f19d429c5
MD5 055dff0eab5b5e1fb1d0da53200fd263
BLAKE2b-256 7dd4ae922b78e012f36a638c53198832e8439dc6f3921bd472b68ef4f1dbe345

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_slack_adapter-0.2.1.tar.gz:

Publisher: publish.yml on ktagashira/adk-slack-adapter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adk_slack_adapter-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for adk_slack_adapter-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f02f767ad0c19e7f8d2ab9f0576324d3be0a31a929bacba8d61f286d1c7adfa
MD5 2d91b51c243a3de3cd2487c130bf87cd
BLAKE2b-256 5719542ae653c2f564ec9084018ab9ae52da5c21d9913ad3ad0685114cd1d17a

See more details on using hashes here.

Provenance

The following attestation bundles were made for adk_slack_adapter-0.2.1-py3-none-any.whl:

Publisher: publish.yml on ktagashira/adk-slack-adapter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page