示例#1
0
def handleGather():
    """
    Process the result of the gather event and either bridge the calls, or update the A-leg
    """
    data = json.loads(request.data)
    if data['digits'] == '1':
        response = Response()
        speak_sentence = SpeakSentence(sentence="The bridge will start now",
                                       voice='julie')
        bridge = Bridge(data['tag'])
        response.add_verb(speak_sentence)
        response.add_verb(bridge)
        return response.to_bxml()
    else:
        updateCall(data['tag'])
        return ''
示例#2
0
def handleOutboundAnswer():
    """
    Perform a gather on the outbound call (B-leg) to determine if they want to accept or reject the incoming call
    """
    data = json.loads(request.data)
    if data['eventType'] != 'answer':
        updateCall(data['tag'])
    else:
        response = Response()
        speak_sentence = SpeakSentence(
            sentence=
            "Please press 1 to accept the call, or any other button to send to voicemail",
            voice="julie")
        gather = Gather(gather_url=urljoin(BASE_URL, '/Outbound/Gather'),
                        terminating_digits="#",
                        max_digits=1,
                        first_digit_timeout=10,
                        speak_sentence=speak_sentence,
                        tag=data['tag'])
        response.add_verb(gather)
        return response.to_bxml()
示例#3
0
def updateCallRoute():
    """
    In the event of a timeout or call screen, update the A-leg call with record bxml to capture a voicemail
    """
    data = json.loads(request.data)
    response = Response()
    speak_sentence = SpeakSentence(
        sentence=
        "The person you are trying to reach is not available, please leave a message at the tone",
        voice='julie')
    play_audio = PlayAudio(
        url="https://www.soundjay.com/button/sounds/beep-01a.wav")
    record = Record(recording_available_url=urljoin(BASE_URL, '/Recording'),
                    recording_available_method='POST',
                    max_duration=30)
    response.add_verb(speak_sentence)
    response.add_verb(play_audio)
    response.add_verb(record)
    return response.to_bxml()
示例#4
0
def handleInboundCallback():
    """
    Handle the inbound call (A-Leg)

    Returns ringing bxml and creates the outbound call (B-leg)
    """
    data = json.loads(request.data)
    createOutboundCall(to=PERSONAL_NUMBER,
                       mfrom=data['from'],
                       callId=data['callId'])

    response = Response()
    speak_sentence = SpeakSentence(
        sentence="Connecting your call, please wait.", voice="julie")

    ring = Ring(duration=30)
    redirect = Redirect(redirect_url=urljoin(BASE_URL, '/UpdateCall'))
    response.add_verb(speak_sentence)
    response.add_verb(ring)
    response.add_verb(redirect)
    return response.to_bxml()