Получить имя очереди, в которой находится вызывающий абонент, Twilio

Я настраиваю телефонное дерево, используя Twilio и Python. Я пытаюсь получить имя очереди, в которой находится вызывающий абонент, чтобы отправить агенту вместе с SMS-оповещением. Я понял, что имя очереди является существительным внутри глагола <Enqueue>, но не могу найти ничего о том, как получить это имя. Код..

Этот раздел отвечает на команду <Gather> и назначает вызывающего абонента в очередь на основе того, что он ввел.

@app.route('/open', methods=['POST'])
def open():
    response = twiml.Response()
    if request.form['Digits'] == "1":
        response.enqueue("general", waitUrl="/wait")
    elif request.form['Digits'] == "2":
        response.enqueue("current", waitUrl="/wait")
    return str(response);

Этот раздел сообщает вызывающему абоненту его позицию в очереди, воспроизводит музыку для удержания и отправляет SMS-сообщение. Там, где в настоящее время есть request.form['QueueSid'], я хочу разместить «понятное имя» очереди, например, «общее».

@app.route('/wait', methods=['POST'])
def wait():
    response = twiml.Response()
    response.say("You are %s in the queue." % request.form['QueuePosition'])
    response.play("http://com.twilio.music.classical.s3.amazonaws.com/BusyStrings.mp3")
    account_sid = "*****"
    auth_token = "*****"
    client = TwilioRestClient(account_sid, auth_token)
    client.sms.messages.create(to="+15555555555", from_="+15555555554", body="A caller is in the call queue - %(num)s in queue %(queue)s" % {"num": request.form['From'], "queue" : request.form['QueueSid']})
    return str(response)

Спасибо!


person NightMICU    schedule 26.03.2013    source источник


Ответы (1)


Оказывается, мне нужно было использовать Twilio client для получения сведений об очереди на основе ее SID. Эти детали включают в себя то, что я искал, friendly_name. Вот обновленный код с решением -

@app.route('/wait', methods=['POST'])
def wait():
    response = twiml.Response()
    response.say("You are %s in the queue." % request.form['QueuePosition'])
    response.play("http://com.twilio.music.classical.s3.amazonaws.com/BusyStrings.mp3")
    account_sid = "*****"
    auth_token = "*****"
    client = TwilioRestClient(account_sid, auth_token)
    queue = client.queues.get(request.form['QueueSid']) #Get the queue based on SID
    friendlyName = queue.friendly_name; #Obtain the queue's Friendly Name
    client.sms.messages.create(to="+15555555555", from_="+15555555554", body="A caller is in the call queue - %(num)s in queue %(queue)s" % {"num": request.form['From'], "queue" : friendlyName}) #SMS with caller ID and queue's friendly name
    return str(response)

Надеюсь, это поможет кому-то .. :)

person NightMICU    schedule 26.03.2013