Overview
TheSlackApp
class provides a clean interface for running Tyler agents as Slack bots with intelligent message routing, thread management, and health monitoring.
Creating a SlackApp
Key Parameters
The Tyler agent that will handle conversations
ThreadStore instance for conversation persistence across Slack channels
FileStore instance for handling file uploads and attachments
Simple sentence describing what topics the bot should respond to. Used for intelligent message filtering when the bot is in channels.
Environment Variables
SlackApp requires these environment variables to be set:Bot User OAuth Token (starts with
xoxb-
)App-level token for Socket Mode (starts with
xapp-
)OpenAI API key for the agent (or other LLM provider keys)
URL to ping for health monitoring
Interval in seconds between health check pings
Weights & Biases project name for Weave tracing
Weights & Biases API key for Weave tracing
Starting the App
Thestart()
method launches the Slack bot server:
Host address to bind the server to
Port number for the server
Message Routing
SlackApp automatically handles different types of Slack events:Direct messages
All direct messages to the bot are processed automatically.Channel messages
In channels, the bot responds to:- Messages where the bot is @mentioned
- Thread replies where the bot has previously participated
- Messages matching the configured
response_topics
(if set)
Thread management
Each Slack channel gets its own persistent conversation thread, maintaining context across messages.Features
Intelligent message classification
Whenresponse_topics
is configured, SlackApp uses an AI classifier to determine whether to respond to messages based on relevance.
File handling
Automatically downloads and processes files shared in Slack when the agent has file-handling tools.Health monitoring
Built-in health check endpoint at/health
and optional external health check pings.
Graceful shutdown
Proper signal handling for clean shutdown in containerized environments.Example with Advanced Features
Server Endpoints
SlackApp runs a FastAPI server with these endpoints:GET /health
Health check endpoint returning server status.
GET /
Root endpoint with basic server information.
Error handling
SlackApp includes comprehensive error handling:- Automatic retries for transient Slack API errors
- Graceful handling of missing threads or messages
- Detailed logging for debugging
- User-friendly error messages in Slack