A FastAPI application that integrates Letta AI agents with Slack, providing intelligent conversation capabilities through a single endpoint.
- 🤖 Letta AI Integration: Uses a persistent Letta agent for intelligent conversations
- 💬 Slack Integration: Handles Slack URL verification, message events, and app mentions
- 🔄 Automatic Responses: Posts Letta agent responses back to Slack channels
- 🎯 Smart Filtering: Filters out simple greetings to reduce noise
- 🌐 ngrok Support: Easy deployment with static domain support
- 📝 Comprehensive Logging: Detailed debug information for troubleshooting
travis_ai/
├── letta/
│ ├── create_agent.py # Letta agent manager
│ └── api.py # Legacy API (moved to simple_api.py)
├── slack/
│ └── auth_middleware.py # Slack authentication middleware
├── simple_api.py # Main FastAPI application
├── main.py # Entry point
├── run.py # Simplified startup script
├── test.py # Basic API tests
├── requirements.txt # Python dependencies
├── .env # Environment variables (create this)
└── README.md # This file
- Python 3.8+
- uv package manager
- ngrok account (for Slack integration)
- Letta AI account
- Slack App with bot token
# Clone the repository
git clone <your-repo-url>
cd travis_ai
# Install dependencies using uv
uv pip install -r requirements.txtCreate a .env file in the project root:
# Letta AI Configuration
LETTA_API_KEY=your_letta_api_key_here
# Slack Configuration
SLACK_BOT_TOKEN=xoxb-your-slack-bot-token-here
# Optional: ngrok static domain
NGROK_DOMAIN=your-static-domain.ngrok-free.devThe application uses a pre-configured Letta agent ID: agent-2ed1f26b-6de6-4d1a-8466-b89e12482f71
If you need to create a new agent, you can use the letta/create_agent.py script:
uv run python letta/create_agent.py- Create a Slack app at api.slack.com/apps
- Add the following OAuth scopes:
app_mentions:readchannels:historychat:writeim:historyim:readim:write
- Subscribe to bot events:
message.channelsapp_mention
- Set the Request URL to your ngrok URL +
/conversation
# Run locally without ngrok
uv run python simple_api.py
# Or use the main entry point
uv run python main.py# Run with ngrok tunneling
uv run python simple_api.py --ngrok
# Or use the main entry point with ngrok
uv run python main.py --ngrok# Local
uv run python run.py
# With ngrok
uv run python run.py --ngrokThe main endpoint that handles all interactions:
Slack URL Verification:
{
"type": "url_verification",
"challenge": "challenge_string"
}Slack Message Events:
{
"type": "event_callback",
"event": {
"type": "message",
"user": "U1234567890",
"text": "Hello, how are you?",
"channel": "C1234567890"
}
}Direct Conversation:
{
"message": "What is Python programming?"
}Health check endpoint that returns:
{
"status": "healthy",
"message": "Simple Letta Agent API is running",
"agent_id": "agent-2ed1f26b-6de6-4d1a-8466-b89e12482f71"
}Run the basic test suite:
uv run python test.pyThis will test:
- Health check endpoint
- URL verification
- Simple greeting filtering
- Direct conversation with Letta agent
- URL Verification: Responds to Slack's challenge requests
- Message Events: Processes regular channel messages
- App Mentions: Handles
@botmentions specifically
The application filters out simple greetings to reduce noise:
hi,hey,hiyagood morning/afternoon/eveningwhat's up,how are youthanks,ok,yes,no
- Responses are automatically posted back to Slack
- Uses threading to keep conversations organized
- Includes comprehensive logging for debugging
-
ModuleNotFoundError: Ensure all dependencies are installed with
uv pip install -r requirements.txt -
LETTA_API_KEY not set: Check your
.envfile and ensure the API key is correct -
Slack events not received:
- Verify ngrok is running and accessible
- Check Slack app configuration
- Ensure Request URL points to
/conversation
-
Agent not responding:
- Verify the agent ID is correct
- Check Letta API key permissions
- Review logs for error messages
The application provides extensive debug logging:
🔍 DEBUG:- Detailed request/response information✅- Successful operations❌- Errors and failures📨- Slack message processing🤖- Letta agent responses
simple_api.py: Main FastAPI application with single endpointletta/create_agent.py: Letta agent management and API interactionsslack/auth_middleware.py: Slack authentication and middlewaremain.py: Application entry point with argument parsingrun.py: Simplified startup script
- LettaAgentManager: Handles all Letta API interactions
- Message Filtering: Smart filtering to reduce noise
- Slack Integration: URL verification and event handling
- Response Posting: Automatic Slack message posting
- Error Handling: Comprehensive error handling and logging
uv run python simple_api.py --ngrok- Use a proper WSGI server like Gunicorn
- Set up proper environment variable management
- Configure SSL/TLS for HTTPS
- Use a proper domain instead of ngrok for production
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
For issues and questions:
- Check the troubleshooting section
- Review the debug logs
- Verify environment configuration
- Test with the provided test suite