Real-time CRM-SMS integration with automated lead engagement
š”Business Impact: Automated SMS workflows reducing manual lead processing time by 80%
Built production SaaS platform as solo engineer: Full-stack SMS system enabling 12 studios to engage 9,000+ leads directly from Zoho CRM, processing 43,000+ messages. Shipped end-to-end solution in 4 weeks.
Zoho CRM triggers webhook on new lead ā Platform validates studio ownership via phone number mapping ā Creates task in Zoho for agent follow-up ā Routes SMS to lead via studio-specific Twilio/Zoho Voice number.
Studios table maps Zoho User IDs to dedicated SMS phone numbers. Each studio maintains separate OAuth tokens in StudioAccount junction table. Messages table enforces tenant boundaries with studioId foreign key, preventing cross-studio data access.
Dual-provider architecture (Twilio + Zoho Voice) with automatic failover. Incoming SMS webhooks identify studio by destination phone number, parse STOP/YES keywords for automated workflows, create Zoho tasks for manual responses. Admin phone number override enables managers to text from any studio context.
Centralized error handling wrapper with PostHog logging. Webhook returns HTTP 200 even on partial failures to prevent Twilio retries. Database-first approach ensures message persistence before API calls. Token refresh middleware handles Zoho OAuth expiration transparently.
Type-safe multi-tenant routing logic and API integrations
Built full-stack SaaS platform with custom Zoho CRM extension
ORM for PostgreSQL with complex multi-tenant data models
Stored 43k+ messages with studio-specific partitioning
Dynamic routing between studio-specific phone numbers
Custom CRM extension with intuitive chat interface
Real-time message synchronization and automated sequences
Complex routing logic based on agent context and permissions
Production monitoring and rapid issue resolution
Shipped complete solution in 4 weeks as solo engineer
Impact: This deduplication system solved race condition issues causing duplicate database records for Zoho Voice messages, reducing data inconsistencies by 100% through intelligent timing proximity detection (±5 minute window) and content matching.
SMS messages processed across 12 studios for lead engagement
Unique leads engaged through automated CRM-SMS workflows
Active fitness studios using the multi-tenant platform
Development time from concept to production deployment
Sole developer
Nov 2023 - ongoing
API integration, webhook handling, multi-tenant SMS delivery, error tracking
Multi-Tenant Data Isolation & Routing Complexity: Building secure tenant boundaries where 12 studios share infrastructure but maintain complete data isolation. Required sophisticated routing logic mapping Zoho User IDs to dedicated phone numbers, separate OAuth token management in StudioAccount junction table, and studio-specific message partitioning. Admin phone number override added complexity requiring context switching between studio permissions.
Race Condition Handling in Dual-Provider Message Synchronization: Managing message consistency across Twilio and Zoho Voice APIs with different response patterns and timing. Zoho Voice messages created multiple database records due to race conditions between message creation and API sync. Required intelligent deduplication system handling timing proximity (±5 minute window), content matching, and phone number normalization.
Rapid Production Deployment Under 4-Week Timeline: Shipping production-ready SaaS platform with enterprise-grade reliability in compressed timeframe. Required making architecture decisions quickly while ensuring scalability, implementing comprehensive error handling, establishing monitoring systems, and maintaining code quality under pressure without compromising long-term maintainability.
Studio-Based Multi-Tenant Architecture with Secure Isolation: Implemented Studios table mapping Zoho User IDs to dedicated SMS phone numbers with complete OAuth token separation via StudioAccount junction table. Messages table enforces tenant boundaries through studioId foreign key, preventing cross-studio data access. Admin phone number override enables managers to text from any studio context while maintaining security boundaries.
Sophisticated Message Deduplication System with Race Condition Prevention: Built multi-criteria duplicate detection system checking zohoMessageId, content, phone numbers, and timing proximity (±5 minute window). Implemented database-first persistence strategy updating existing messages with missing zohoMessageId rather than creating duplicates. Enhanced sync process with atomic operations and centralized deduplication utilities.
Database-First Architecture with Centralized Error Handling: Designed webhook processing that always returns HTTP 200 (even on partial failures) to prevent Twilio retries, while implementing database-first approach ensuring message persistence before API calls. Built centralized error handling wrapper with PostHog logging, token refresh middleware for transparent OAuth management, and comprehensive monitoring for production reliability.
Scale-Appropriate Multi-Tenancy Over Complex Patterns: For B2B SaaS with 12 studios, simple phone number-based tenant isolation proved more reliable than complex tenant management systems. Engineering judgment in choosing maintainable solutions appropriate for actual scale often outperforms following enterprise patterns designed for larger systems.
Race Condition Prevention Through Intelligent Deduplication: Rather than complex locking mechanisms, smart deduplication with timing proximity detection (±5 minutes) and content matching created robust real-time integration. Sometimes simple approaches to distributed system problems outperform sophisticated but brittle solutions.
Webhook Reliability via Simple Error Handling: Always returning HTTP 200 status (regardless of processing success) combined with database-first persistence created more reliable integration than complex retry logic. Production systems benefit from predictable behavior over sophisticated error handling when dealing with external webhook providers.
Multi-tenant data isolation via Studios table architecture
Phone number validation for webhook authentication
STOP message parsing for SMS compliance
PostHog monitoring for production error tracking