I am trying to achieve the following use case:
- A caller dials a Twilio number.
- Twilio forwards the call to my Asterisk server.
- Asterisk receives the call from Twilio and immediately connects the caller to sip:test@sip.linphone.org (essentially bridging the caller directly to the SIP address).
- Once the call is connected between the caller and sip:xxxx@sip.linphone.org, Twilio should no longer be involved in the call (to avoid duration charges).
The desired flow is: Caller → Twilio → Asterisk → sip:test@sip.linphone.org
At the end, the connection should be: Caller → sip:test@sip.linphone.org
I understand that I will need to pay Twilio for the incoming and outgoing leg until the caller is connected to Linphone SIP. However, I do not want Twilio to continue counting and charging for the whole call duration once the connection is established between the caller and the SIP address.
Problem: Right now, the call flow works, and the Linphone client receives the call successfully. However, Twilio continues to log the call duration and charge for the entire duration of the call.
Here is my current configuration: These are the complete configurations for receiving calls from Twilio and connecting the caller with Linphone SIP using Asterisk.
extensions.conf:
[from-twilio]
- exten => s,1,NoOp(Call received from Twilio)
- exten =>s,n,NoOp(Forwarding to sip:test@sip.linphone.org)
- exten => s,n,Dial(PJSIP/sip-linphone) ; Forward the call to Linphone SIP address
- exten => s,n,NoOp(Call to sip-linphone ended) exten => s,n,Hangup()
pjsip.conf:
[transport-udp-nat]
- type=transport
- protocol=udp
- bind=0.0.0.0
- local_net=xx.xx.xx.xx/16
- external_media_address=xx.xx.xx.xx
- external_signaling_address=xx.xx.xx.xx
[twilio0-aors]
- type=aor
- contact=sip:test.sip.twilio.com:5060
twilio-trunks
- type=endpoint
- transport=transport-udp-nat
- context=from-twilio
- disallow=all
- allow=ulaw
- direct_media=yes
- force_rport=yes
- rewrite_contact=yes
twilio0
- aors=twilio0-aors
[twilio0-ident]
- type=identify
- endpoint=twilio0
- match=54.172.60.0
- match=54.172.60.1
- match=54.172.60.2
- match=54.172.60.3
[twilio0-auth]
- password=xxxxxx
- username=xxxxxx
[sip-linphone]
- type=endpoint
- transport=transport-udp-nat
- context=from-sip-linphone
- disallow=all
- allow=ulaw
- aors=sip-linphone-aors
- direct_media=yes
- force_rport=yes
- rewrite_contact=yes
[sip-linphone-aors]
- type=aor
- contact=sip:xxxx@sip.linphone.org:5060
[linphone]
- type=endpoint
- context=from-pstn
- disallow=all
- allow=ulaw
- aors=linphone
- refer_blind_progress=yes
[linphone]
- type=aor
- contact=sip:linphone.org
[linphone]
- type=auth
- auth_type=userpass
- password=xxxxx
- username=xxxxx
Question:
- How can I configure Asterisk (or Twilio) so that Twilio disconnects completely after the call is bridged between the caller and sip:xxxx@sip.linphone.org?
- Is there a way to use Transfer or any other method to hand off the call to Asterisk entirely and stop Twilio’s billing?
Any help or guidance would be greatly appreciated! Thank you!