Esempio n. 1
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()
def get_menu():
    response = VoiceResponse()

    # read menus from config
    menus = ccConfig['settings']['menus']

    # check to see if a default menu was specified, else default to "main"
    menu = request.values.get("menu")
    if menu not in menus:
        menu = "main"

    # read input_type variable
    input_type = request.values.get("input_type")

    # check if user input was provided via dtmf entry
    if input_type == "dtmf":
        # get digits pressed at menu
        digits = request.values.get("Digits")
        input_action = menus[menu][digits]["action"]
        response.redirect(url=input_action)
        response.hangup()
    else:
        # no user input was detected, so lets present a menu
        gather = Gather(action='/get_menu' + "?menu=" + menu,
                        input='dtmf',
                        timeout="5",
                        method='POST',
                        numDigits="1")

        # loop through menus and generate menu options
        for key in menus[menu]:
            print(key, '->', menus[menu][key]["verbiage"])
            gather.say(menus[menu][key]["verbiage"],
                       voice=ccConfig['settings']['textToSpeech']['voice'])

        # add menu to response
        response.append(gather)
        response.hangup()

    # return response
    return str(response)
Esempio n. 3
0
def get_menu():
    response = VoiceResponse()

    # read menus from json file
    with open('menus.json') as f:
        menus = json.load(f)

    # check to see if a default menu was specified, else default to "main"
    menu = request.values.get("menu")
    if menu not in menus:
        menu = "main"

    # read input_type variable
    input_type = request.values.get("input_type")

    # check if user input was provided via dtmf entry
    if input_type == "dtmf":
        # get digits pressed at menu
        digits = request.values.get("Digits")
        input_action = menus[menu][digits]["action"]
        response.say("you pressed " + digits)
        response.redirect(url=input_action)
        response.hangup()
    else:
        # no user input was detected, so lets present a menu
        gather = Gather(action='/get_menu' + "?menu=" + menu,
                        input='dtmf',
                        timeout="3",
                        method='GET')

        # loop through menus and generate menu options
        for key in menus[menu]:
            print(key, '->', menus[menu][key]["verbiage"])
            gather.say(menus[menu][key]["verbiage"])

        # add menu to response
        response.append(gather)
        response.hangup()

    # return response
    return str(response)
def get_voicemail():
    response = VoiceResponse()
    response.say('You have reached our voicemail, please leave a message.',
                 voice=ccConfig['settings']['textToSpeech']['voice'])
    response.hangup()
    return str(response)
def hangup():
    response = VoiceResponse()
    response.say('Thank you! Good Bye!')
    response.hangup()
    return str(response)
Esempio n. 6
0
def quit_call():
    response = VoiceResponse()
    response.say('Thank you for calling Eagle.net')
    response.hangup()
    return str(response)
Esempio n. 7
0
def dial_prompt():

    # Initialize VoiceResponse
    response = VoiceResponse()

    # check if user input was provided via dtmf entry
    if "SpeechResult" in request.values:

        # Read speech result
        speech_result = request.values.get("SpeechResult")

        # Validate Number Provided
        number = re.sub("[^0-9]", "", speech_result)

        # Make E164
        if len(number) == 11:
            number = "+" + number

        # Assume US Number, Make E164
        elif len(number) == 10:
            number = "+1" + number

        # We did not determine a valide phone number
        else:
            response.say(
                "I am sorry, I did not understand you.  Please try again.",
                voice="man")
            response.redirect("/dial-prompt")
            return str(response)

        # Prompt user
        gather = Gather(action='/dial-verify?number_to_dial=' + number,
                        input='speech',
                        speechTimeout="auto",
                        timeout="10",
                        method='GET')

        # Append say to gather to produce TTS
        gather.say("We detectected " + speech_result +
                   " Would you like me to connect you? ")

        # Append the gather
        response.append(gather)

        # Hangup the call
        response.hangup()

    else:

        # Prompt user
        gather = Gather(action='/dial-prompt',
                        input='speech',
                        speechTimeout="auto",
                        timeout="10",
                        method='GET')

        # Append say to gather to produce TTS
        gather.say("What number would you like to dial?")

        # Append the gather
        response.append(gather)

        # Hangup the call
        response.hangup()

    # return response
    return str(response)
Esempio n. 8
0
def get_voicemail():
    response = VoiceResponse()
    response.say('You have reached our voicemail, please leave a message.')
    response.hangup()
    return str(response)