An intelligent, automated calling system built with Ruby on Rails
Features β’ Installation β’ Configuration β’ Usage β’ Deployment
Autodialer is a powerful Ruby on Rails application that revolutionizes outbound calling by combining:
- π€ AI-Powered Commands - Natural language processing with Google Gemini
- π Twilio Integration - Reliable voice call delivery
- β‘ Background Processing - Async job handling with Sidekiq
- π Real-Time Tracking - Live call status monitoring
- π― Smart Scripting - AI-generated call scripts
β οΈ Important: This application is designed for testing with verified numbers only. Always obtain proper consent before calling real people.
- Multiple Input Methods: Paste numbers directly or upload
.txt/.csvfiles - Smart Validation: Automatic format checking and duplicate removal
- Batch Processing: Queue up to 100 numbers at once
- International Support: Handles country codes and various formats
Natural language interface powered by Google Gemini:
β
"Call +1 800 555 0100"
β
"Dial the last number"
β
"Call the third number from history"
β
"Dial the last 5 numbers"
β
"Call the previous number again"
Smart Features:
- Intent recognition and phone number extraction
- Historical reference tracking (last, previous, nth number)
- Context-aware script generation
- Fallback to direct number parsing
- Automated Calling: Programmable voice calls via Twilio API
- Status Tracking: Real-time updates (queued, ringing, completed, failed)
- Custom Scripts: AI-generated or default voice messages
- Multiple Voices: Support for various Polly voices
- Webhook Processing: Async status callbacks
- Call Timeline: Chronological view of all attempts
- Status Details: Duration, timestamps, and outcomes
- Success Metrics: Track completion rates
- Filterable Records: Search by status, number, or date
- Sidekiq Workers: Async call processing
- Redis Integration: Job queue management
- Auto-retry Logic: Configurable retry attempts
- Development Mode: Inline processing for easy testing
- Live Updates: Automatic status polling every 2 seconds
- Visual Feedback: Color-coded status badges
- Progress Tracking: Per-number call status
- Non-blocking: Continue browsing while calls process
- Ruby: 3.4.7 or higher
- PostgreSQL: 12 or higher
- Redis: 6 or higher (for production Sidekiq)
- Twilio Account: For voice calling
- Google Gemini API Key: For AI features
git clone https://github.com/irkky/autodialer.git
cd autodialerbundle install# Create and migrate database
rails db:create
rails db:migrate
# Optional: Load seed data
rails db:seedCreate a .env file from the example:
cp .env.example .envEdit .env with your credentials (see Configuration section).
Create a .env file in the project root with the following variables:
# ======================
# TWILIO CREDENTIALS
# Get these from: https://console.twilio.com
# ======================
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=your_auth_token_here
TWILIO_PHONE_NUMBER=+18005551234
# ======================
# GEMINI API KEY
# Get from: https://ai.google.dev/
# ======================
GEMINI_API_KEY=AIzaSyXXXXXXXXXXXXXXXXXXXXXXXXXX
# ======================
# BASE URL
# Must be publicly accessible by Twilio
# Use ngrok for local development:
# ngrok http 3000
# ======================
BASE_URL=https://yourapp.ngrok-free.app
# ======================
# REDIS CONFIG
# For Sidekiq background jobs
# ======================
REDIS_URL=redis://localhost:6379/0
# ======================
# RAILS ENVIRONMENT
# ======================
RAILS_ENV=development
# ======================
# DATABASE (Optional)
# PostgreSQL password if required
# ======================
AUTODIALER_DATABASE_PASSWORD=your_password
# ======================
# SIDEKIQ (Optional)
# Set to false to use Redis in development
# ======================
SIDEKIQ_INLINE=true-
Create a Twilio Account: Sign up at twilio.com
-
Get a Phone Number: Purchase or use a trial number
-
Configure Webhooks: In Twilio Console β Phone Numbers β Active Numbers β Configure
Setting URL Voice URL https://your-domain.com/twilio/voice_responseStatus Callback https://your-domain.com/twilio/status_callbackHTTP Method POST -
Verify Numbers (Trial Account): Add test numbers to your Verified Caller IDs
- Visit Google AI Studio
- Create a new API key
- Add the key to your
.envfile asGEMINI_API_KEY
To expose your local Rails server to Twilio:
# Install ngrok
brew install ngrok # macOS
# or download from https://ngrok.com/download
# Start ngrok
ngrok http 3000
# Copy the HTTPS URL to your .env file as BASE_URL
# Example: https://abc123.ngrok-free.apprails serverVisit: http://localhost:3000
# In development, jobs run inline by default
# To use Redis + Sidekiq:
SIDEKIQ_INLINE=false rails server
# In a separate terminal:
bundle exec sidekiq -C config/sidekiq.ymlngrok http 3000- Navigate to Upload Numbers (
/calls/new) - Choose your input method:
- Paste: Enter numbers (one per line)
- Upload: Select a
.txtor.csvfile
- Click Start Dialing
- View real-time status in the modal
- Check Call Logs for detailed results
- Navigate to AI Command Center (
/ai) - Enter a natural language command:
Call +1 800 555 0100Dial the previous numberCall the last 3 numbers
- Gemini extracts the intent and number
- System queues and processes the call
- View results in Call Logs
Direct Number Calling:
Call +1 800 555 0100
Dial 9876543210
Ring +91 98765 43210 now
Historical References:
Call the previous number
Dial the last number again
Call the same number
Ring the second last number
Call the before last number
Ordinal References:
Call the first number
Dial the third entry
Ring the 5th number from the list
Bulk Historical:
Call the last two numbers
Dial the last 5 numbers
Ring last three numbers
Navigate to Call Logs (/logs) to see:
- π Status: Completed, Failed, Busy, No-answer
- β±οΈ Duration: Call length in seconds
- π Timestamps: Start and end times
- π Number: Called phone number
- π Updates: Real-time status changes
Useful commands for testing and maintenance:
rake autodialer:generate_test_logsCreates 10 fake call records with random statuses.
rake autodialer:clear_logsDeletes all call records from the database.
TEST_NUMBER=+18001234567 rake autodialer:simulate_callCreates a simulated call record without actually calling.
autodialer/
βββ app/
β βββ controllers/
β β βββ ai_controller.rb # AI command processing
β β βββ calls_controller.rb # Bulk upload handling
β β βββ logs_controller.rb # Call log display
β β βββ twilio_controller.rb # Webhook handlers
β β
β βββ models/
β β βββ call_record.rb # Call data model
β β
β βββ services/
β β βββ gemini_ai.rb # AI integration
β β βββ twilio_service.rb # Twilio API wrapper
β β
β βββ workers/
β β βββ dialer_worker.rb # Call processing job
β β βββ twilio_status_sync_worker.rb # Status polling
β β
β βββ views/
β βββ ai/ # AI command interface
β βββ calls/ # Upload pages
β βββ logs/ # Log display
β
βββ config/
β βββ initializers/
β β βββ sidekiq.rb # Redis config
β β βββ sidekiq_inline.rb # Development mode
β β βββ twilio.rb # Twilio setup
β β
β βββ routes.rb # Application routes
β
βββ db/
β βββ migrate/
β βββ create_call_records.rb # Database schema
β
βββ lib/
βββ tasks/
βββ autodialer.rake # Custom rake tasks
- β Render.com - Easy Rails deployment
- β Railway.app - One-click deployment
- β Fly.io - Global edge network
- β Heroku - Classic PaaS
- Set Environment Variables: All production credentials
- Configure Redis: For Sidekiq job processing
- Setup PostgreSQL: Production database
- Compile Assets:
rails assets:precompile - Run Migrations:
rails db:migrate - Update BASE_URL: Point to production domain
- Configure Twilio Webhooks: Use production URLs
- Enable HTTPS: Required for Twilio webhooks
RAILS_ENV=production
SECRET_KEY_BASE=<generated_key>
TWILIO_ACCOUNT_SID=<your_sid>
TWILIO_AUTH_TOKEN=<your_token>
TWILIO_PHONE_NUMBER=<your_number>
GEMINI_API_KEY=<your_key>
BASE_URL=https://your-production-domain.com
REDIS_URL=redis://your-redis-url:6379/0
DATABASE_URL=postgresql://user:pass@host:5432/dbnameGenerate SECRET_KEY_BASE:
rails secret- Connect your GitHub repository
- Set environment as Web Service
- Add environment variables
- Set build command:
bundle install && rails assets:precompile && rails db:migrate - Set start command:
bundle exec puma -C config/puma.rb - Add Redis addon
- Deploy!
- β Use test/verified numbers only
- β
Store credentials in
.env(never commit) - β Enable CSRF protection
- β Validate phone number formats
- β Rate limit API calls
- β Enable HTTPS/SSL
- β Secure environment variables
- β
Use strong
SECRET_KEY_BASE - β Restrict Sidekiq dashboard access
- β Monitor Twilio usage and costs
- β Implement authentication for admin pages
- β Add CAPTCHA for public-facing forms
- β Set up request rate limiting
- Never call real people without explicit consent
- Comply with TCPA regulations (US) and local laws
- Respect Do Not Call lists
- Include opt-out mechanisms in scripts
- Monitor for abuse and suspicious patterns
- Secure webhook endpoints (verify Twilio signatures)
Problem: Calls fail with 403 or authorization errors
Solution:
- Verify
TWILIO_ACCOUNT_SIDandTWILIO_AUTH_TOKENin.env - Check that credentials match your Twilio console
- Ensure phone number format includes country code
Problem: Twilio can't reach your voice_response endpoint
Solution:
- Confirm
BASE_URLis publicly accessible - Check ngrok is running for local dev
- Verify webhook URLs in Twilio console
- Ensure Rails server is running
Problem: Status never updates from "queued"
Solution:
- Check Sidekiq is running (production)
- Verify Redis connection
- Check logs:
tail -f log/development.log - Ensure
TwilioStatusSyncWorkeris executing
Problem: AI commands don't trigger calls
Solution:
- Verify
GEMINI_API_KEYis set correctly - Check API quota/billing on Google Cloud
- Ensure number is in E.164 format
- Review
GeminiAi.process_commandlogic
Problem: Can't connect to PostgreSQL
Solution:
- Start PostgreSQL:
brew services start postgresql - Check database exists:
rails db:create - Verify
database.ymlcredentials - Ensure PostgreSQL is running on port 5432
POST /twilio/voice_response
Receives initial call connection request from Twilio.
Parameters:
CallSid- Unique call identifier
Response: TwiML voice instructions
POST /twilio/status_callback
Receives call status updates from Twilio.
Parameters:
CallSid- Unique call identifierCallStatus- Current status (queued, ringing, in-progress, completed, failed)To- Destination phone numberStartTime- Call start timestampEndTime- Call end timestampCallDuration- Duration in seconds
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Ruby style guide
- Write meaningful commit messages
- Add tests for new features
- Update documentation
- Keep dependencies up to date
This project is licensed under the MIT License. See the LICENSE file for details.
Built with these amazing technologies:
- Ruby on Rails - Web framework
- Twilio - Voice API
- Google Gemini - AI/ML capabilities
- Sidekiq - Background processing
- PostgreSQL - Database
- Redis - Job queue
- Bootstrap - UI components
Made with β€οΈ using Ruby on Rails