AI365Pro set out to modernise its phone system so consultants could call customers from anywhere, directly inside the CRM. This case study shows how we built a cloud VoIP stack using Twilio Elastic SIP Trunking and an Asterisk PBX to power browser‑based calling and traditional phones alike.
Why We Moved to Cloud VoIP
AI365Pro needed more than just a dial tone:
Use the main business number 04xx 777 888 from any location, on any device.
Route calls intelligently through IVR and queues, with central call recording.
Remove dependence on physical phone lines and office hardware.
Let consultants click‑to‑call directly from records inside the CRM at ai365pro.com.
Traditional on‑premise telephony couldn’t deliver the flexibility and integration we wanted, so we chose a cloud‑first design.
The Architecture We Designed
At a high level, the new phone system looks like this:
Twilio Elastic SIP Trunking
Provides Australian DIDs, including 04xx 777 888, and outbound PSTN connectivity.
Asterisk PBX (PJSIP)
Runs on a hardened VPS and is reachable via pbx.ai365pro.com (example FQDN).
Manages extensions, IVR, queues, voicemail, and call recording.
Endpoints
Desk phones and softphones register via SIP/UDP.
Browser‑based softphones in the CRM connect via WebRTC over secure WebSocket (WSS).
Call flow:
Outbound: Extension → Asterisk → Twilio SIP Trunk → PSTN.
Inbound: PSTN number → Twilio → Asterisk Origination URI → IVR/queue/extension.
Configuring Twilio for AI365Pro
We started by building a robust trunk in Twilio:
Create the SIP Trunk and Numbers
In the Twilio Console, we created an Elastic SIP Trunk named AI365Pro-Trunk.
We attached the main number 04xx 777 888, plus capacity for additional DIDs as the team grows.
Termination (Outbound) Settings
Termination SIP Domain: ai365pro-pbx.sip.twilio.com.
Authentication via a credential list (ai365pro-trunk-user with a strong password), used by Asterisk for outbound calls.
Origination (Inbound) Settings
Origination URI: sip:pbx.ai365pro.com:5061;transport=tls, pointing all inbound calls from Twilio to the Asterisk server over TLS.
Secure Trunking
Enabled Secure Trunking so signaling uses TLS and media can be protected with SRTP between Twilio and Asterisk.
This setup keeps carrier connectivity in the cloud while giving Asterisk full control of call logic.
Building the Asterisk Side
Using Twilio’s Asterisk guides as a starting point, we fine‑tuned PJSIP to fit AI365Pro’s environment.
TLS Transport
text[transport-tls] type=transport protocol=tls bind=0.0.0.0:5061 external_signaling_address=pbx.ai365pro.com external_media_address=pbx.ai365pro.com cert_file=/etc/asterisk/keys/ai365pro-pbx.pem priv_key_file=/etc/asterisk/keys/ai365pro-pbx.key method=tlsv1_2
Twilio Trunk Definition
text[twilio-ai365pro] type=registration outbound_auth=twilio-ai365pro-auth server_uri=sip:ai365pro-pbx.sip.twilio.com:5061;transport=tls client_uri=sip:[email protected] contact_user=ai365pro-user retry_interval=60 [twilio-ai365pro-auth] type=auth auth_type=userpass username=ai365pro-user password=STRONG_TRUNK_PASSWORD [twilio-ai365pro-endpoint] type=endpoint transport=transport-tls context=from-twilio disallow=all allow=ulaw outbound_auth=twilio-ai365pro-auth aors=twilio-ai365pro-aor direct_media=no rtp_symmetric=yes force_rport=yes rewrite_contact=yes [twilio-ai365pro-aor] type=aor contact=sip:ai365pro-pbx.sip.twilio.com
This follows Twilio’s best‑practice templates: secure TLS transport, ulaw codec, symmetric RTP, and NAT‑friendly contact handling.
Dialplan: Turning Numbers into Call Flows
Inbound to AI365Pro
text[from-twilio]
; Main business number routed to IVR
exten => +614xx777888,1,NoOp(Incoming call for AI365Pro main number)
same => n,Goto(ai365pro-ivr,s,1)
; Catch-all during rollout
exten => _X.,1,NoOp(Incoming Twilio DID ${EXTEN})
same => n,Dial(PJSIP/7000,30)
same => n,Voicemail(7000@default,u)
same => n,Hangup()
Calls to 04xx 777 888 now hit an IVR that can route to sales, support, or after‑hours handling instead of a single handset.
Outbound from Extensions
text[ai365pro-internal-outbound]
; Dial 0 + number for outside calls
exten => _0X.,1,NoOp(AI365Pro outbound via Twilio: ${EXTEN})
same => n,Set(CALLED_NUMBER=${EXTEN:1})
same => n,Dial(PJSIP/${CALLED_NUMBER}@twilio-ai365pro-endpoint,60)
same => n,Hangup()
Staff dials a simple prefix for outside calls, and Asterisk automatically routes them over the Twilio trunk.
Enabling Browser‑Based Calling in the CRM
To keep consultants working entirely inside the CRM, we added WebRTC endpoints:
Transport: WSS
Media: DTLS‑SRTP with media_encryption=dtls and rtcp_mux=yes.
NAT handling: rtp_symmetric=yes, force_rport=yes, rewrite_contact=yes.
The CRM at ai365pro.com uses these endpoints to offer a built‑in softphone. Users can:
Answer inbound calls delivered from Twilio via Asterisk.
Place outbound calls with a single click from contact, lead, or opportunity records.
Call recordings and logs are associated with the right customer inside the CRM, so the phone system becomes part of the customer data, not a separate silo.
Security and Reliability
A phone system is only useful if it’s secure and stable, so we added several safeguards:
The cloud firewall only accepts SIP/TLS and RTP from Twilio’s documented SIP IP ranges and from AI365Pro’s VPN, reducing the attack surface.
Trunk and extension passwords are long, random, and rotated regularly.
Fail2ban monitors authentication failures and blocks suspicious IPs.
Monitoring checks trunk registration, call completion rates, and latency, so issues can be detected before users notice.
The Impact for AI365Pro
After go‑live, AI365Pro gained:
A single, professional business number (04xx 777 888) that can be answered by the right person, no matter where they’re working.
Integrated telephony in the CRM, so consultants can see who is calling, click‑to‑call, and review call history without leaving ai365pro.com.
A future‑proof platform where adding new staff or numbers is as simple as creating a new extension or mapping a new DID in Twilio.
The result is a flexible, cloud‑based phone system that matches the way AI365Pro actually works: online, remote‑friendly, and integrated with the tools the team already uses.