A multi-bot Slack platform that integrates Claude LLM with Sefaria's Jewish text database through MCP (Model Context Protocol). The platform supports multiple specialized bots, each with their own personality and capabilities, all sharing common infrastructure.
- Dynamic Bot Routing: Deploy multiple bots with different specializations
- Shared Infrastructure: Common services (Claude API, MCP) shared across all bots
- Bot Registry System: Automatic bot discovery and registration
- Scalable Design: Easy addition of new bots without code changes
- Smart Message Processing: Responds to @mentions and follows thread conversations
- Scholarly Responses: Provides comprehensive answers about Jewish texts with proper citations
- Attack Detection: Identifies and gracefully handles disingenuous or malicious questions
- Multilingual Support: Responds based on user's language
- Source Validation: All responses include Sefaria citations with proper link formatting
- Coverage Warnings: Alerts users when topics fall outside Jewish textual sources
- Bina (בינה): Main scholarly assistant for general Jewish text inquiries
- Binah (בינה): Deep research variant for comprehensive analysis (planned)
The application uses LangGraph for orchestrating message processing through an 8-node workflow:
Input: Slack message event → LangGraph workflow → Output: Formatted Slack response
- validate - Validates message, checks mentions, determines processing need
- acknowledge - Sends contextual emoji reaction (🤔, 👀, 🙏, 📜, 📚)
- fetchContext - Retrieves thread history, builds conversation context
- callClaude - Calls Claude API with MCP integration for Sefaria access
- validateSlackFormatting - Checks if response needs formatting fixes
- formatResponse - Applies final formatting, coverage warnings
- sendResponse - Posts formatted response to Slack
- handleError - Handles any errors during processing
src/workflows/workflow-base.ts- Base workflow template shared by all botssrc/workflows/bina-workflow.ts- Bina bot-specific workflow implementationsrc/nodes.ts- Implementation of all 8 workflow nodessrc/graph-types.ts- TypeScript interfaces for workflow state
src/app.ts- Express server with dynamic multi-bot routingsrc/bot-registry.ts- Bot discovery, registration, and management systemsrc/workflows/- Bot-specific workflow implementationssrc/slack-handler.ts- Fallback message processing (legacy compatibility)src/claude-service.ts- Shared Claude API integration with MCP connectorsrc/types.ts- TypeScript interfaces for all components
POST /slack/events- Default webhook (routes to "bina" for backward compatibility)POST /slack/events/:botName- Bot-specific webhook endpointsGET /health- Health check endpoint with bot registry status
Available Bot Routes:
POST /slack/events/bina- Bina bot endpointPOST /slack/events/binah- Binah bot endpoint (when configured)
- Node.js (v16 or higher)
- npm or yarn
- Slack workspace with admin permissions
- Anthropic API key with MCP beta access
- Sefaria MCP server running (typically via ngrok tunnel)
- LangGraph dependencies (@langchain/langgraph, @langchain/core)
- Clone the repository:
git clone <repository-url>
cd slack-mcp- Install dependencies:
npm install-
Set up environment variables (see Configuration section)
-
Build the application:
npm run buildThe platform supports two configuration modes:
Create a .env file with bot-specific configurations:
# Shared configuration (required)
ANTHROPIC_API_KEY=your-anthropic-api-key
SEFARIA_MCP_URL=https://your-ngrok-url.ngrok-free.app
PORT=3001
# Bot-specific configurations
# Pattern: BOTNAME_SLACK_TOKEN and BOTNAME_SIGNING_SECRET
# Bina bot (main scholarly assistant)
BINA_SLACK_TOKEN=xoxb-your-bina-bot-token
BINA_SIGNING_SECRET=your-bina-signing-secret
# Binah bot (deep research variant)
BINAH_SLACK_TOKEN=xoxb-your-binah-bot-token
BINAH_SIGNING_SECRET=your-binah-signing-secretFor backward compatibility, you can still use the original single-bot format:
# This will automatically be registered as the "bina" bot
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_SIGNING_SECRET=your-signing-secret
ANTHROPIC_API_KEY=your-anthropic-key
SEFARIA_MCP_URL=https://your-ngrok-url.ngrok-free.app
PORT=3001To add a new bot:
- Add Environment Variables: Follow the
BOTNAME_SLACK_TOKENandBOTNAME_SIGNING_SECRETpattern - Create Workflow (Optional): Add a new workflow in
src/workflows/yourbot-workflow.ts - Update Bot Registry: The bot will be automatically discovered and registered
- Slack Webhook: Configure your Slack app to use
https://your-domain.com/slack/events/yourbot
The system automatically discovers bots based on environment variable patterns - no code changes needed!
npm run devnpm run build
npm startThe service will start on the port specified in your environment variables (default: 3001).
Check bot registration status:
curl http://localhost:3001/healthThis will return information about registered bots:
{
"status": "ok",
"timestamp": "2024-01-01T00:00:00.000Z",
"bots": [
{"name": "bina", "description": null},
{"name": "binah", "description": null}
],
"botCount": 2
}The workflow uses SlackWorkflowState to track:
slackEvent- Input Slack message eventshouldProcess- Processing decision flagacknowledgmentSent- Emoji reaction statusthreadHistory- Slack conversation contextconversationContext- Claude API conversation formatclaudeResponse- Raw Claude API responseslackValidatedResponse- Formatted response for SlackerroranderrorOccurred- Error handling state
- Smart Slack Formatting Pipeline - Automatic HTML/markdown conversion using Claude Haiku
- Dynamic Emoji Selection - Context-aware emoji reactions based on content analysis
- Comprehensive Error Handling - Graceful degradation with fallback mechanisms
- Thread Context Management - Conversation continuity across message threads
The application includes comprehensive test coverage:
- Workflow Integration Tests - End-to-end workflow validation
- Node-Level Tests - Individual node function testing
- Service Integration Tests - API integration and error handling