CRM Bot is an intelligent Slack bot that monitors conversations and automatically creates/updates records in Attio CRM. Built by Ethan Ding for TextQL, this bot uses Claude Sonnet 4's native tool calling to understand natural language requests and perform CRM operations.
π¦ v1.12.0 Migration Notice: This bot has been upgraded from a custom ReAct framework to Claude's native tool calling. See
CHANGELOG.mdandMIGRATION.mdfor details.
Built to streamline GTM (Go-To-Market) operations by:
- Automatically capturing important updates from Slack into the CRM
- Enabling natural language CRM queries directly from Slack
- Reducing manual data entry and keeping CRM records up-to-date
- Creating a seamless bridge between team communications and CRM data
crm-bot/
βββ src/ # Main application source code
β βββ index-claude.js # Main entry point (Claude Agent)
β βββ handlers/
β β βββ slackHandlerClaude.js # Slack event handlers with Claude agent
β βββ services/
β βββ claudeAgent.js # Claude Sonnet 4 native tool calling
β βββ attioService.js # Attio CRM API integration
β βββ database-mock.js # In-memory DB fallback
β βββ fileStorage.js # File-based storage
βββ legacy/ # Legacy ReAct framework files (moved)
β βββ index-react.js # Old ReAct entry point
β βββ reactAgent.js # Old ReAct implementation
β βββ slackHandlerReact.js # Old ReAct handler
βββ tests/ # All test files
β βββ test-bot.js # Automated test suite
β βββ test-suite.js # Comprehensive test runner
β βββ test-*.js # Individual feature tests
β βββ test-logs/ # Test execution logs
βββ docs/ # Project documentation
β βββ credentials/ # API credentials info
β βββ SETUP_INSTRUCTIONS.md # Setup guide
β βββ RAILWAY_DEPLOYMENT.md # Deployment guide
β βββ STORAGE_SETUP.md # Storage setup
β βββ DEVELOPMENT_WORKFLOW.md # Development guide
β βββ LOCAL_TESTING.md # Local testing setup
βββ scripts/ # Utility and deployment scripts
β βββ deploy-railway.sh # Railway deployment script
β βββ deploy-secrets.sh # Secrets management
β βββ update-railway-vars.sh # Update environment variables
βββ config/ # Configuration files
β βββ railway.json # Railway deployment config
β βββ railway.toml # Railway build config
β βββ nixpacks.toml # Nixpacks build config
βββ local-bot.js # Local testing interface
βββ package.json # Node.js dependencies
βββ .env # Environment variables (source of truth)
βββ CLAUDE.md # AI assistant context
- Natural Language Processing: Understands requests like "find all deals related to Raine Group"
- Fuzzy Search: Intelligently matches partial names and typos
- Preview Mode: Shows exactly what actions will be taken before executing
- Thread Support: Maintains conversation context across thread replies
- Approval Workflow: All write operations require user confirmation
- Search - Find companies, deals, or people with fuzzy matching
- Create Notes - Add notes to any CRM record
- View Details - Get comprehensive information about entities
- Create Entities - Add new companies, deals, or people (coming soon)
- Update Fields - Modify existing records (coming soon)
- Uses Claude 3 for intelligent reasoning
- ReAct pattern for step-by-step problem solving
- Shows thinking process transparently
- Handles ambiguous requests gracefully
- Framework: Slack Bolt.js (Socket Mode)
- AI: Anthropic Claude API
- CRM: Attio API
- Storage: File-based conversation logging
- Hosting: Railway (production deployment)
- Language: Node.js 18+
- Node.js 18+
- Slack workspace admin access
- Attio CRM account
- Anthropic API key
- File system access for conversation storage
Create a .env file with:
# Slack Configuration (App ID: A094BJTADMG)
SLACK_BOT_TOKEN=xoxb-...
SLACK_SIGNING_SECRET=...
SLACK_APP_TOKEN=xapp-...
# APIs
ANTHROPIC_API_KEY=sk-ant-api03-...
ATTIO_API_KEY=...
# File Storage (automatic)
# Conversations stored in data/conversations/- Create a Slack app at https://api.slack.com/apps
- Enable Socket Mode
- Add Bot Token Scopes:
app_mentions:readchat:writechannels:historychannels:readgroups:historygroups:readim:historyim:readim:writeusers:read
- Install app to workspace
- Copy tokens to
.env
π NEW: Test the AI locally without Slack! Perfect for rapid development.
-
Test AI Logic Locally (No Slack Required!)
# Interactive testing - chat with the bot npm run local # Type commands like: > find rain group > search for the raine group > /debug # Show AI reasoning steps > /exit # Quit # Or quick one-liner tests echo "find the raine group" | npm run local # Run automated test suite npm run test:bot
-
Deploy to Test Slack Features
git push origin main # Auto-deploys to Railway -
Full Development Cycle:
- Phase 1: Test AI changes locally (
npm run local) - Phase 2: Deploy and test Slack integration
- See DEVELOPMENT_WORKFLOW.md for details
- Phase 1: Test AI changes locally (
- Interactive Chat: Real-time conversation with the bot
- Debug Mode: See the AI's reasoning process
- Fuzzy Search: Test misspellings like "rain" β "raine"
- Thread Context: Test multi-message conversations
- Instant Feedback: No deployment wait times
-
Always Test AI Logic Locally First
# Make changes to reactAgent.js or attioService.js npm run local # Test your changes instantly
-
Use Feature Branches
git checkout -b feature/improve-search # Test locally until perfect npm run local # Then deploy git push origin feature/improve-search
-
Monitor Production
- Railway logs show deployment status
- Bot includes version in responses (e.g., "π v1.8.0")
- Repository: https://github.com/TextQLLabs/crm-bot
- Auto-deploy: β
Enabled - pushes to
mainbranch trigger automatic deployment - Deploy Time: ~2-3 minutes
- Environment: Variables set in Railway dashboard (not from
.env)
-
Push to GitHub
git add . git commit -m "Your changes" git push origin main
-
Railway Auto-Deploy
- Detects push within seconds
- Builds new container
- Runs health checks
- Swaps to new version
-
Monitor Deployment
- Go to Railway dashboard β Your project
- Click on deployment to see logs
- Look for: "β‘οΈ CRM Bot with ReAct Agent is running!"
Build Errors:
- Shown in Railway dashboard under failed deployment
- Common: Missing dependencies, syntax errors
- Fix locally first, then push
Runtime Errors:
- Visible in Railway logs (real-time)
- Bot will show error messages in Slack
- Railway auto-restarts on crashes
Rollback:
- Railway dashboard β Deployments β Click previous deployment β "Redeploy"
- Or use git:
git revert HEAD && git push
- Real-time Logs: Railway dashboard β "View Logs"
- Deployment Status: Green = running, Red = failed
- Debug Info: Bot includes deployment info in thinking message
- Alerts: Set up in Railway dashboard (optional)
- Mention the bot:
@crm-bot-ethan test - Search test:
@crm-bot-ethan find deals related to Raine - Note creation:
@crm-bot-ethan add a note to the Raine deal saying "Test note" - Thread test: Reply to the bot's message to test context retention
An MCP (Model Context Protocol) server is configured for the Slack integration, allowing direct bot testing without manual Slack interaction. This is available on the Ethan Ding account.
- Add entity creation (companies, deals, people)
- Implement field updates
- Add bulk operations support
- Create activity/task logging
- Multi-workspace support
- Custom field mapping
- Scheduled reports
- Webhook support for real-time CRM updates
- Integration with other tools (email, calendar)
- Advanced analytics and insights
- Add comprehensive error handling
- Implement rate limiting
- Add request queuing
- Create admin dashboard
- Add performance monitoring
- Implement caching strategy
-
"invalid_auth" error
- Check Slack tokens are correct in Railway
- Ensure tokens match the app (App ID: A094BJTADMG)
-
"missing_scope" error
- Add missing OAuth scopes in Slack app
- Reinstall app to workspace
- Update tokens in Railway
-
"401 invalid x-api-key"
- Verify Anthropic API key is correct
- Check for extra spaces or quotes
-
Bot not responding
- Check Railway deployment status
- Verify bot is mentioned correctly
- Check logs for connection errors
- Built by: Ethan Ding
- Organization: TextQL
- Slack Workspace: TextQL
- Always use
.envfile as source of truth for credentials - Socket Mode means no public URLs needed
- Railway handles automatic restarts on crashes
- File-based storage automatically creates data directories
- Preview mode ensures safety for all write operations
- GitHub: https://github.com/TextQLLabs/crm-bot
- Railway Dashboard: [Check your Railway account]
- Slack App: https://api.slack.com/apps/A094BJTADMG
- Attio CRM: https://app.attio.com
- See
CLAUDE.mdfor AI assistant context and technical implementation details - See
docs/directory for comprehensive guides on setup, deployment, and development