How to Configures Twilio as a SIP trunk in Vicidial
Fermin Perdomo
July 23, 2025
In this post, I will teach how to configure Twilio as a SIP trunk in vicidial.
Requirements
- A working VICIdial server
- A Twilio account
- A purchased Twilio SIP domain (Elastic SIP Trunking)
- A public IP address for your VICIdial server
- Port 5060 (UDP/TCP) and RTP ports (e.g., 10000–20000) open in your firewall
Step-by-Step Configuration
1. Create a Twilio SIP Trunk
- Go to Twilio Console → SIP Trunks
- Click "Create new SIP trunk"
- Name it e.g., VICIdialTrunk
2. Configure Termination (Outbound from VICIdial)
- Go to your trunk → Termination
- Add a Termination SIP URI, e.g.:
vicidial.pstn.twilio.com
- Set Authentication:
- Method: IP Access Control List (ACL)
- Add your VICIdial server's public IP to the ACL
Copy the SIP URI for use in the dialplan later.
3. Configure Origination (Inbound to VICIdial)
- Go to your trunk → Origination
- Add a new Origination URI:
sip:YOUR_PUBLIC_IP
Replace YOUR_PUBLIC_IP with your VICIdial server’s IP.
4. Configure Carrier in VICIdial
Login to VICIdial admin panel:
- Go to Admin > Carriers > Add A New Carrier
Carrier Settings:
Carrier ID: TwilioSIP Carrier Name: Twilio SIP Registration String: (leave blank for IP-based auth)
Dialplan Entry:
exten => _X.,1,AGI(agi://127.0.0.1:4577/call_log) exten => _X.,n,Dial(SIP/${EXTEN}@twilio-out,60,tTo) exten => _X.,n,Hangup()
Account Entry:
[twilio-out] type=peer host=YOUR_TRUNK_SIP_URI ; e.g. vicidial.pstn.twilio.com transport=udp port=5060 insecure=invite dtmfmode=rfc2833 disallow=all allow=ulaw context=trunkinbound
Replace YOUR_TRUNK_SIP_URI with the one from Twilio’s Termination page.
5. Allow Inbound SIP Calls in Asterisk
Edit your /etc/asterisk/extensions.conf and add this in [trunkinbound] context:
[trunkinbound] exten => _X.,1,AGI(agi://127.0.0.1:4577/call_log) exten => _X.,n,Dial(SIP/1234,60,tTo) ; Replace with actual agent or group exten => _X.,n,Hangup()
6. Reload Asterisk
asterisk -rx "sip reload" asterisk -rx "dialplan reload"
7. Test Outbound Call
- Create a test campaign with a phone number.
- Dial and monitor logs via:
tail -f /var/log/asterisk/full
🔒 Security Notes
- Ensure your server only accepts traffic from Twilio’s SIP IPs:
https://www.twilio.com/docs/sip-trunking#sip-trunking-ip-addresses - Use fail2ban or iptables to secure your VICIdial instance.
Please login to leave a comment.