Skip to main content
SIP Trunking enables your TelemanAI system to connect to the public switched telephone network (PSTN) through Internet Protocol (IP) connections, replacing traditional telephone lines. This guide covers complete SIP Trunk setup and integration.

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:
1

Twilio Account

  • Active Twilio account with SIP Trunking enabled
  • Your Twilio Account SID
  • Your Twilio Auth Token
2

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
3

Authentication Setup

Choose your authentication method:For IP-based authentication:
  • Static IP addresses for your SIP clients
  • IP whitelist configuration
For credential-based authentication:
  • SIP clients that support SIP authentication
  • Secure password storage

Environment Configuration

First, configure your TelemanAI environment for SIP Trunking.
1

Edit Environment File

Open your .env file and add the following configuration:
# Twilio SIP Trunk Configuration
SIP_TRUNK=YES
TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_APP_SID=your_twilio_app_sid
TWILIO_NUMBER=your_twilio_phone_number
TWILIO_SIP_ENABLED=true
TWILIO_SIP_DEFAULT_DOMAIN=your-default-domain.sip.twilio.com
Replace placeholder values with your actual Twilio credentials. Never commit credentials to version control.
2

Run Database Migration

Execute the migration to create necessary database tables:
php artisan migrate
This creates the sip_trunks table and related structures.
3

Add Menu Integration

Add the SIP Trunk menu item to your navigation:
php artisan teleman:add-sip-trunk-menu
4

Clear Cache

Clear application cache to apply changes:
php artisan cache:clear

Creating Your First SIP Trunk

1

Navigate to SIP Trunks

From your dashboard, go to Dashboard → SIP Trunks
2

Click Add New

Click the Add New button to open the SIP Trunk creation form
3

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”
SIP Domain (required)
  • Your Twilio SIP domain
  • Format: your-domain.sip.twilio.com
  • Must match your Twilio console configuration
Friendly Name (optional)
  • Additional descriptive name
  • Used for easier identification
4

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
Department routing allows automatic distribution of inbound SIP calls to specific teams.
5

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
Credential List
  • Best for remote workers
  • Supports dynamic IP addresses
  • Requires username/password management
6

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
Voice Method
  • 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.
7

Configure Security Options

Active
  • Toggle to enable/disable the SIP Trunk
  • Only active SIP Trunks will route calls
Secure
  • Enable secure SIP (SIPS)
  • Uses TLS encryption
  • Recommended for production
Always use secure SIP (SIPS) in production environments to encrypt call signaling.

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

1

Select IP ACL Authentication

In the SIP Trunk form, select IP Access Control List as the authentication type
2

Add IP Addresses

Click Add IP Address to add allowed IPs:IP Address (required)
  • Enter the static IP address
  • Format: 203.0.113.1 or 2001:db8::1
  • IPv4 or IPv6 supported
Friendly Name (optional)
  • Descriptive label for the IP
  • Example: “Office Router” or “PBX Server”
3

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
4

Save Configuration

Click Save to create the SIP Trunk with IP ACL authentication
Add all potential source IPs for your SIP clients, including backup connections and failover addresses.

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

1

Select Credential List

In the SIP Trunk form, select Credential List as the authentication type
2

Add Credentials

Click Add Credential to create username/password pairs:Username (required)
  • SIP authentication username
  • Must be unique per SIP Trunk
  • Use alphanumeric characters
Password (required)
  • Strong password for SIP authentication
  • Minimum 12 characters recommended
  • Use mix of letters, numbers, symbols
3

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
4

Save Configuration

Click Save to create the SIP Trunk with credential authentication
Use strong passwords for credential authentication. Regularly rotate credentials for security.

Inbound Call Handling

When a call arrives through your SIP Trunk, TelemanAI processes it automatically.

Call Flow

  1. Call Arrives: Twilio receives call on your SIP domain
  2. Domain Identification: System identifies SIP domain from incoming request
  3. SIP Trunk Lookup: System finds matching active SIP Trunk in database
  4. Department Routing:
    • If SIP Trunk has department assigned → route to department
    • If no department → route to default agent
  5. Call Handling: Agent receives call in web dialer

Configuring Department Routing

1

Edit SIP Trunk

Navigate to Dashboard → SIP Trunks and click on your SIP Trunk
2

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
3

Save Changes

Click Update to save the department assignment
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

1

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
2

Open Web Dialer

Navigate to Dashboard → Web Dialer
3

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
4

Make Calls

With SIP Trunk selected:
  • Enter phone number to call
  • Click Call button
  • Calls route through your SIP domain
  • Status shows “Calling via SIP Trunk”

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

1

Navigate to SIP Trunk

Go to Dashboard → SIP Trunks and click on your SIP Trunk
2

Click Test Connection

Click the Test Connection button on the SIP Trunk details page
3

Review Results

The system will:
  • Verify Twilio SIP domain is accessible
  • Check authentication configuration
  • Validate voice URL endpoint
  • Display success or error message
Test connections after any configuration changes to ensure proper setup.

Additional Testing Methods

SIP Client Testing

Test with SIP clients like Zoiper, X-Lite, or Linphone:
  1. Configure SIP client with your credentials:
    • Domain: your-domain.sip.twilio.com
    • Username: (from credential list)
    • Password: (from credential list)
  2. Register the SIP client
  3. Make a test call
  4. Verify call routing and audio quality

Automated Tests

Run the test suite:
php artisan test --filter=SipTrunk

Managing SIP Trunks

Viewing SIP Trunk Details

1

Access SIP Trunk List

Navigate to Dashboard → SIP Trunks
2

View Details

Click on a SIP Trunk name to view:
  • Basic configuration
  • Authentication settings
  • Department assignment
  • Active status
  • Recent activity

Editing SIP Trunks

1

Open SIP Trunk

Navigate to Dashboard → SIP Trunks and click on the SIP Trunk
2

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.
3

Save Changes

Click Update to save your modifications

Deleting SIP Trunks

Deleting a SIP Trunk will:
  • Stop all inbound call routing
  • Remove authentication configurations
  • Disconnect any active SIP clients
  • Cannot be undone
1

Navigate to SIP Trunks

Go to Dashboard → SIP Trunks
2

Select SIP Trunk

Find the SIP Trunk to delete
3

Delete

Click the Delete button
4

Confirm

Confirm the deletion when prompted

Security Best Practices

  • Always enable SIPS in production
  • Uses TLS encryption for signaling
  • Protects credentials and call metadata
  • Required for PCI compliance
  • Implement IP ACL where possible
  • Use most restrictive whitelist
  • Monitor for unauthorized access attempts
  • Update IPs when infrastructure changes
  • Minimum 12 characters for SIP credentials
  • Use password generators
  • Include uppercase, lowercase, numbers, symbols
  • Avoid dictionary words
  • Change SIP passwords quarterly
  • Immediately rotate compromised credentials
  • Keep audit log of credential changes
  • Disable unused credentials
  • Review SIP Trunk call logs regularly
  • Set up alerts for unusual patterns
  • Monitor failed authentication attempts
  • Track usage by department/user

Troubleshooting

Problem: Test connection fails or calls don’t connectSolution:
  • Verify Twilio credentials in .env file
  • 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
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
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)
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
Problem: Cannot add IP addresses or credentialsSolution:
  • Open browser developer tools (F12)
  • Check console for JavaScript errors
  • Verify jQuery is loaded properly
  • Test in incognito/private window
  • Clear browser cache
  • Check for JavaScript conflicts
  • Try /public/sip-trunk-test.html for isolated testing

Advanced Configuration

Custom Voice URLs

For advanced routing scenarios, you can customize the voice URL:
# Custom voice URL format
https://your-domain.com/custom/routing?param=value
Use cases:
  • Multi-tenant routing
  • Custom IVR integration
  • External call handling systems
  • A/B testing call flows

Webhook Configuration

The default inbound webhook endpoint is:
POST https://your-domain.com/sip/inbound
This endpoint:
  • Parses SIP address to identify domain
  • Finds corresponding SIP Trunk in database
  • Routes based on department settings
  • Generates TwiML instructions for Twilio

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

Build docs developers (and LLMs) love