An intelligent SMS automation system that helps phone repair shops convert leads and manage customer interactions using Claude AI. The system handles appointment scheduling, customer inquiries, and lead qualification automatically while maintaining a natural, professional conversation flow.
- Intelligent Conversations: Leverages Claude AI to maintain natural, context-aware customer interactions
- Appointment Scheduling: Automatically schedules repairs based on availability
- Lead Qualification: Identifies and qualifies potential customers
- Customer Information Management: Stores and retrieves customer data and conversation history
- Multi-State Conversation Handling: Manages complex conversation flows with proper state management
- Error Handling: Robust handling of edge cases and graceful degradation
- Human Handoff: Smart escalation to human agents when needed
- Backend: Node.js with Express
- AI: Anthropic's Claude 3 API
- Database: MongoDB for conversation and customer data storage
- SMS Gateway: Twilio for message handling
- State Management: Custom conversation state tracking
- Error Handling: Comprehensive error management system
- Node.js (v14 or higher)
- MongoDB instance
- Twilio account with SMS capabilities
- Anthropic API key
- Environment variables configured
- Clone the repository
git clone https://github.com/yourusername/sms-ai-agent.git
cd sms-ai-agent
- Install dependencies
npm install
- Configure environment variables
Create a
.env
file in the root directory:
TWILIO_ACCOUNT_SID=your_account_sid
TWILIO_AUTH_TOKEN=your_auth_token
TWILIO_PHONE_NUMBER=your_twilio_number
MONGODB_URI=your_mongodb_uri
ANTHROPIC_API_KEY=your_anthropic_key
PORT=3000
- Start the server
npm start
const SMSAgent = require('./path/to/SMSAgent');
const agent = new SMSAgent(
process.env.TWILIO_ACCOUNT_SID,
process.env.TWILIO_AUTH_TOKEN,
process.env.TWILIO_PHONE_NUMBER,
process.env.MONGODB_URI
);
- Trigger Initial Contact Initiates the first contact with a potential customer.
POST /api/trigger-message
// Request Body
{
"phoneNumber": "+1234567890",
"customerInfo": {
"name": "John Doe",
"phoneModel": "iPhone 13 Pro",
"issue": "Cracked screen",
"email": "john@example.com"
}
}
// Success Response
{
"status": "success",
"messageSid": "SM123...",
"content": "Hi John! We received your repair request for iPhone 13 Pro screen repair...",
"to": "+1234567890"
}
- Handle Incoming Messages Webhook endpoint for processing all subsequent messages in the conversation.
POST /api/webhook
// Request Body (Twilio Webhook Format)
{
"Body": "Yes, I'd like to schedule an appointment",
"From": "+1234567890",
"To": "+0987654321",
"MessageSid": "SM123..."
}
// Success Response
{
"status": "success",
"messageSid": "SM124...",
"content": "Great! We have availability tomorrow at 2 PM or 4 PM. Which time works better?",
"to": "+1234567890"
}
-
Initial Contact
- System receives customer information and triggers initial message
- AI generates appropriate greeting and information gathering
-
Information Collection
- System collects necessary details about the repair
- Validates phone model and issue description
-
Quote Provision
- Provides repair cost estimation
- Handles objections when needed
-
Appointment Scheduling
- Checks availability
- Books appointment
- Sends confirmation
-
Follow-up
- Handles post-booking queries
- Manages appointment modifications
The system includes robust error handling for:
- Invalid phone models
- Unclear repair descriptions
- System integration issues
- Message delivery failures
- Database connectivity problems
- API rate limiting
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
For support, please email idib2025@gmail.com or create an issue in the repository.