Exemplo n.º 1
0
def get_pin():
    response = VoiceResponse()
    gather = Gather(input='dtmf', timeout=10, num_digits=4)
    gather.say('Please enter your conference pin.')
    response.append(gather)
    response.redirect(url_for('conference.join'), method='GET')
    return str(response)
def voice():
    """Respond to incoming phone calls with a menu of options"""
    # Start our TwiML response
    resp = VoiceResponse()
    caller = request.values.get('From')

    # verify the phone number has access to the call
    name = app.config['KNOWN_PARTICIPANTS'].get(caller)
    if name is None:
        resp.say("Sorry, I don't recognize the number you're calling from.")
        return str(resp)
    
    # TODO - START VERIFICATION

    # Start our <Gather> verb
    gather = Gather(num_digits=6, action='/gather')
    gather.say(
        "Welcome {}. Please enter the 6 digit code sent to your device.".format(
            name))
    resp.append(gather)

    # If the user doesn't select an option, redirect them into a loop
    resp.redirect('/voice')

    return str(resp)
Exemplo n.º 3
0
def answer_incoming_call():
    """
    Receives an incoming call to our Twilio number, which will be missed calls
    from our user's phone number.

    Reads a greeting to the user and gives them a menu of options for what to
    do next.
    """
    # Start our TwiML response
    response = VoiceResponse()

    # If this call wasn't forwarded from our user's phone number, don't answer
    # it
    if request.form['ForwardedFrom'] != app.config['USER_PHONE_NUMBER']:
        response.hangup()
        return str(response)

    # Play a greeting and prompt the user to press a button if they want to
    # leave a voicemail
    gather = Gather(
        num_digits=1,
        timeout=10,  # Wait 10 seconds for them to press a number
        action=url_for('record_message'))
    gather.say(
        "You have reached the voicemail of Andrew Baker. Press 5 to leave a message.",
        voice='Polly.Matthew')
    response.append(gather)

    # If they don't press anything, thank the caller and end the call
    response.say('Thank you for calling. Goodbye.', voice='Polly.Matthew')

    return str(response)
Exemplo n.º 4
0
def language():
    response = VoiceResponse()
    if 'Digits' in request.values:
        language = int(request.values['Digits'])
        if language == 1:
            response.say(en['message4'], voice='Polly.Aditi', language="hi-IN")
            response.say(en['message5'], voice='Polly.Aditi', language="hi-IN")
            gather = Gather(num_digits=2, action='/age/' + str(language))
            response.append(gather)
            return str(response)
        elif language == 2:
            response.say(hi['message4'], voice='Polly.Aditi', language="hi-IN")
            response.say(hi['message5'], voice='Polly.Aditi', language="hi-IN")
            gather = Gather(num_digits=2, action='/age/' + str(language))
            response.append(gather)
            return str(response)
        elif language == 3:
            response.say(ka['message4'], voice='Polly.Aditi', language="hi-IN")
            response.say(ka['message5'], voice='Polly.Aditi', language="hi-IN")
            gather = Gather(num_digits=2, action='/age/' + str(language))
            response.append(gather)
            return str(response)
        else:
            response.redirect('/index')
            return str(response)
    else:
        return str(response)
Exemplo n.º 5
0
def voice():
    """Respond to incoming phone calls with a menu of options"""
    # Start our TwiML response
    resp = VoiceResponse()
    caller = request.values.get('From')
    caller = caller[4:]

    # verify the phone number has access to the call
    from_number = [x for x in KNOWN_PARTICIPANTS if caller in x]

    if not from_number:
        resp.say("Sorry, I don't recognize the number you're calling from.")
        return str(resp)

    name = KNOWN_PARTICIPANTS.get(from_number[0])
    #start_verification(caller)

    # Start our <Gather> verb
    gather = Gather(num_digits=6, action='/gather')
    gather.say(
        "Welcome {}. Please enter the 6 digit code sent to your device.".
        format(name))
    resp.append(gather)

    # If the user doesn't select an option, redirect them into a loop
    resp.redirect('/voice')

    return str(resp)
Exemplo n.º 6
0
def awkward_silence_hotline():
    """awkward silence hotline phoneline"""
    # resp = VoiceResponse()
    # resp.say("Uhhhhhh")

    # return str(resp)
    from_number = request.values.get('From', None)
    if from_number in callers:
        caller = callers[from_number]
    else:
        caller = "Stupid Hacker"

    resp = VoiceResponse()
    # Greet the caller by name
    resp.say("Hello " + caller)

    # # Play an mp3
    # resp.play("http://demo.twilio.com/hellomonkey/monkey.mp3")

    # Gather digits.
    g = Gather(timeout="15", numDigits=1, action="/handle-key", method="POST")
    g.say("""I am the Lord Mayor of Awkward Town, press 1.
             Press 2 for I have foot in mouth disease.
             Press 3 for my boyfriend just broke up with me and I'm pregnant.
             Press 4 for I just can't.
             Press 5 to make your own recording
             Press any other key to start over.""")

    resp.append(g)

    return str(resp)
def voice():
    """Respond to incoming phone calls"""
    resp = VoiceResponse()
    incoming_number = request.values['From']

    # If an unknown number, filter out robo callers and forward to cell
    if incoming_number not in whitelisted_numbers:
        gather = Gather(num_digits=1, action='/buzzer/forward')
        gather.say('Press 1 to continue')
        resp.append(gather)

        return str(resp)

    # Tell the user a nice message that they are not permitted to enter
    if not allowed_to_buzz():
        resp.say(
            "The system cannot let you in. Did you dial the right buzzcode?")
        send_message(
            "A visitor was just rejected as the buzzer system was not unlocked"
        )
        return str(resp)

    # Otherwise, unlock the door
    resp.say(say_message, language='zh-CN')
    resp.play(digits=buzzcode)
    send_message("A visitor was just let in")

    return str(resp)
Exemplo n.º 8
0
def playstation(request):
    dig = request.GET['Digits']
    skipintro = False
    if 'played' in request.GET: skipintro = True
    try:
        song = stationnextsonginternal(t.id)
        sid = song.id
    except:
        rn = Song.objects.last().id
        x = True
        while x:
            sid = random.randint(9000, rn)
            if Song.objects.get(id=sid).filetype == 'mp3': x = False
    resp = VoiceResponse()
    if not skipintro:
        resp.say(
            f"Thank you for chosing station number {dig}. At any point you can press 1 followed by the pound key to dislike and skip this song. Please be kind. The algorithm is still in development.",
            voice='woman',
            language='en-gb')
    gather = Gather(action='/twilio/dislike/' + str(dig) + '/' + str(sid),
                    method='GET',
                    numDigits='1')
    resp.append(gather)
    gather.play('http://5f1c429e.ngrok.io/twilio/playsong/' + str(sid))
    resp.redirect(f'/twilio/playstation?Digits={dig}&played=yes', method='GET')
    return HttpResponse(resp)
Exemplo n.º 9
0
def begin_call():
    print "start /begin_call"
    from_number = request.values.get('From', None)
    if from_number in callers:
        session['caller'] = callers[from_number]
    else:
        session['caller'] = "unknown"

    resp = VoiceResponse()
    if session['caller'] != "unknown":
        resp.say("Hey " + session['caller'] + "!")
        gather = Gather(input='dtmf speech',
                        timeout=5,
                        num_digits=4,
                        action='/set_date',
                        method='GET')
        gather.say(
            "Let's record a new " + os.environ['PODCASTNAME'] +
            "!\n First, when will this episode air?\n Say the air date or punch it in using a Month Month Day Day format.\n For example, you could say October 31st or punch in 10 31."
        )
        resp.append(gather)
        resp.say("You didn't give me a date. Bye!")
    else:
        resp.say("Hey, this isn't for you. \nBoy Bye!")
        resp.hangup()
        session.clear()
    return str(resp)
Exemplo n.º 10
0
def voice():
    """Respond to incoming phone calls with a menu of options"""
    # Start our TwiML response
    resp = VoiceResponse()

    # If Twilio's request to our app included already gathered digits,
    # process them
    if 'Digits' in request.values:
        # Get which digit the caller chose
        choice = request.values['Digits']

        # <Say> a different message depending on the caller's choice
        if choice == '1':
            resp.say('You selected sales. Good for you!')
            return str(resp)
        elif choice == '2':
            resp.say('You need support. We will help!')
            return str(resp)
        else:
            # If the caller didn't choose 1 or 2, apologize and ask them again
            resp.say("Sorry, I don't understand that choice.")

    # Start our <Gather> verb
    gather = Gather(num_digits=1)
    gather.say('For sales, press 1. For support, press 2.')
    resp.append(gather)

    # If the user doesn't select an option, redirect them into a loop
    resp.redirect('/voice')

    return str(resp)
Exemplo n.º 11
0
def handle_gather():
    print("Gathering")
    response = VoiceResponse()
    gather = Gather(input='dtmf', timeout=60, num_digits=11)
    gather.say('Enter your target number')
    response.append(gather)
    return str(response)
Exemplo n.º 12
0
    def _build_twilio_voice_response(
            self, messages: List[Dict[Text, Any]]) -> VoiceResponse:
        """Builds the Twilio Voice Response object."""
        voice_response = VoiceResponse()
        gather = Gather(
            input="speech",
            action=f"/webhooks/{self.name()}/webhook",
            actionOnEmptyResult=True,
            speechTimeout=self.speech_timeout,
            speechModel=self.speech_model,
            enhanced=self.enhanced,
        )

        # Add pauses between messages.
        # Add a listener to the last message to listen for user response.
        for i, message in enumerate(messages):
            msg_text = message["text"]
            if i + 1 == len(messages):
                gather.say(msg_text, voice=self.assistant_voice)
                voice_response.append(gather)
            else:
                voice_response.say(msg_text, voice=self.assistant_voice)
                voice_response.pause(length=1)

        return voice_response
Exemplo n.º 13
0
def answer():
    """Respond to incoming phone calls with a brief message."""
    response = VoiceResponse()
    gather = Gather(input='speech', action='/gather')
    gather.say('Welcome to Wing! Please give any speech input.')
    response.append(gather)
    return str(response)
Exemplo n.º 14
0
def check_human_speech(url):
    response = VoiceResponse()
    gather = Gather(input='speech dtmf', timeout=10, speechTimeout=1, numDigits=1, action=url, hints='accept', finishOnKey='')
    gather.say('To accept this call, press any key or say accept. '*3)
    response.append(gather)
    response.hangup()
    return str(response)
Exemplo n.º 15
0
def voice():
    resp = VoiceResponse()
    print("HERE")
    print(str(resp))
    global isOpen
    global limited
    global numOfOpens
    global password
    if isOpen:
        resp.play(digits='wwwww9')
        time.sleep(2)
        print(str(resp))
        print(str(resp))
        return str(resp)
    if limited and numOfOpens > 0:
        numOfOpens -= 1
        if numOfOpens <= 0:
            limited = False
        open_door(resp)
        return str(resp)
    if password:
        gather = Gather(action='/gather')
        gather.say("Please Enter the password, then press pound")
        resp.append(gather)
        return str(resp)
    else:
        resp.say("Sorry, this apartment is not available right now")
def german_question_2(language, call_id):
    # Start our TwiML response
    resp = VoiceResponse()

    if 'Digits' in request.values:
        # Get which digit the caller chose
        choice = request.values['Digits']

        # <Say> a different message depending on the caller's choice
        if choice in ["1", "2"]:
            edit_call(call_id, "answer_2", int(choice))
            resp.redirect(f"/hotline/{language}/question/3/{call_id}")
            return str(resp)
        else:
            # If the caller didn't choose 1 or 2, apologize and ask them again
            resp.say(
                hotline_translation["question_2_answer_unknown"][language],
                voice="woman",
                language=language)

    gather = Gather(num_digits=1)
    gather.say(hotline_translation["question_2_text_1"][language],
               voice="woman",
               language=language)
    resp.append(gather)

    resp.redirect(f'/hotline/{language}/question/2/{call_id}')

    return str(resp)
def route_verification_phone(api_version):
    resp = VoiceResponse()

    if api_version == "v1":
        # STEP 1) Choose Language

        if 'Digits' in request.values:
            choice = request.values['Digits']

            if choice == '1':
                resp.redirect(f'/verification/{api_version}/de/phone/code')
                return str(resp)
            elif choice == '2':
                resp.redirect(f'/verification/{api_version}/en-gb/phone/code')
                return str(resp)
            else:
                for language in ['de', 'en-gb']:
                    resp.say(hotline_translation['unknown_option'][language], voice='woman', language=language)

        gather = Gather(num_digits=1)
        for language in ['de', 'en-gb']:
            gather.say(hotline_translation['choose_language'][language], voice='woman', language=language)
        resp.append(gather)

        resp.redirect(f'/verification/{api_version}/phone')

    else:
        resp.redirect('/hotline/error/api_version')

    return str(resp)
def route_verification_phone_code(api_version, language):

    resp = VoiceResponse()

    if api_version == "v1":
        if language in ["de", "en-gb"]:
            if 'Digits' in request.values:
                token = request.values['Digits']
                finished_on_key = request.values['FinishedOnKey']

                if len(token) == 5 and finished_on_key == '#':
                    phone_number = routing.get_params_dict(request)['Caller']
                    verification_result = phone_verification.verify(token, phone_number)

                    if verification_result['status'] == 'ok':
                        resp.say(hotline_translation['verification_success'][language], voice='woman', language=language)
                        return str(resp)
                    else:
                        resp.say(hotline_translation['verification_fail'][language], voice='woman', language=language)


            gather = Gather(num_digits=6, finish_on_key='#')
            gather.say(hotline_translation['verification_enter_code'][language], voice='woman', language=language)
            resp.append(gather)

            resp.redirect(f'/backend/{api_version}/{language}/phone/code')
        else:
            resp.redirect('/v1/hotline/error/language')
    else:
        # Programming Error
        resp.redirect('/v1/hotline/error/api_version')

    return str(resp)
Exemplo n.º 19
0
def incoming_voice_call():
    response = VoiceResponse()
    gather = Gather(action='/outbound/voice/call', method='POST')
    gather.say('Please enter the number to dial, followed by the pound sign')
    response.append(gather)
    response.say('We didn\'t receive any input. Goodbye')
    return str(response)
Exemplo n.º 20
0
def voice():
    """Respond to incoming phone calls with a menu of options"""
    # Start our TwiML response
    resp = VoiceResponse()

    # If Twilio's request to our app included already gathered digits,
    # process them
    if 'Digits' in request.values:
        # Get which digit the caller chose
        choice = request.values['Digits']

        # <Say> a different message depending on the caller's choice
        if choice == '1':
            resp.say('You selected sales. Good for you!')
            return str(resp)
        elif choice == '2':
            resp.say('You need support. We will help!')
            return str(resp)
        else:
            # If the caller didn't choose 1 or 2, apologize and ask them again
            resp.say("Sorry, I don't understand that choice.")

    # Start our <Gather> verb
    gather = Gather(numDigits=1)
    gather.say('For sales, press 1. For support, press 2.')
    resp.append(gather)

    # If the user doesn't select an option, redirect them into a loop
    resp.redirect('/voice')

    return str(resp)
Exemplo n.º 21
0
def check_human_key(url):
    response = VoiceResponse()
    gather = Gather(input='dtmf', timeout=10, numDigits=1, action=url, finishOnKey='')
    gather.say('To accept this call, press any key. '*3)
    response.append(gather)
    response.hangup()
    return str(response)
Exemplo n.º 22
0
def gather_input():
    response = VoiceResponse()
    gather = Gather(num_digits=2, action='/handle_input', method="POST")
    gather.say("Please enter a two digit number to play fizz buzz.")
    response.append(gather)
    response.say("You didnt input anything, bye bye.")  # if timeout on entry

    return str(response)
Exemplo n.º 23
0
def voice():
    resp = VoiceResponse()
    gatherName = Gather(input='speech dtmf', action='/summary')
    gatherName.say(callscripts.GreetingString)
    resp.say(callscripts.Thanks)
    resp.append(gatherName)
    resp.redirect('/voice')
    return str(resp)
Exemplo n.º 24
0
def turn():
    resp = VoiceResponse()
    gather = Gather(num_digits=1,
                    action='/hooks/play?roomid={}'.format(
                        request.args.get('roomid')))
    gather.say('Its your turn. Select a digit please')
    resp.append(gather)
    resp.redirect('/hooks/again')
    return str(resp)
Exemplo n.º 25
0
def hello_world():

    response = VoiceResponse()
    gather = Gather(num_digits=1, action='/procNumbers')

    gather.say('For Dining press 1, for busses press 2')
    response.append(gather)
    response.redirect('/')
    return str(response)
Exemplo n.º 26
0
def voice():
    twiml = VoiceResponse()
    gather = Gather(action='/callback',
                    timeout='3',
                    input='speech',
                    partial_result_callback='/partial')
    gather.say('Welcome to Signal Air, where can we take you?')
    twiml.append(gather)
    return str(twiml)
Exemplo n.º 27
0
def callback():

    speech_result = request.values.get("SpeechResult", None).lower()
    resp = MessagingResponse()
    resp.message(speech_result)
    sms_reply.resp.message(speech_result)

    print('SpeechResult:' + speech_result)
    print(sms_reply.z)

    twiml = VoiceResponse()
    if any(c in speech_result for c in endcallarr):

        twiml.say("ok i will end the call now",
                  voice="Polly.Raveena",
                  language="en-IN")
        twiml.redirect('/hangup')
    elif any(c in speech_result for c in jokearr):
        gather = Gather(action="joke",
                        input="speech",
                        partial_result_callback='/partial',
                        speechTimeout="auto",
                        language="en-IN",
                        hints='hindi,english')

        gather.say("hindi or english", voice="Polly.Aditi", language="en-IN")
        twiml.append(gather)
        twiml.redirect('/incoming')
        return str(twiml)

    elif any(c in speech_result for c in chatarr):

        #gather = Gather(action="chat", input="speech", partial_result_callback='/partial', speechTimeout="auto",
        #language="en-IN", hints='chat')

        twiml.say("Now you are transfered to chatting",
                  voice="Polly.Aditi",
                  language="en-IN")
        #twiml.append(gather)
        twiml.redirect('/chat')
        return str(twiml)

    elif "monkey" in speech_result:
        twiml.say("secret code detected")
        twiml.redirect("/resultone")

    else:
        twiml.say(
            'i could not understand what are you saying Please repeat it.',
            voice="Polly.Aditi",
            language="en-IN")

    twiml.redirect('/incoming')

    #twiml.say('You Said' + speech_result, voice="Polly.Aditi", language="en-IN")
    return str(twiml)
Exemplo n.º 28
0
def call():
    from_number = request.form['From']
    if from_number != PRIVATE_NUMBER:
        return perform_call(PRIVATE_NUMBER)
    else:
        response = VoiceResponse()
        g = Gather(action="/aliasing", finish_on_key="#", method="POST")
        g.say("Dial the number you want to call followed by the pound sign")
        response.append(g)
        return str(response)
Exemplo n.º 29
0
def incomingcall(request):
    resp = VoiceResponse()
    resp.say("Welcome to Zaks library radio.", voice='woman', language='en-gb')
    gather = Gather(action='/twilio/playstation', method='GET')
    gather.say(
        "Choose a station followed by the pound key. For the Hip Hop station, press 2, for the Rock station press 3, or press 6 for totally random?",
        voice='woman',
        language='en-gb')
    resp.append(gather)
    return HttpResponse(resp)
Exemplo n.º 30
0
def answer_call():
    global globalSid
    """Respond to incoming phone calls with a brief message."""
    # Start our TwiML response
    resp = VoiceResponse()
    gather = Gather(input='speech', action='/completed', timeout=5)
    if globalSid != request.values['CallSid']:
        gather.say('Hi, Welcome to XPO Support.', voice='woman', language='en')
    resp.append(gather)
    return str(resp)
Exemplo n.º 31
0
def outbound():
    resp = VoiceResponse()
    gather = Gather(input='speech', action='/completed', timeout=5)
    if globalSid != request.values['CallSid']:
        gather.say(
            'Hi, I am Jane, calling on behalf on XPO. Do you have some time to give us a feedback?',
            voice='woman',
            language='en')
    resp.append(gather)
    return str(resp)
Exemplo n.º 32
0
def voice():
    """Respond to incoming phone calls with a menu of options"""
    # Start our TwiML response
    resp = VoiceResponse()

    # Start our <Gather> verb
    gather = Gather(num_digits=1, action='/gather')
    gather.say('For sales, press 1. For support, press 2.')
    resp.append(gather)

    # If the user doesn't select an option, redirect them into a loop
    resp.redirect('/voice')

    return str(resp)
Exemplo n.º 33
0
def test(request):
    resp = VoiceResponse()

    gather = Gather(action="/api/v1/ivr/test/route_call/", method="POST", num_digits=1, timeout=10)
    gather.play(url="https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-welcome.mp3")
    gather.play(url="https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-sales.mp3")
    gather.play(url="https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-customer-service.mp3")
    gather.play(url="https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-accounting.mp3")
    resp.append(gather)

    return HttpResponse(resp)
Exemplo n.º 34
0
from twilio.twiml.voice_response import Gather, VoiceResponse, Say

response = VoiceResponse()
gather = Gather(input='speech', action='/completed')
gather.say('Welcome to Twilio, please tell us why you\'re calling')
response.append(gather)

print(response)
Exemplo n.º 35
0
from twilio.twiml.voice_response import Gather, VoiceResponse, Say

response = VoiceResponse()
gather = Gather(input='speech dtmf', timeout=3, num_digits=1)
gather.say('Please press 1 or say sales for sales.')
response.append(gather)

print(response)
Exemplo n.º 36
0
 def add_gandalf_to_response(response):
     gather = Gather(num_digits=5, action=url_for('.password_entered'))
     challenge_clip = pick_random_file("challenge")
     gather.play(challenge_clip)
     response.append(gather)
     response.redirect(url_for(".gatekeeper", notFirstCall='true'))
Exemplo n.º 37
0
from twilio.twiml.voice_response import Gather, Redirect, VoiceResponse, Say

response = VoiceResponse()
gather = Gather(action='/process_gather.php', method='GET')
gather.say('Enter something, or not')
response.append(gather)
response.redirect('/process_gather.php?Digits=TIMEOUT', method='GET')

print(response)