コード例 #1
0
def perform_action():
    response = VoiceResponse()
    gather = Gather(input='speech dtmf',
                    timeout=5,
                    num_digits=1,
                    action='/perform')
    gather.say(
        'Say balance or press 1 for your balance,say credit or press 2 for your credit card due date'
    )
    response.append(gather)
    return response.to_xml()
コード例 #2
0
def check_number():
    response = VoiceResponse()
    from_number = request.form.get('From')

    if from_number not in get_blocklist():
        response.redirect(
            os.environ.get(
                'REDIRECT_PATH',
                'https://example.signalwire.com/laml-bins/55ab7685-e9c3-4449-b1f0-07ff083d041e'
            ))

    else:
        response.hangup()

    return response.to_xml()
コード例 #3
0
def start_voice():
    response = VoiceResponse()
    speech = request.form.get('SpeechResult')
    digits = request.form.get('Digits')

    print(speech)
    print(digits)

    if (speech == '1234' or digits == '1234'):
        response.redirect('/ask')
    else:
        gather = Gather(input='speech dtmf', timeout=5, num_digits=4)
        gather.say('Please say or enter your PIN')
        response.append(gather)

    return response.to_xml()
コード例 #4
0
def perform_action():
    response = VoiceResponse()
    speech = request.form.get('SpeechResult')
    digits = request.form.get('Digits')
    replace = ''

    if (speech == 'balance' or digits == '1'):
        response.say('Your balance is: PLACEHOLDER')
        replace = '<say-as interpret-as="currency">' + get_balance(
        ) + '</say-as>'
    if (speech == 'credit' or digits == '2'):
        response.say('Your credit card is due: PLACEHOLDER')
        replace = '<say-as interpret-as="date" format="mdy">' + get_credit_card_due_date(
        ) + '</say-as>'
    else:
        response.redirect('/ask')
    return response.to_xml().replace('PLACEHOLDER', replace)