コード例 #1
0
ファイル: phone.py プロジェクト: robdfct/Wobsite
def ivr():
    r = plivoxml.ResponseElement()
    if request.method == 'GET':
        get_digits_action_url = url_for('phone.ivr', _external=True)
        getDigits = plivoxml.GetDigitsElement(action=get_digits_action_url,
                                              method='POST',
                                              timeout=7,
                                              retries=1)
        getDigits.add_speak(
            ''' Thank you for calling Aldora Capital Partners incorporated.
        if you would like to get information about our lending products. Please press one.
        If you are a broker. And would like to partner with us, to help your clients better. Please press two.
        If you know your parties extension, please press three. 
        For all other inquiries please press zero.  
        ''')

        r.add(getDigits)
        r.add_speak(
            'No input recieved. Thank you for contacting Aldora Capital.')
        return Response(r.to_string(), mimetype='text/xml')

    if request.method == 'POST':
        digit = request.form.get('Digits')
        if digit == '1':
            message = ' We are routing your call to a nearest in house specialist, if they do not pick up the phone, leave them a message and they will get back to you.'

            call_number = phone_tools.get_number(role='sales')
            return phone_tools.get_forward(request,
                                           forward_number=call_number,
                                           message=message)

        elif digit == '2':
            r.add_speak(''' Thank you for your interest in partnering with us.

Please use the contact us page on our website: www.aldora . capital.com
            .And someone from our team will contact you as soon as possible..'''
                        )
        elif digit == '3':
            r.add_redirect(url_for('phone.call_router', _external=True),
                           method='GET')

        elif digit == '0':
            call_number = phone_tools.get_number(role='help')
            return phone_tools.get_forward(request,
                                           forward_number=call_number,
                                           message='Calling Help line.')

        elif len(str(digit)) > 0:
            return phone_tools.get_forward(
                request,
                extension=digit,
                message='Getting Forward to extension')

        else:
            r.add_speak('No input detected, Hanging up.')
        return Response(r.to_string(), mimetype='text/xml')
コード例 #2
0
ファイル: phone.py プロジェクト: robdfct/Wobsite
def call_router():
    r = plivoxml.ResponseElement()

    if request.method == 'GET':
        call_router_url = url_for('phone.call_router', _external=True)
        getDigits = plivoxml.GetDigitsElement(action=call_router_url,
                                              method='POST',
                                              timeout=10,
                                              digit_timeout=3,
                                              retries=1)
        r.add(getDigits)
        getDigits.add_speak('Please enter the extension now.')
        return Response(r.to_string(), mimetype='text/xml')

    if request.method == 'POST':
        extension = request.form.get('Digits')
        return phone_tools.get_forward(request, extension)
コード例 #3
0
    def test_set_methods(self):
        expected_response = '<Response><GetDigits action="https://foo.example.com" digitTimeout="10"' \
            ' finishOnKey="#" invalidDigitsSound="http://foo.audio.url" log="true" method="GET"' \
            ' numDigits="2" playBeep="false" redirect="false" retries="1" timeout="100"' \
            ' validDigits="*"><Speak language="en-US" loop="2" voice="WOMAN">This is test</Speak>' \
            '<Play loop="2">This is test</Play></GetDigits></Response>'

        action = 'https://foo.example.com'
        method = 'GET'
        timeout = 100
        digitTimeout = 10
        finishOnKey = '#'
        numDigits = 2
        retries = True
        redirect = False
        playBeep = False
        validDigits = '*'
        invalidDigitsSound = 'http://foo.audio.url'
        log = True

        content_speak = 'This is test'
        voice_speak = 'WOMAN'
        language_speak = 'en-US'
        loop_speak = 2
        loop_play = 2
        content_play = 'This is test'

        element = plivoxml.ResponseElement()
        response = element.add(
            plivoxml.GetDigitsElement().set_action(action).set_method(method).
            set_redirect(redirect).set_timeout(timeout).set_play_beep(playBeep)
            .set_finish_on_key(finishOnKey).set_digit_timeout(digitTimeout).
            set_timeout(timeout).set_num_digits(numDigits).set_retries(retries)
            .set_valid_digits(validDigits).set_invalid_digits_sound(
                invalidDigitsSound).set_log(log).add_speak(
                    content=content_speak,
                    voice=voice_speak,
                    language=language_speak,
                    loop=loop_speak).add_play(
                        content=content_play, loop=loop_play)).to_string(False)
        self.assertEqual(response, expected_response)