Twilio on SIP Cisco ATA SPA112 / SPA122

by Martin Monperrus

How to use a Twilio SIP trunk account on a Cisco ATA SPA112? Here some hints from my own configuration.

Introduction

There are two ways to use SIP in Twilio, “SIP Domain” and “SIP Trunk” (PSTN numbers can work with both of them). Here, I use a “SIP Trunk” because the configuration is easier. (for a “SI P domain”, one has to write TwiML bins for incoming and outgoing calls, which is not easy).

Prerequisite

First, configure your network, if your ATA is behind NAT, solve the SIP+NAT hell. I use the simplest solution (disable SIP-ALG on the router + static port forwarding for SIP and RTP).

See https://www.voip-info.org/wiki/view/NAT+and+VOIP for alternative solutions.

Option 1: SIP Trunk

No Registration In Twilio, registration is only supported for “Sip Domain”, not for SIP trunks. However, one can make outgoing calls and receive incoming calls without registration, so fill “no” for “Register” in the configuration

Second, fill “yes” for “Make Call Without Reg” and “Ans Call Without Reg” (because registration may fail).

Option 2: SIP Domain

Be careful, the SIP domain registration has to be done against the US1 SERVER, <domain>.sip.us1.twilio.com

Dial plan for Outgoing Calls

For outgoing calls, Twilio requires that the number is prefixed with a plus sign, eg +33678095653. However, this is not possible to dial a plus sign with a good old phone.

The solution is to transform a digit or a digit sequence into a plus sign, with the following dial plan:

  (<00:+>x.|<0:+46>[1-9]x.)

This states that for international numbers that include country code, the “00” is replaced by the + sign. For local number starting with a single “0”, the “0” is replaced by a plus and the country code (Sweden in this case). When I call 0709534615, the ATA actually calls +46709534615 on the SIP server.

Caller ID for Outgoing Calls

Twilio Number By default the caller id for outgoing calls is the user id if it is in international format (without +, eg 46709534615). This means that if you want to have a caller id that corresponds to your Twilio phone number, you have to create a a credential user name that is your Twilio phone number in international format (without +, eg 46709534615).

Other number If you want to use another number, then you have to register it as credential and put it as user id and use the auth id, plus “use auth id = yes”.

Other number (expert) You can also fill the “SIP URI” field, with your number to be used as caller id, for instance 46709534615@mydomain.pstn.twilio.com.

(Note that if you use both an “auth id” and a “user id”, the user id is taken as caller id, but if you use an “auth id”, a “user id” and a “SIP URI”, the number in the SIP URI is taken as caller ID.

Incoming calls

You can receive incoming calls without registration, for this you have the “Origination” of the sip trunk. To receive calls, it must be your ATA SIP URI, sip:<user_name>@<your_public_ip>, for instance sip:46709534615@82.809.32.392.

If you want to avoid hard-coding your public IP, you can use a DNS record (possibly a dynamic DNS).

Receiving calls from Line 2 to Line 1

(This is not specific to Twilio). To use two different SIP accounts and at the same time receive the calls from Line 2 to Line 1 (with one single plugged phone), you have to 1) use the same SIP port number on both lines and 2) use the same “user id” for both lines. In this case, all outgoing calls go through line 1 and the corresponding account.

(On Twilio, you can create any credential user id, so you can duplicate a user id from another provider, and this works).

Documentation

Cisco Small Business SPA100 Series Phone Adapters Administration Guide

Feedback

Tagged as: