eric-brechemier / how-i-replaced-skype-with-twilio

How I replaced Skype with Twilio to make phone calls from my computer
Creative Commons Attribution 4.0 International
43 stars 9 forks source link
phone phone-number pstn setup sip sms twilio twilio-voice twiml voip

How I replaced Skype with Twilio (2019–2022)

How I replaced Skype with Twilio to make phone calls from my computer.

Motivation

Working remotely, I have become used to the comfort of making calls from my computer on Slack or Discord. Using a quality headset gives a warm sound and a feeling of proximity, and leaves the hands clear for typing on the keyboard and looking up information during the call.

I have been a longtime subscriber of Skype premium service to get a similar experience when calling regular phones instead of other computers. Sadly, as the Skype service stagnated for many years before changing for the worse in 2017–2018, I had to find a better alternative and I started to look into VOIP services with support for calls to the PSTN in 2018–2019.

The Long Story

This is the story of how I successfully configured Twilio to get a mobile phone number which can make and receive calls from my computer.

I have described all the steps that I followed in details, including the understanding that I gained through trial and error, in separate issues:

If you are interested only in how to reproduce my current setup, you can read the short story below. It features links to more details in the long story, if you need them.

The Short Story

1. Create your Twilio account

2. Choose a new phone number

3. Configure SIP

4. Make calls from your computer

<?xml version="1.0" encoding="UTF-8"?>
<!-- Making Calls from SIP to Regular Phones -->
<Response>
  <Dial callerId="{{#e164}}{{SipDomain}}{{/e164}}">
    {{#e164}}{{To}}{{/e164}}
  </Dial>
</Response>

5. Receive calls on your computer

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <!-- Receiving Calls from Regular Phones to SIP -->
  <Dial>
    <Sip>sip:me@1-202-555-0162.sip.us1.twilio.com;transport=tls;secure=true</Sip>
  </Dial>
</Response>

In the above script, replace the user name and domain in the <Sip> element with the identifier of the SIP user that you created, followed with @ and the SIP domain that you created, ending with .sip.us1.twilio.com;transport=tls;secure=true:

<Sip>sip:[SIP User]@[SIP Domain].sip.us1.twilio.com;transport=tls;secure=true</Sip>

6. Configure a voicemail

You can extend the TwiML script which handles incoming calls to forward the caller to voicemail when you fail to answer:

You now have a script of the form:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <!-- Receiving Calls from Regular Phones to SIP (with Voicemail) -->
  <Dial action="https://twimlets.com/forward?FailUrl=https%3A%2F%2Ftwimlets.com%2Fvoicemail%3FEmail%3Dyou%2540example.org%26Message%3Dhttps%253A%252F%252Fyour-runtime-domain.twil.io%252Fassets%252Fgreeting.wav%26Transcribe%3Dfalse&amp;Dial=true">
    <Sip>sip:your-sip-user@your-sip-domain.sip.us1.twilio.com;transport=tls;secure=true</Sip>
  </Dial>
</Response>

where:

7. Configure Pipedream Workflow to Send SMS Messages by Email

When sending an SMS by email, you will need to include the phone number of the recipient, in international format, in the subject, e.g. New SMS to +## ###-###-#####.

{{steps.trigger.event.headers.subject.replace(/^.+\+/,'+').replace(/[^+0-9]/g,'')}}
{{steps.trigger.event.body.text}}

8. Configure Pipedream Workflow to Receive SMS Messages by Email

<?xml version="1.0" encoding="UTF-8" ?>
<Response/>
New SMS from {{steps.trigger.event.body.From}}
{{steps.trigger.event.body.Body}}

Limitations

The current setup does not fulfill all of my expectations yet:

License