A Slack bot application that enables seamless communication between Slack users and Kentik's AI Advisor REST API. Users can ask questions about their network by mentioning the bot (@kentik) in Slack channels or sending direct messages.
- Natural Interaction: Use
@kentikmentions in channels or send direct messages - Slack Assistant Mode: Access AI Advisor through Slack's native assistant panel
- Thread-based Conversations: Responses appear in threads, maintaining conversation context
- Conversation Continuity: Follow-up questions in threads continue the same AI Advisor session
- Context-Aware: When starting a conversation in an existing thread, includes context from previous messages
- Asynchronous Processing: Handles AI Advisor's asynchronous response pattern with polling
- Persistent Storage: SQLite database maintains mapping between Slack threads and AI Advisor sessions
- Python 3.10 or higher
- UV package manager
- Slack workspace with admin access
- Kentik account with API credentials
- Slack app configured with appropriate permissions
- Clone the repository:
git clone <repository-url>
cd kentik-ai-advisor-slackbot- Install UV if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh- Create virtual environment and install dependencies:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv sync --all-extras- Go to Slack API and click "Create New App"
- Choose "From manifest"
- Paste the example manifest from below and create the app
display_information:
name: Kentik
description: AI-powered network analysis assistant
background_color: "#333436"
features:
app_home:
home_tab_enabled: false
messages_tab_enabled: true
messages_tab_read_only_enabled: false
assistant_view:
assistant_description: Ask questions about your network using Kentik's AI Advisor
bot_user:
display_name: kentik
always_online: true
oauth_config:
scopes:
bot:
- app_mentions:read
- channels:history
- channels:read
- chat:write
- im:history
- im:read
- im:write
- assistant:write
settings:
event_subscriptions:
bot_events:
- app_mention
- message.im
- assistant_thread_started
- assistant_thread_context_changed
interactivity:
is_enabled: true
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: false- Go to "Settings → Install App"
- Click "Install to Workspace"
- Authorize the app
- Copy the "Bot User OAuth Token" as
SLACK_BOT_TOKENfor your.envfile. See Configuration section for details.
- Go to "Settings → Basic Information"
- Scroll down to "App-Level Tokens"
- Click "Generate Token and Scopes"
- Add
connections:writescope - Copy the generated token as
SLACK_APP_TOKENfor your.envfile. See Configuration section for details.
- Copy the example environment file:
cp .env.example .env- Edit
.envwith your credentials:
# Slack Configuration
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-token
# Kentik API Configuration
KENTIK_API_URL=https://grpc.api.kentik.com # or https://grpc.api.kentik.eu
KENTIK_API_EMAIL=your-email@company.com
KENTIK_API_TOKEN=your-api-token
# Optional Configuration
THREAD_CONTEXT_MESSAGES=5
POLLING_INTERVAL_SECONDS=2
POLLING_TIMEOUT_SECONDS=120
CONVERSATIONS_DB_PATH=conversations.db- Log into Kentik Portal
- Click your profile (top-right)
- Go to "Authentication" tab
- Copy your API Token
| Variable | Required | Default | Description |
|---|---|---|---|
SLACK_BOT_TOKEN |
Yes | - | Slack Bot User OAuth Token |
SLACK_APP_TOKEN |
Yes | - | Slack App-Level Token |
KENTIK_API_URL |
Yes | - | Kentik API URL (US/EU cluster) |
KENTIK_API_EMAIL |
Yes | - | Kentik account email |
KENTIK_API_TOKEN |
Yes | - | Kentik API token |
THREAD_CONTEXT_MESSAGES |
No | 5 | Number of previous messages to include as context |
POLLING_INTERVAL_SECONDS |
No | 2 | Polling interval in seconds (min: 2) |
POLLING_TIMEOUT_SECONDS |
No | 120 | Max wait time for AI response in seconds |
CONVERSATIONS_DB_PATH |
No | conversations.db | Path to SQLite database file |
uv run kentik-ai-advisor-slackbotRun the container:
docker run -d --restart unless-stopped \
--name kentik-ai-advisor-slackbot \
-e SLACK_BOT_TOKEN='xoxb-your-token' \
-e SLACK_APP_TOKEN='xapp-your-token' \
-e KENTIK_API_URL='https://grpc.api.kentik.com' \
-e KENTIK_API_EMAIL='your-email@company.com' \
-e KENTIK_API_TOKEN='your-api-token' \
kentik/ai-advisor-slackbot:latestOr use a .env file:
docker run -d --restart unless-stopped \
--name kentik-ai-advisor-slackbot \
--env-file .env \
-v $(pwd)/conversations.db:/app/conversations.db \
kentik/ai-advisor-slackbot:latest- User mentions bot in channel:
@kentik show me top talkers - Bot creates new AI Advisor session
- Response posted in thread
- Thread/session mapping saved to database
- User replies in thread:
@kentik what about the last 24 hours? - Bot retrieves existing session ID from database
- Updates AI Advisor session with follow-up question
- Maintains conversation context
- User mentions bot in thread not started by bot
- Bot creates new session with context:
- First message in thread
- Previous 5 messages (configurable)
- Response posted in same thread
- User sends DM to bot
- Treated as new conversation
- No threading (DMs don't support threads)
- User opens Kentik AI Advisor from Slack's assistant panel
- Suggested prompts help users get started
- Conversations persist across sessions using thread timestamps
- Full AI Advisor capabilities available through the native assistant UI
The bot maintains a SQLite database (conversations.db) that maps:
- Slack thread timestamp → AI Advisor session UUID
- Channel ID for reference
- Created/updated timestamps
This allows the bot to:
- Continue conversations across multiple questions
- Maintain conversation history
- Support multiple concurrent conversations
The bot handles AI Advisor's asynchronous pattern:
- Submit question (POST/PUT)
- Receive session ID and PENDING status
- Poll every 2 seconds (GET)
- Wait for COMPLETED or FAILED status
- Process and format response
- Post to Slack
- Check bot is running:
docker logs kentik-ai-advisor-slackbot - Verify Socket Mode is enabled in Slack app settings
- Ensure
SLACK_APP_TOKENandSLACK_BOT_TOKENare correct - Check bot has
app_mentions:readscope
- Check database file exists and is writable
- Verify thread timestamps are consistent
- Check logs for database errors
- Increase
POLLING_TIMEOUT_SECONDS(default: 120s) - Check Kentik API credentials are valid
- Verify network connectivity to Kentik API
AI Advisor has rate limits:
- 4 requests/minute for create/update
- 60 requests/minute for get
The bot respects these limits with 2-second polling intervals.
For issues and questions:
- GitHub Issues: this repository
- Kentik Support: https://support.kentik.com