1

I'm following the Dynamic Call Center with Python and Django to build a simple Django call center. I'm handling outgoing and incoming calls like so:

@csrf_exempt
def CallTaskRouter(request):
    response = VoiceResponse()
    if 'phoneNumber' in request.POST:
        dial = response.dial(caller_id=TWILIO_NUMBER, answer_on_bridge='true')
        dial.number(request.POST['phoneNumber'], 
        status_callback_event='initiated ringing answered completed', 
        status_callback='https://my-url/status', 
        status_callback_method='GET')

    else:
        response = VoiceResponse()
        gather = response.gather(numDigits=1, action='https://my-url/support/enqueue', method="POST")
        gather.say("To speak to support, press one.", language='en-US')
        gather.say("To speak to sales, press two.", language='en-US')
        response.append(gather)

    return HttpResponse(
        str(response), content_type='application/xml; charset=utf-8'
    )

I'd like to notify user when the customer's phone is "ringing" and I'd like to start the call time counter once the call is answered. I use js to setup "device" and initiate the call like so:

device = new Twilio.Device(data.token, { 
            codecPreferences: ['opus', 'pcmu'],
            fakeLocalDTMF: true,
            enableRingingState: true,
        });

function callCustomer(phoneNumber) {
    numberToCall = phoneNumber;
    var params = { phoneNumber: phoneNumber};
    newConnection = device.connect(params); 
    newConnection.on('ringing', function(){
        initiateCallTime();
        console.log('Ringing')
    });
    };

Even though I followed all the inquiries in documentation (answer_on_bridge='true', enableRingingState: true) the connection is starting with "open" state (I used connection.status() function to find out) and doesn't go thought the expected status value ("pending", "connecting", "ringing"...)

Am I missing anything? please help

Adamowicz
  • 23
  • 5
  • Are you using a current version of the SDK? https://www.twilio.com/docs/voice/client/javascript/changelog. – Alan Jun 08 '20 at 11:21
  • I'm using 1.7.7 – Adamowicz Jun 08 '20 at 11:45
  • I see the Changelog mention, `Added support for the answerOnBridge feature of TwiML`. What is the TwiML your application is using? Did you use `answerOnBridge`, https://www.twilio.com/docs/voice/twiml/dial#answeronbridge. – Alan Jun 08 '20 at 12:02
  • Yes, I'm using answer_on_bridge='true' in my dial – Adamowicz Jun 08 '20 at 12:11
  • @Alan thank you for your suggestions, I'm using CDN instead of NPM, do you think this might be a reason? – Adamowicz Jun 09 '20 at 09:45
  • Try the Client Quickstart, it seems to have the logic working, https://www.twilio.com/docs/voice/client/javascript/quickstart. Specifically, look at https://github.com/twilio-labs/function-templates/blob/master/voice-client-javascript/assets/quickstart.js. – Alan Jun 09 '20 at 12:03
  • @Adamowicz did you end up solving this? Running into same issue now. – Murcielago Sep 06 '20 at 21:17
  • @Murcielago, unfortunately no, I just gave up, connection is starting straight with 'open' state even though the settings seem to be correct :( – Adamowicz Sep 07 '20 at 11:20
  • @Adamowicz were you using a trial account? Seems like that's an issue though they don't document it anywhere: https://github.com/twilio/voice-quickstart-ios/issues/178#issuecomment-545608235 – Murcielago Sep 08 '20 at 16:06
  • 1
    @Murcielago Sorry for the delay, yes indeed, I was using a trial account, sad they didn't mention that anywhere, I dropped the on 'ringing' part as I thought it was deprecated. Can you make this an answer? – Adamowicz Sep 17 '20 at 06:24
  • @Adamowicz yeah it's frustrating. I made an answer below. – Murcielago Sep 22 '20 at 02:15

1 Answers1

0

If you are using a trial account for Twilio voice, you can NOT use "ringing" functionality. See here.

I created an issue for it here.

Murcielago
  • 1,030
  • 1
  • 14
  • 24