SIP DID from World to the ITSP to Us
A DID (Direct Inward Calling) number is a phone number that in some way when it is called then originates a SIP call toward a SIP server (the SIP server, in our case FreeSWITCH, will then route the call to its final destination, often an extension phone).
The logical flow is: CALLER -> PSTN -> DID -> ITSP -> SIP -> FreeSWITCH
There are many DIDs providers, maybe the most known pure DID provider is DIDx.net, that can provide local numbers from all around the world. Many ITSPs also can lease you numbers, local to the country they are located and international numbers, and usually they get those numbers from upstream DID providers.
So, we buy (actually, lease, nobody can sell you the ownership of a phone number, you can only pay for its use month by month) a local number from our ITSP, in this case Telnyx. We choose a number in Chicago, USA.
Telnyx is smart enough to use the data from our FreeSWITCH gateway registration (eg our IP address and port) to send us the calls coming from the number we "purchased".
In our case we purchased the DID number "+1-872-203-0716".
We need to add an extension to the incoming "public" dialplan ("public" is the dialplan context where we receive inbound calls from the outside world), so we will be able to connect the incoming call Telnyx send us from our DID number to one of our registered phones .
Edit /usr/local/freeswitch/conf/dialplan/public.xml , and at file beginning add the "telnyx_did" extension, which will transfer the incoming call to the 1012 extension in default dialplan (which will be actually served by the "Local_Extension", as we saw before, that provides a lot of features, voicemail included).
After issuing a "reloadxml" from FreeSWITCH command line, we can use our cellphone to call "+1-872-203-0716" and the call will be routed to our softphone registered as "1012" user. It will start to ring, and if we do not answers, call will go to voicemail to record a voice message.