-
Notifications
You must be signed in to change notification settings - Fork 306
feat: add Slack bot integration for kagent #1017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
cd76e9f to
50c8b0a
Compare
|
cc @peterj @EItanya @yuval-k @ilackarms can I get a review on this? FWIW, i've fully tested this on a Slack enterprise-grid account and this is loosely based off existing patterns I'm currently using for other use cases. The HITL portion is very "basic" atm with regex matching, but is a good starter for using Slack as an approval gate down the road -- using fancier conditions. There are a few minor things that I'd like to wire up, but wanted to make sure this is line with the direction the project is heading towards. |
8789d2e to
fd2d66f
Compare
|
@EItanya can I get a review on this? Not sure which maintainer I should be tagging |
fd2d66f to
aafe032
Compare
adab011 to
f67f765
Compare
| @echo " make test - Run tests (if available)" | ||
| @echo " make lint - Run linting with ruff" | ||
| @echo " make type-check - Run type checking with mypy" | ||
| @echo " make build - Build Docker image" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, defer to the wider audience on sensible defaults.
|
This is a great feature - I got it to work; however, I think this Slack bot should probably be in a separate repo, instead of having it in the main repository. @EItanya what do you think? Also, it would be great starting point (in terms of UX and functionality) for creating a Discord and/or MS Teams bots as well. |
|
@apexlnc how do I continue the conversation with the agent? I see that it creates a thread when using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a couple of comments
You should be able to continue the conversation in the thread. Are you not able to?
Sure, let me know if you want it in another repo, and if so, which repo. @peterj -- btw, a lot of the "magic" happens once this is merged : #1025 i'm also realizing that i didn't push some of my local changes (mostly housekeeping stuff) -- will do that later after some responses to the comments above |
649f677 to
cab2a12
Compare
Adds a production-ready Slack bot that provides a unified interface to interact with Kagent agents through Slack, including full Human-in-the-Loop (HITL) support for tool approvals. Key features: - Socket Mode bot for @mentions and direct messages - Dynamic agent discovery and intelligent routing with keyword-based routing - Real-time streaming responses with HITL approval workflow - RBAC with Slack user group integration - Prometheus metrics with kagent_slackbot namespace prefix - Complete Kubernetes manifests (Deployment, HPA, PDB, RBAC) - Dockerfile for containerized deployment Architecture: - Uses A2A SDK types throughout for type safety and validation - Pydantic models for agent metadata and HITL protocol - Handles both TaskStatusUpdateEvent and TaskArtifactUpdateEvent - Structured DataPart decisions for tool approval workflow - Interactive approval buttons with streaming completion responses The bot integrates with Kagent's A2A protocol via JSON-RPC 2.0 and supports all agent types (Declarative, BYO, etc.). Follows bolt-python async patterns. Addresses maintainer feedback: - Use Pydantic models for agent data validation - Full A2A SDK type integration (not raw dicts) - Metrics namespace prefix for Prometheus - Code formatted with ruff - Default permissions.yaml config provided Signed-off-by: apexlnc <[email protected]>
cab2a12 to
73ceb6c
Compare
@peterj This is probably for the better: bot should only respond to a configurable calls (ie: @kagent kagent) and not by default to any message in the thread created. @apexlnc I'm noticing also the emoji response 👀 are not removed after bot responded - they should be present when bot is processing and removed after bot responded. Also, something nice to steal from Onyx (in the later time) - "continue in kagent" and "I need help from a human"
|
…plication Address reviewer feedback from PR review: - Run ruff formatter on all Python files (all checks pass) - Remove 👀 emoji reaction after bot response completion - Fix Docker build by including config/ directory in image - Reorganize SLACK_SETUP.md to clearly separate Option A (manifest) from Option B (manual setup) Additional code quality improvements: - Extract duplicate button parsing logic to _parse_button_value() helper - Extract duplicate SSE streaming logic to _parse_sse_stream() helper - Replace magic numbers with named constants: * SLACK_TEXT_SUMMARY_LENGTH = 200 * PREVIEW_MAX_LENGTH = 1000 * UPDATE_THROTTLE_SECONDS = 2 - Use existing AGENT_CACHE_TTL constant in main.py - Add emoji removal to all exit paths including errors and HITL flows - Add _remove_reaction() helpers to eliminate further duplication This eliminates ~60 lines of duplicate code and improves maintainability without changing any functionality. Fixes: peterj's review comments on make build, docs, formatting Signed-off-by: apexlnc <[email protected]>
|
Thanks for the feedback @peterj @marcinkubica I believe all the comments have been addressed, but let me know if I missed anything! |





Summary
Production-ready Slack bot integration for the Kagent multi-agent platform. Provides a unified Slack interface to interact with multiple AI agents through DMs and channel mentions.
Features
Core Functionality
/api/agentswith 5-minute cachingUser Experience
/agentsto list,/agent-switchto manually select agentsSecurity & RBAC
Architecture
Testing
Tested locally with kagent deployment using Socket Mode in DM-only configuration.