Пример #1
0
def startRecording():
    resp = VoiceResponse()

    if 'Digits' in request.values and request.values['Digits'] == '1':
        caller = request.values.get("From", None)
        slacktext = '{} pressed 1 and should speak in Dutch.'.format(caller)
        sc.api_call('chat.postMessage',
                    channel=slack_channel,
                    text=slacktext,
                    username=caller,
                    icon_emoji=':phone:')
        resp.record(max_length=120, play_beep=True, action="/end-call-dutch")
    elif 'Digits' in request.values and request.values['Digits'] == '2':
        caller = request.values.get("From", None)
        slacktext = '{} pressed 2 and should speak in English.'.format(caller)
        sc.api_call('chat.postMessage',
                    channel=slack_channel,
                    text=slacktext,
                    username=caller,
                    icon_emoji=':phone:')
        resp.record(max_length=120, play_beep=True, action="/end-call-english")
    else:
        caller = request.values.get("From", None)
        slacktext = '{} punched his phone and should learn to listen.'.format(
            caller)
        sc.api_call('chat.postMessage',
                    channel=slack_channel,
                    text=slacktext,
                    username=caller,
                    icon_emoji=':phone:')
        resp.say(text['recording'])
        resp.gather(num_digits=1, action='/start-recording', timeout=15)

    return str(resp)
Пример #2
0
def voice_question(question):
    twiml_response = VoiceResponse()
    twiml_response.say(question.body)
    twiml_response.say("Please wait for the next question after answering")
    # twiml_response.say(VOICE_INSTRUCTIONS[question.kind])
    action = save_response_url(question)
    if question.kind == Question.TEXT:
        # twiml_response.record(
        #     action=action,
        #     method='POST',
        #     max_length=6,
        #     transcribe=True,
        #     transcribe_callback=action
        # )
        twiml_response.gather(
            action=action,
            method='POST',
            input='dtmf speech',
            language='en-IN',
            hints='Working,capital,amount,companys,current,assets,minus,liabilities, \
Bank,Reconciliation,Statement,prepared,reconcile,balances,cashbook,maintained,concern,periodical,intervals, \
Depreciation,permanent,gradual,continuous,reduction,book,value,fixed',
            timeout=10,
            # partialResultCallback='https://requestb.in/yyekuoyy'
        )
    else:
        twiml_response.gather(action=action, method='POST')
    return twiml_response
Пример #3
0
def receiveCall():
    resp = VoiceResponse()
    resp.say("Welcome to Pillar. "
             "Please enter your 4 digit verification code and press pound.")
    resp.gather(num_digits=4,
                action="https://pillarrestapi.herokuapp.com/verification")
    return str(resp)
Пример #4
0
def situation():
    """Processes the caller's <Gather> input from the welcome view"""
    # Start our TwiML response
    global call_situation_type
    resp = VoiceResponse()

    # If the caller pressed one, start the recording
    if 'Digits' in request.values and request.values['Digits'] == '1':
        call_situation_type = 'critical'
        resp.say("You pressed for critical situation. Please mention only the location after the beep. Beeeeeeeeep.")
             
    elif 'Digits' in request.values and request.values['Digits'] == '2':
        call_situation_type = 'significant'
        resp.say("You pressed for significant situation. Please mention only the location after the beep. Beeeeeeeeep.")
    elif 'Digits' in request.values and request.values['Digits'] == '3':
        call_situation_type = 'minor'
        resp.say("You pressed for minor situation. Please mention only the location after the beep. Beeeeeeeeep.")
    else:
        resp.say("Sorry, I didn't understand that.")
        #resp.say("Press 1 to record a message for the band")
        #resp.gather(numDigits=1, action='/start-recording')

    resp.gather(input='speech',action='/end_call')

    return str(resp)
Пример #5
0
def incoming_call(request):
    """ Returns TwiML instructions to Twilio's POST requests """
    resp = VoiceResponse()
    resp.say("For Programmable SMS, press one. For Voice, press any other key.")
    resp.gather(numDigits=1, action="/call/enqueue", method="POST")

    return HttpResponse(resp)
Пример #6
0
def gather(request,
           action=None,
           method='POST',
           num_digits=None,
           timeout=None,
           finish_on_key=None):
    """
    See: http://www.twilio.com/docs/api/twiml/gather.

    Usage::

        # urls.py
        urlpatterns = patterns('',
            # ...
            url(r'^gather/$', 'django_twilio.views.gather'),
            # ...
        )
    """
    r = VoiceResponse()
    r.gather(action=action,
             method=method,
             numDigits=num_digits,
             timeout=timeout,
             finishOnKey=finish_on_key)
    return r
Пример #7
0
    def on_post(self, req, resp):
        """
        Echo gather instruction in TwiML:

        Example:
            Query strings:

            content: Your alert has been fired.
            instruction: Press 1 to claim alert.
            message_id: 123


            TwiML:

            <?xml version="1.0" ?>
            <Response>
                <Pause length="2"/>
                <Say language="en-US" voice="alice">Press pound for menu.</Say>
                <Gather timeout="0" finishOnKey="#">
                    <Say language="en-US" voice="alice">Your alert has been fired.</Say>
                </Gather>
                <Gather action="http://$endpoint_domain/iris/api/v0/twilio/calls/relay?message_id=123" numDigits="1">
                    <Say language="en-US" voice="alice">Press 1 to claim alert.</Say>
                </Gather>
            </Response>
        """
        content = req.get_param('content', required=True)
        instruction = req.get_param('instruction', required=True)
        message_id = req.get_param('message_id', required=True)
        loop = req.get_param('loop')

        if not message_id.isdigit() and not uuid4hex.match(message_id):
            raise falcon.HTTPBadRequest('Bad message id',
                                        'message id must be int/hex')

        action = self.get_api_url(req.env, 'v0',
                                  'twilio/calls/relay?') + urlencode({
                                      'message_id':
                                      message_id,
                                  })

        r = VoiceResponse()
        if req.get_param('AnsweredBy') == 'machine':
            logger.info("Voice mail detected for message id: %s", message_id)
            r.say(content, voice='alice', language="en-US", loop=loop)
        else:
            r.pause(length=2)
            r.say('Press pound for menu.', voice='alice', language="en-US")

            with r.gather(timeout=0, finishOnKey="#") as g:
                g.say(content, voice='alice', language="en-US")

            with r.gather(numDigits=1, action=action) as g:
                g.say(instruction, voice='alice', loop=loop, language="en-US")

        resp.status = falcon.HTTP_200
        resp.body = str(r)
        resp.content_type = 'application/xml'
Пример #8
0
    def test_empty(self):
        """ a gather with nothing inside """
        r = VoiceResponse()
        r.gather()

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Gather /></Response>'
        )
Пример #9
0
def retrieve_recording():
    resp = VoiceResponse()
    global recording
    recording = request.form.get('RecordingUrl')
    print(recording)

    resp.say(
        "If you would like to hear the message you just recorded, please press 2 now. Otherwise, you may hang up to end the call.",
        voice='alice')
    resp.gather(numDigits=1, action='/play-recording')

    return str(resp)
Пример #10
0
def answer_call():
    #begin twilio response
    resp = VoiceResponse()

    # Read out the base IVR menu option
    resp.say("Welcome to Dr. Brewer's test message line!", voice='alice')
    resp.say("Press 1 to record a message for later use!", voice='alice')

    #grab the next digit entered
    resp.gather(numDigits=1, action='/start-recording')

    return str(resp)
def voice_twiml(question):
    response = VoiceResponse()
    response.say(question.content)
    response.say(VOICE_INSTRUCTIONS[question.kind])

    action_url = url_for('answer', question_id=question.id)
    transcription_url = url_for('answer_transcription',
                                question_id=question.id)
    if question.kind == Question.TEXT:
        response.record(action=action_url,
                        transcribe_callback=transcription_url)
    else:
        response.gather(action=action_url)
    return str(response)
def voice_twiml(question):
    response = VoiceResponse()
    response.say(question.content)
    response.say(VOICE_INSTRUCTIONS[question.kind])

    action_url = url_for('answer', question_id=question.id)
    transcription_url = url_for('answer_transcription',
                                question_id=question.id)
    if question.kind == Question.TEXT:
        response.record(action=action_url,
                        transcribe_callback=transcription_url)
    else:
        response.gather(action=action_url)
    return str(response)
Пример #13
0
def welcome():
    """
    Twilio voice webhook for incoming calls.
    Respond with a welcome message and ask them to press 1
    to record a message for the band.
    """
    # Start our TwiML response
    resp = VoiceResponse()
    resp.say("Welcome to WildSOS")
    resp.say('Press 1 to report for poaching. Press 2 for human wildlife conflict.')
   
    # <Gather> a response from the caller
    resp.gather(numDigits=1, action='/start-recording')

    return str(resp)
Пример #14
0
def voice(request):
    r = VoiceResponse()

    with r.gather(numDigits=1, action='choice') as gather:
        gather.play('http://5ivemarketing.com/static/phone/audio/Memo.mp3')

    return r
Пример #15
0
def handle() -> VoiceResponse:
    response = VoiceResponse()

    # input code
    response.say('please enter your code or press the pound key to be forwarded')
    response.gather(
        method='GET',
        num_digits=config.gather_digits,
        timeout=config.gather_timeout,
    )

    # fallback for no code entered
    response.say('forwarding call')
    response.dial(number=config.fallback_phone)

    return response
Пример #16
0
def choose_movie(request: HttpRequest) -> HttpResponse:
    vr = VoiceResponse()

    digits = request.POST.get('Digits')
    try:
        theater = Theater.objects.get(digits=digits)

    except Theater.DoesNotExist:
        vr.say('登録されている映画館から選択してください', voice='woman', language='ja-JP')
        vr.redirect(reverse('choose-theater'))

    else:
        with vr.gather(
                action=f'{reverse("list-showtimes")}?theater={theater.id}',
                finish_on_key='#',
                timeout=20,
        ) as gather:
            gather.say('映画を選択して、シャープを押してください', voice='woman', language='ja-JP')
            movies = (Movie.objects.filter(
                digits__isnull=False).order_by('digits'))
            for movie in movies:
                gather.say(f' {movie.title} は、 {movie.digits}',
                           voice='woman',
                           language='ja-JP')

        vr.say('選択していません', voice='woman', language='ja-JP')
        vr.redirect(reverse('choose-theater'))

    return HttpResponse(str(vr), content_type='text/xml')
Пример #17
0
def dept():
    resp = VoiceResponse()
    dept_lang = request.values['lang']
    digit = request.values['digit']
    say_dict = {
        'es': [
            "Para ventas oprime uno", "Para apoyo oprime duo",
            "Para finanzas oprime tres"
        ],
        'en': [
            "For sales press one", "For support press two",
            "For billing press three"
        ],
        'fr': [
            u"Pour ventes pressé un", u"Pour soutien pressé deux",
            u"Pour finances pressé tres"
        ]
    }
    with resp.gather(num_digits=digit,
                     action="/enqueue_call?lang=" + dept_lang,
                     timeout="10") as g:
        g.say(say_dict.get(dept_lang)[0], language=dept_lang)
        g.say(say_dict.get(dept_lang)[1], language=dept_lang)
        g.say(say_dict.get(dept_lang)[2], language=dept_lang)
    return str(resp)
def voice_question(question):
    twiml_response = VoiceResponse()

    twiml_response.say(question.body)
    twiml_response.say(VOICE_INSTRUCTIONS[question.kind])

    action = save_response_url(question)
    if question.kind == Question.TEXT:
        twiml_response.record(action=action,
                              method='POST',
                              max_length=6,
                              transcribe=True,
                              transcribe_callback=action)
    else:
        twiml_response.gather(action=action, method='POST')
    return twiml_response
Пример #19
0
def get_cur():
    global index, choice
    response = VoiceResponse()
    n = current
    if n["option"] == "speak":
        response.say(message=n["message"])
    elif n["option"] == "directory":
        response.say(message="Directory: ")
        for key, value in n.items():
            if key != "option":
                response.say(message=key + " at " + value)
    elif n["option"] == "end":
        response.hangup()
    elif n["option"] == "redirect":
        response.dial(n['redirect'])
    elif n["option"] == "choice":
        choice = True
        choices = n['choices']
        with response.gather(numDigits=1, action="/gather") as gather:
            for i in range(len(choices)):
                gather.say(message="Press" + str(i) + " to " + choices[i])
        response.redirect("/cur")

    response.redirect('/next')
    return str(response)
Пример #20
0
def call_menu(request, name):
    response = VoiceResponse()
    menu = get_menu(name)
    items = get_menu_items(menu)

    # start twilio menu response
    with response.gather(
        num_digits=1, action=call_reverse(name, "call-action"), method="POST",
        timeout=10
    ) as g:
        last_digit = -1
        menu_text = ""
        if menu.greeting_text is not None:
            menu_text += menu.greeting_text
        for item in items:
            # skip empty items
            if not item.menu_text and not item.action_text \
                    and not item.action_phone:
                continue
            if last_digit >= item.menu_digit:
                continue

            last_digit = item.menu_digit

            if item.menu_text:
                menu_text += " Press {} {}.".format(item.menu_digit,
                                                    item.menu_text)

        twilio_say(menu, g, menu_text)
    return response
Пример #21
0
def welcome():
    global language

    selected_option = request.form['Digits']
    option_actions = {'1': _setEnglish, '2': _setHindi}

    option_actions[selected_option]()

    response = VoiceResponse()
    with response.gather(num_digits=1, action=url_for('menu'),
                         method="POST") as g:
        if language == 'h':
            g.say(
                message=
                "I O Hackers Helpline ko call karne ke liye dhanyawad, , ,  " +
                "lakshan dene ke liye kripya 1 dabayein , ," +
                "rog ki jaankari praapt karne ke liye 2 dabayein , ," +
                "nikatatam nagarpaalika pratinidhi se sampark karne ke liye 3 dabayein , ,",
                voice="Polly.Aditi",
                language="hi-IN",
                loop=3)
        else:
            g.say(message="Thanks for Calling I O Hacker Helpline , , , " +
                  "Please Press 1 to get symptom wise information , ," +
                  "Press 2 to get disease information , , " +
                  "Press 3 to dial nearest Municipal representative , ,",
                  voice='alice',
                  language='',
                  loop=3)

    return twiml(response)
Пример #22
0
def choose_movie(request: HttpRequest) -> HttpResponse:
    validate_django_request(request)
    vr = VoiceResponse()

    digits = request.POST.get('Digits')
    try:
        theater = Theater.objects.get(digits=digits)

    except Theater.DoesNotExist:
        vr.say('Please select a theater from the list.')
        vr.redirect(reverse('choose-theater'))

    else:
        with vr.gather(
                action=f'{reverse("list-showtimes")}?theater={theater.id}',
                finish_on_key='#',
                timeout=20,
        ) as gather:
            gather.say('Please choose a movie and press #')
            movies = (Movie.objects.filter(
                digits__isnull=False).order_by('digits'))
            for movie in movies:
                gather.say(f'For {movie.title} press {movie.digits}')

        vr.say('We did not receive your selection')
        vr.redirect(reverse('choose-theater'))

    return HttpResponse(str(vr), content_type='text/xml')
Пример #23
0
def welcome():
    response = VoiceResponse()
    with response.gather(
        num_digits=1, action=url_for('menu'), method="POST"
    ) as g:
        g.say(message="Hey, we are from blah team. " +
              "Please press 1 to start the interview. Also pleas enote to continue after each question, press 1" , loop=3)
    return twiml(response)
Пример #24
0
def incoming_call(request):
    """ Returns TwiML instructions to Twilio's POST requests """
    resp = VoiceResponse()
    gather = resp.gather(numDigits=1, action=reverse('enqueue'), method="POST")
    gather.say(
        "For Programmable SMS, press one. For Voice, press any other key.")

    return HttpResponse(resp)
Пример #25
0
def gather(request, action=None, method='POST', num_digits=None, timeout=None,
           finish_on_key=None):
    """
    See: http://www.twilio.com/docs/api/twiml/gather.

    Usage::

        # urls.py
        urlpatterns = patterns('',
            # ...
            url(r'^gather/$', 'django_twilio.views.gather'),
            # ...
        )
    """
    r = VoiceResponse()
    r.gather(action=action, method=method, num_digits=num_digits,
             timeout=timeout, finish_on_key=finish_on_key)
    return r
Пример #26
0
def welcome():
    response = VoiceResponse()
    with response.gather(num_digits=1, action=url_for('menu'),
                         method="POST") as g:
        g.say(message="Thanks for calling the E T Phone Home Service. " +
              "Please press 1 for directions." +
              "Press 2 for a list of planets to call.",
              loop=3)
    return twiml(response)
Пример #27
0
def voice(request: request.HttpRequest):
    try:
        _ = request.META['HTTP_X_TWILIO_SIGNATURE']
        resp = VoiceResponse()
        with resp.gather(num_digits=1, action="/api/menu/", method="POST", timeout=3) as gather:
            gather.say(message="Press 1 to record a message or press 2 stream the voice call.", loop=1)
    
        return HttpResponse(str(resp))
    except KeyError:
        return
Пример #28
0
def gather_digits(request):
    msg = 'Press 1 for text and 2 for voice'
    twilio_response=VoiceResponse()

    with twilio_response.gather(Action='/respond', numDigits=1) as g:
        g.say(msg)
        g.pause(length=1)
        g.say(msg)

    return twilio_response
Пример #29
0
def hello_customer():
    resp = VoiceResponse()
    with resp.gather(num_digits="1",
                     action="/process_digits",
                     method="GET",
                     timeout=10) as g:
        g.say(
            "Hello, welcome to ACMECorp, thanks for calling please select from the following options, for sales press one, for support press, billing press three"
        )
    return Response(str(resp), mimetype="text/xml")
Пример #30
0
def welcome():
    response = VoiceResponse()
    with response.gather(
            num_digits=1, action=url_for('menu'), method="POST"
    ) as g:
        g.say(message="Hello, thank you for calling,,," +
                      "While you wait to speak to a representative, consider playing our fintastic game! "
                      "Please press 1 to start the quiz,,," +
                      "or press 2 for for regular hold music,,,,,", loop=1)
    return twiml_resp(response)
Пример #31
0
def welcome():
    response = VoiceResponse()
    user = request.form['From']
    with response.gather(
        num_digits=1, action=url_for('menu'), method="POST"
    ) as g:
        g.say(message="Welcome to Zuba. "+
              "Please press 1 to go to audio publication. " +
              "Press 2 to subsribe to channel. ", loop=1)
    return twiml(response)
Пример #32
0
def screencall(request):
    twiml = VoiceResponse()
    gather = twiml.gather(action=reverse('ivr:agents_connect_message'))
    phone_number = request.POST['From']
    spelled_phone_number = ' '.join(char for char in phone_number)
    gather.say(spelled_phone_number)
    gather.say('Press any key to accept')
    twiml.say('Sorry. Did not get your response')
    twiml.hangup()
    return HttpResponse(str(twiml))
Пример #33
0
def incoming_call():
    resp = VoiceResponse()
    with resp.gather(num_digits="1",
                     action="/incoming_call/department",
                     timeout=10) as g:
        g.say("Para Espanol oprime el uno.", language='es')
        g.say("For English, press two.", language='en')
        g.say(u"Pour Francais, pressé trois", language='fr')

    return Response(str(resp), mimetype='text/xml')
def voice():

    resp = VoiceResponse()
    # Greet the caller by name
    resp.say("Hello. It's me. ")
    # Play an mp3
    resp.play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3")

    # Gather digits.
    with resp.gather(numDigits=1, action="/handle-gather", method="POST") as g:
        g.say(
            """To speak to a real person, press 1.
                 Press 2 to record a message for a Twilio educator.
                 Press any other key to start over."""
        )

    return str(resp)
Пример #35
0
from twilio.twiml.voice_response import Gather, VoiceResponse

response = VoiceResponse()
response.gather()

print(response)