How to Configures Twilio as a SIP trunk in Vicidial

Fermin Perdomo Fermin Perdomo
schedule 2 min read

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

  1. Go to Twilio Console → SIP Trunks
  2. Click "Create new SIP trunk"
  3. 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:

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

Reactions

lock You need to be logged in to react.
Log In

Newsletter

Get new posts delivered straight to your inbox.

mail

Great Tools for Developers

Git Tower

Git Tower

A powerful Git client for Mac and Windows that simplifies version control.

Visit arrow_forward
Mailcoach

Mailcoach

Self-hosted email marketing platform for sending newsletters and automated emails.

Visit arrow_forward
Uptimia

Uptimia

Website monitoring and performance testing tool to ensure your site is always up and running.

Visit arrow_forward
Cloudways

Cloudways

Managed cloud hosting platform that simplifies server management for developers.

Visit arrow_forward

Comments

No comments yet. Be the first to share your thoughts.

chat_bubble Join the conversation — log in to leave a comment.
Log In