Overview
SIP Trunk integration with Twilio allows you to:- Route inbound calls from SIP Trunks to departments or agents
- Make outbound calls through SIP domains
- Configure IP-based or credential-based authentication
- Use SIP Trunks with the Web Dialer
- Manage SIP security settings and voice endpoints
- Test SIP Trunk connections in real-time
Prerequisites
Before setting up SIP Trunks, ensure you have:Twilio Account
- Active Twilio account with SIP Trunking enabled
- Your Twilio Account SID
- Your Twilio Auth Token
Network Configuration
- Properly configured network environment that allows SIP traffic
- Open SIP ports (5060 for SIP, 5061 for SIPS)
- Firewall configured to allow Twilio IP ranges
Environment Configuration
First, configure your TelemanAI environment for SIP Trunking.Run Database Migration
Execute the migration to create necessary database tables:This creates the
sip_trunks table and related structures.Creating Your First SIP Trunk
Enter Basic Information
Fill in the required fields:Name (required)
- A descriptive name for the SIP Trunk
- Example: “Main Office SIP Trunk” or “Remote Workers SIP”
- Your Twilio SIP domain
- Format:
your-domain.sip.twilio.com - Must match your Twilio console configuration
- Additional descriptive name
- Used for easier identification
Configure Department Routing
Department (optional)
- Select a department for automatic call routing
- Incoming calls will route to this department
- Leave blank to route to default agent
Select Authentication Type
Choose your authentication method:IP Access Control List (IP ACL)
- Best for fixed office locations
- More secure for controlled environments
- No credential management needed
- Best for remote workers
- Supports dynamic IP addresses
- Requires username/password management
Configure Voice Settings
Voice URL (optional)
- URL for handling inbound calls
- Defaults to:
https://your-domain.com/sip/inbound - Can be customized for special routing
- HTTP method for voice URL
- Choose: GET or POST
- Recommended: POST
The default voice URL works for most use cases. Only customize if you have special routing requirements.
Authentication Methods
IP Access Control Lists (IP ACL)
IP-based authentication restricts SIP connections to specified IP addresses.When to Use IP ACL
- Office environments with static IP addresses
- Higher security requirements
- Situations where credential management is difficult
- Dedicated SIP infrastructure
Configuring IP ACL
Select IP ACL Authentication
In the SIP Trunk form, select IP Access Control List as the authentication type
Add IP Addresses
Click Add IP Address to add allowed IPs:IP Address (required)
- Enter the static IP address
- Format:
203.0.113.1or2001:db8::1 - IPv4 or IPv6 supported
- Descriptive label for the IP
- Example: “Office Router” or “PBX Server”
Add Multiple IPs
Click Add IP Address again to add more IPs:
- One IP per row
- Can add unlimited IP addresses
- Remove IPs using the trash icon
Credential-Based Authentication
Credential-based authentication uses username/password pairs.When to Use Credentials
- Remote workers with dynamic IP addresses
- Multiple users sharing the same SIP Trunk
- Mobile or traveling workers
- Third-party SIP clients
Configuring Credentials
Add Credentials
Click Add Credential to create username/password pairs:Username (required)
- SIP authentication username
- Must be unique per SIP Trunk
- Use alphanumeric characters
- Strong password for SIP authentication
- Minimum 12 characters recommended
- Use mix of letters, numbers, symbols
Add Multiple Credentials
Click Add Credential to add more users:
- One credential pair per row
- Each user gets unique credentials
- Remove using the trash icon
Inbound Call Handling
When a call arrives through your SIP Trunk, TelemanAI processes it automatically.Call Flow
- Call Arrives: Twilio receives call on your SIP domain
- Domain Identification: System identifies SIP domain from incoming request
- SIP Trunk Lookup: System finds matching active SIP Trunk in database
- Department Routing:
- If SIP Trunk has department assigned → route to department
- If no department → route to default agent
- Call Handling: Agent receives call in web dialer
Configuring Department Routing
Select Department
Choose the desired department from the dropdown:
- Only active departments appear
- Department must have agents assigned
- Agents must be available to receive calls
All incoming calls to this SIP Trunk will now route to agents in the selected department.
SIP Trunk and Web Dialer Integration
SIP Trunks can be used with the Web Dialer for outbound calling.Enabling SIP Trunk in Web Dialer
Create Active SIP Trunk
Ensure you have at least one active SIP Trunk:
- Navigate to Dashboard → SIP Trunks
- Verify status is Active
- Test connection is successful
Select SIP Trunk
In the Web Dialer interface:
- Look for SIP Trunk dropdown
- Select your SIP Trunk from the list
- SIP Trunk info panel displays configuration
Benefits of SIP Trunk Calling
- Cost Efficiency: Potentially lower call costs through SIP providers
- Flexibility: Multiple routing options per user
- Scalability: Support for multiple SIP domains
- Department Control: SIP Trunks can be assigned to departments
Testing SIP Trunk Connection
Additional Testing Methods
SIP Client Testing
Test with SIP clients like Zoiper, X-Lite, or Linphone:-
Configure SIP client with your credentials:
- Domain: your-domain.sip.twilio.com
- Username: (from credential list)
- Password: (from credential list)
- Register the SIP client
- Make a test call
- Verify call routing and audio quality
Automated Tests
Run the test suite:Managing SIP Trunks
Viewing SIP Trunk Details
Editing SIP Trunks
Modify Settings
Update any configuration:
- Name and friendly name
- Department routing
- Authentication settings
- Security options
The SIP domain is read-only after creation. Create a new SIP Trunk to use a different domain.
Deleting SIP Trunks
Security Best Practices
Use Secure SIP (SIPS)
Use Secure SIP (SIPS)
- Always enable SIPS in production
- Uses TLS encryption for signaling
- Protects credentials and call metadata
- Required for PCI compliance
IP Restrictions
IP Restrictions
- Implement IP ACL where possible
- Use most restrictive whitelist
- Monitor for unauthorized access attempts
- Update IPs when infrastructure changes
Strong Passwords
Strong Passwords
- Minimum 12 characters for SIP credentials
- Use password generators
- Include uppercase, lowercase, numbers, symbols
- Avoid dictionary words
Regular Credential Rotation
Regular Credential Rotation
- Change SIP passwords quarterly
- Immediately rotate compromised credentials
- Keep audit log of credential changes
- Disable unused credentials
Monitor Activity
Monitor Activity
- Review SIP Trunk call logs regularly
- Set up alerts for unusual patterns
- Monitor failed authentication attempts
- Track usage by department/user
Troubleshooting
Connection Failed
Connection Failed
Problem: Test connection fails or calls don’t connectSolution:
- Verify Twilio credentials in
.envfile - Check TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN
- Ensure SIP_TRUNK=YES is set
- Check network firewall allows SIP traffic
- Verify SIP ports (5060/5061) are open
- Test Twilio API connectivity
Authentication Problems
Authentication Problems
Problem: SIP clients cannot authenticateSolution:
- Verify IP addresses in ACL are correct
- Check credentials are entered correctly (no typos)
- Ensure SIP Trunk is set to Active
- Verify Twilio console matches TelemanAI config
- Test with simple credentials first
- Check for special characters in passwords
Inbound Call Routing Issues
Inbound Call Routing Issues
Problem: Calls arrive but don’t route to agentsSolution:
- Verify department has assigned agents
- Check agent availability status
- Review voice URL configuration
- Check TwiML response logs in Twilio console
- Verify SIP domain matches exactly
- Test with default routing (no department)
Web Dialer SIP Trunk Not Appearing
Web Dialer SIP Trunk Not Appearing
Problem: SIP Trunk doesn’t show in Web DialerSolution:
- Verify SIP_TRUNK=YES in
.env - Check SIP Trunk status is Active
- Ensure user has permissions
- Clear browser cache and refresh
- Verify TWILIO_SIP_ENABLED=true
- Check sip-trunk-dialer.js is loaded
Add IP Address Button Not Working
Add IP Address Button Not Working
Advanced Configuration
Custom Voice URLs
For advanced routing scenarios, you can customize the voice URL:- Multi-tenant routing
- Custom IVR integration
- External call handling systems
- A/B testing call flows
Webhook Configuration
The default inbound webhook endpoint is:- Parses SIP address to identify domain
- Finds corresponding SIP Trunk in database
- Routes based on department settings
- Generates TwiML instructions for Twilio
Related Resources
Web Dialer
Use SIP Trunks with the Web Dialer
Departments & Agents
Configure departments for SIP call routing
Creating Campaigns
Use SIP Trunks in campaigns
Twilio Integration
Configure Twilio services