Connecting LQ SIP to Twilio

Twilio is a decent choice for SIP Account provider for our LQ product, and dialing in from an external device, dialing out through the LQ web GUI, from the Telephone Directory in DynamEC, and via a speed dial in Eclipse works well.

TwiML for inbound calling looks like this:

<?xml version="1.0" encoding="UTF-8"?> 

<Response>

  <Dial>

    <Sip>clearcom-lq@clearcom-lq.sip.twilio.com</Sip>

  </Dial>

</Response>

The clearcom-lq information should be updated as necessary.

For dialing out, basic TwiML looks like this:

<?xml version="1.0" encoding="UTF-8"?> 

<Response>

  <Dial callerId="+5103376660">{{#e164}}{{To}}{{/e164}}</Dial>

</Response>

 

The caller ID will have to be a valid number for your Twilio installation or the call will be rejected (as can be seen via the Debugger. 

Dialing out via a panel through Twilio

 

Devices which send a sequence of numbers individually (rather than all at one time) such as V-Series and I-Stations will not be understood by Twilio.

Instead we use Programmable Voice > Functions > Classic Functions to provide a handler on our SIP account - remember to change the callerId to something valid:

exports.handler = function(context, event, callback) { 

let numberOfDigitsNeeded = 10;

let callerId =  +17729996375;

let wavURL = "https://clearcom.ftpstream.com/download/5Bv8yGFPlomcv0bQ2vKK/AE/Erik/dialtone.mp3";

 let twiml = new Twilio.twiml.VoiceResponse();

 let digitsSoFar = event.To;

 console.log("To: " + digitsSoFar);

 let sipAtSignIndex = digitsSoFar.indexOf("@");

 var remainingDigits = numberOfDigitsNeeded - (sipAtSignIndex-4); // minus whatever we already have

let dialedNumber = ""; 

 if(sipAtSignIndex > 0)

 {

    dialedNumber = digitsSoFar.substring(4, sipAtSignIndex);

 } else {

     console.log("No dialed number detected - waiting for ten digits");

     remainingDigits = numberOfDigitsNeeded;

 }

 console.log("Dialed number so far " + dialedNumber);

 if((event.Digits === undefined) && (remainingDigits > 0))

  {

    // we are trying to get DTMF tones

    console.log("First time into Call Forward for this call");

    console.log("We still need to find " + remainingDigits + " digits");

    const gather = twiml.gather(

        {

        input: "dtmf",

        numDigits: remainingDigits,

        finishOnKey: "#"

        }

        );

   gather.say(remainingDigits + " more digits");

  //gather.play(wavURL);

    } 

    else 

    { // we have DTMF tones and just need to call them

      let phoneNumber = dialedNumber;

      if(event.Digits !== undefined)

      {

          phoneNumber = dialedNumber + event.Digits

      }

      console.log("We have digits - " +  phoneNumber);

        let dialParams = {};

        dialParams.callerId = callerId;

        twiml.say("Calling");

        twiml.say(phoneNumber.split("").join(" "));

        // above line is a hack but say-as interpret as telephone didn't work

        twiml.dial(dialParams, phoneNumber);

    }

  // return the TwiML

  callback(null, twiml);

};

CAN'T FIND YOUR ANSWER? CLICK HERE TO CONTACT SUPPORT


This solution was provided to you by Clear-Com via a question submitted to us by customers like you. If your question wasn’t answered, you need help or you have a recommended solution for our database, please send us an email at support@clearcom.com

The information on this page is owned by Clear-Com and constitutes Clear-Com’s confidential and proprietary information, may be used solely for purposes related to the furtherance of Clear-Com’ business and shall not be disclosed, distributed, copied or disseminated without Clear-Com’s prior written consent. Click Here for Clear-Com's privacy statement.