Register Twilio as extension/endpoint SIP client using username and password - twilio

I have the next situation:
A call is made to a PSTN/DID number of my phone company and that I can use with proprietary SIP cell phone app or SIP client application like Zoiper / Linphone configuring with SIP, user and password.
I cannot configure this service to forward a call to 3rd party service SIP URI. I've already asked it to my PSTN provider and they say that it is impossible.
The question is:
How can I make Twilio (or maybe another service) register as SIP client with user and password (like extension/endpoint ) to receive a call from PSTN and forward it to other SIP URI or phone number?
I know that asterisk / some cloud pbx can do it like it was previously free account at pbxes.com.

Have you considered porting your number to a carrier that will allow you to forward inbound calls to a specific SIP URI you configure or register for calls to that URI, given your current carriers constraints?
For example, Twilio has some documentation here on porting a number.
International Porting
Porting a number To Twilio
I understand, based on your country, this may not be an option.
Twilio does not have a way to register as a SIP client with another provider. It does offer the ability of using a Twilio hosted number (and thus the comment on porting) to register a SIP client against or forward a PSTN call to a SIP User Agent.

Related

Is it possible to make outbound call using SIP to PSTN with Twilio?

What I'm trying to achieve is the following: Use Twilio's Voice API to make an outbound call to a PSTN mobile number, however, instead of using Twilio's routing (which is 10x more expensive than normal SIP providers in my region), I want to use a 3rd-party SIP Trunk to perform the call.
The two areas I can't figure out are:
Can Twilio even do this when using a standard SIP Trunk
And/or, does the SIP Trunk need certain features for this to work (so I can't just signup for any old SIP Trunk)
I see Twilio can dial a SIP URI, however, I can't see how the SIP Trunk will route that call to the PSTN (ie. it seems it can only dial the SIP user as the final destination). Twilio has recently introduced BYOC - https://www.twilio.com/docs/voice/bring-your-own-carrier-byoc - which looked hopeful, however, when setting up the Origination Target you can only provide the SIP URI. This is the technical point I don't really understand, since my SIP Trunk requires a username and password to authenticate before making a call, and the BYOC setup doesn't offer this. Is there some special feature the SIP Trunk needs to work?
I think I'm missing something fundamental here, because I can't see a way of making this work (maybe it's not possible without a very specialized setup). So any help getting on the right track is appreciated (I did try Twilio Support, but they seem as clueless as I am).
So I can answer my own question for anyone coming across this post. You can use a standard SIP Trunk with Twilio's BYOC. Twilio sends an INVITE request to the SIP address entered in as the Origination on the BYOC setup. However, it must use IP address authentication - there's no way to use standard SIP credential authentication.
The ip addresses used depends on the DC it's coming from. See signalling IPs here - https://www.twilio.com/docs/voice/api/sip-interface#ip-address-whitelist
You can also append the "edge" parameter in the Origination SIP URI to dictate which Twilio DC it comes from - https://www.twilio.com/docs/voice/api/receiving-sip#SIP-URI-edge
For additional security, you could consider Twilio's private Interconnect option, or you could append some custom arguments to the SIP URI, which could be authenticated on the SIP Trunk side when it receives the INVITE - however, this would require a custom setup to achieve that, and whatever argument you use for authentication would be visible in the URI.

Transfer call from SIP trunk to Twiml application

I have a phone number registered in Twilio that I wanted to use for both a Twiml application and an Elastic SIP Trunk (connected to Asterisk). The idea is that inbound calls hit the Twiml app first and then can be forwarded to the Asterisk server if needed, while outbound calls just go via the SIP trunk. (The reason it needs to be a SIP trunk instead of simply using SIP Registration with Programmable Voice is because that is the only way to have E911 support for outbound calls.)
Twilio support told me that it is not possible to use the same number for both.
Because of that limitation, my current plan is to use two Twilio phone numbers. My published phone number will go to the Twiml application, and a second number that I will not give out will go to the SIP Trunk. (Twilio allows number spoofing of other numbers on your account, so I will have the Asterisk server pretend to use my primary number for outbound calls instead of using the second private number.)
In order for this to work, I need to be able to transfer calls from my Twiml app to Asterisk and from Asterisk server back to the Twiml application. The former is easy: just use <Dial> with a SIP URL that points to the trunk. The latter is what I need help with. (I also want to do this in case someone does manage to call the second number - I want them to be redirected to the Twiml app.)
As far as I can tell, the only way for me to transfer calls back into my Twiml application is to forward the call from the Asterisk server back to my public number. The problem is that I think this will look like an outgoing+incoming call and I will get double-billed for these minutes. I'm already paying for another number, and I really don't want to have to pay extra for the minutes too.
Is there a better (or "official") way to transfer a call back to the Twiml app? Or am I wrong about Twilio seeing (and billing) this as two calls?
It is not clear why you cannot use the Twilio number for both a Twiml application and an Elastic SIP Trunk (connected to Asterisk). Did they indicate why?
Just don't assign that particular number to your Elastic SIP Trunk and you should be able to assign it to your TwiML application for inbound calls and use a when you want to forward the the call to your Asterisk PBX.
For outbound calls, you can have you Asterisk PBX send calls with that number as CallerID to your Elastic SIP Trunk Termination URI.
For E911 calls from the Twilio Elastic SIP Trunk, you should have a number associated with your Elastic SIP Trunk, enabled for Emergency Calling, so when 911 calls are placed, the CallerID of that number is used for outbound calls and calls can be returned to that number should the connection get disconnected.
If you did go the second route you mentioned, can you have your Asterisk Server send the call to a Twilio Programmable Voice SIP Domain, maybe have a Dial Plan defined so an Asterisk prefix digit sends calls out this different trunk. Not sure this will work (since mixing Elastic SIP Trunking with Programmable Voice in this manner) but one idea. Your Asterisk server will remain in the call path.

Twilio & ThinQ qustion

I know there are some twilio experts here and would really appreciate it if someone could answer a question for us and if so, please let me know if you do freelance work.
Our website offer clients to purchase numbers, which are twilio numbers, and we forward the calls and SMS to their original number, while doing demographics, call recordings and marketing. The number on which call was received is important to us. We want to use Thinq LCR to reduce cost. But Thinq wants us to port the twilio number to them. If we port the twilio number to Thinq, will the existing twilio services break? and on which routing profile will we forward the numbers after porting, if twilio number has been ported to thinq, there's no twilio number to forward anymore. And will we need to change all the code to work with the new Thinq API as twilio is out of the game now?
Thank you!!!
Chip :)
From what I understand of your problem, you should port your existing Twilio DIDs to ThinQ and switch to provisioning new DIDs from ThinQ directly, going forward.
Once the DIDs are visible in the dashboard (i.thinq.com), you would configure them all to route to a Twilio SIP domain that you will need to create. See https://www.thinq.com/thinq-voice-origination-with-twilios-bring-your-own-number-byon-service/ for instructions on how to do this.
With this setup, people trying to reach your clients would dial the DIDs controlled by ThinQ. ThinQ would send the SIP calls over to the Twilio SIP domain which would then interact with your server's callbacks to handle the call.
Your callback would use the appropriate Twilio API (REST or TwiML) to dial the client's actual phone number via SIP so that it goes over your ThinQ VoIP account for lower costs (e.g dial to sip:#wap.thinq.com?thinQid=&thinQtoken= )

Twilio studio connect call to SIP

I'm trying to setup a simple flow using Twilio studio, with the last widget being "Connect call to".
I want to have a caller connected to an agent with a SIP client, registered with the SIP domain in Twilio. The SIP client that's registered to the SIP domain is nothing but a Bria SIP client iOS app that has successfully registered with the SIP domain.
When I type in twilio's SIP domain details as the end point along with the username and password, the flow gets published fine.
When I test the flow by calling the number that triggers the flow, I do get the options as per the flow. I then press certain keys that triggers the "Connect call to" widget in question. At this point, call ends without connecting to the SIP client. I also see this error event, 32009 - The user you tried to dial is not registered with the corresponding SIP Domain.
Am confused. I tried looking into the documentation on Twilio but no luck.
Did you use the below format, making sure to include the us1 subdomain?
USERNAME#SIPDOMAIN.sip.us1.twilio.com

What is the difference between Twilio Elastic SIP Trunking, and Twilio SIP

Basic question here...for making calls in/out of Twilio, between PSTN numbers and SIP endpoints (e.g. PBX), it seems you could accomplish this using 1 of 2 methods:
Twilio SIP (using TwiML for translating between PSTN call and SIP call)
Elastic SIP Trunking
I'm wondering what the main differences in these methods are. It seems that with Twilio SIP you have use of TwiML-based applications, and with SIP Trunking you do not...is that the only difference?
ELASTIC SIP Trunking by Twilio is VoIP Carrier option with Global reach such that Load balancing / geographical redundancy and every other interconnect pain point is handled by Twilio and you can just focus on your application and not worry about interconnect partners and call termination in different countries.
I believe, after having built the partnerships to do the call terminations for applications that were making calls using TwiML, they decided to open the infrastructure to applications that dont necessarily have to be written over TwiML.

Resources