This is basically a vastly simplified version of my previous article on registering an Obihai ATA to Twilio. However, I’ve discovered you can provide emergency calling without having to use an Elastic SIP Trunk. Not only does this simplify the configuration, but it also allows you to use a SIP device that can’t use different services for inbound and outbound calls. Therefore, this article supersedes the old one, and you can use it on any SIP device, Obihai or otherwise; however, the other article has some nice Obihai-specific information, so I’m leaving it up.

Anyway, let’s get started!

  1. Create a new Programmable SIP Domain in the Programmable SIP dashboard:
    • The domain you enter in the “SIP URI” field is the domain you will use to configure your SIP endpoint.
    • In the “Voice Authentication” section, make a new credential list. Create a new username and password for your ATA; save these somewhere for now.
    • Enable the “SIP Registration” section. In the “SIP Registration Authentication” subsection, select the same credential list you created in the previous bullet point.
  2. In the configuration for your SIP endpoint, configure the Twilio SIP Domain service:
    • SIP Server: <your domain>.sip.us1.twilio.com
      • You can use another region, but I’m assuming us1 here.
    • SIP Transport: TCP
    • Registration: Enabled
    • SIP Username and Password: (the credentials you added to your SIP Domain above)
  3. Make a new TwiML Bin; call it something like “Endpoint-Incoming” (you will need one per endpoint, so name it accordingly).
    • Put this in the Bin:
      <?xml version="1.0" encoding="UTF-8"?>
      <Response><Dial answerOnBridge="true"><Sip>sip:mycreduser@mysipdomain.sip.us1.twilio.com</Sip></Dial></Response>

      Replace “mycreduser” with the username you used in the Credential list. Replace “mysipdomain” with the name of the SIP Domain you configured. Note the “us1” – you do have to incldue your selected region here.
    • Copy the Bin URL to your clipboard.
  4. Edit the Twilio phone number that you want to connect to your SIP endpoint.
    • Find the “A Call Comes In” Webhook box, and paste the link to the TwiML Bin into that box.
    • Save the number.

At this point, incoming calls to your SIP endpoint should be working.

Outgoing Calls

  1. Make a new Studio flow called something like “Endpoint-Outgoing” (you will need one per endpoint, so name it accordingly).
    • Make a new “Connect Call To” block as follows:
      • Name: (anything)
      • Connect Call To: Single Number – {{trigger.call.To|split:"@"|first|split:":"|last}}
      • Caller ID: (the same number you edited above)
        • You must use E.164 format; e.g. +12125551212
      • Timeout: At least 60 seconds
    • Connect the Incoming Call trigger to the “Connect Call To” block you just made.
    • Publish the flow.
  2. Edit the phone number again and enable emergency calling for the number.
  3. Edit your SIP Domain:
    • Set the action for “A Call Comes In” to the Studio flow you just made
    • Enable Emergency Calling for the domain
    • Set the Emergency Caller ID for the domain to be your Twilio number for this endpoint
  4. Finagle the dial plan on your SIP endpoint to ensure that both 933 and 911 are permitted (and treated as emergency calls, if that is applicable to your endpoint).

Outgoing calls should now be working on your endpoint. I highly recommend you dial 933 to ensure that the correct Caller ID and E911 address are read back. Enjoy!

Recommended Posts

1 Comment


Add a Comment