예제 #1
0
def language_select():
    r = Result(request.data)
    s = CallSession(r)

    answer = r.getInterpretation()

    s.set('language', answer)

    return redirect(url_for('phone.hello'))
예제 #2
0
    def do_POST(self):
        if "/continue" in self.path:
            content_len = int(self.headers['content-length'])
            post_body = self.rfile.read(content_len)
            print("IN CONTINUE")
            print(post_body)
            self.send_response(200)
            self.send_header('Content-type', 'text/html')
            self.end_headers()
            r = Result(post_body.decode('utf-8'))

            t = Tropo()
            answer = r.getValue()

            if int(answer) == 1:
                t.say(
                    "We are now transferring you to a Charlie Hospital phone operator!   Please wait a moment..."
                )

            elif int(answer) == 2:
                t.say(
                    "Please provide your information:  Your name, ID card, hospital department and doctor!!  We will make the appointment for you!"
                )

            else:
                t.say(
                    "We see from your phone number you have an appointment with Dr.Green on Friday May 5th at 2:30PM."
                )

            print("ANSWER " + answer)

            message = t.RenderJson()
            self.wfile.write(bytes(message, "utf8"))
            return

        else:
            content_len = int(self.headers['content-length'])
            post_body = self.rfile.read(content_len)
            self.send_response(200)
            self.send_header('Content-type', 'text/html')
            self.end_headers()

            print(post_body)
            s = Session(post_body.decode('utf-8'))
            t = Tropo()
            t.ask(
                choices="1,2,3",
                timeout=60,
                name="digit",
                say=
                "Welcome to Charlie Hospital!!  Please press one to speak to phone operator;   Press two to make a new appointment; Press three to check your appointment"
            )
            t.on(event="continue", next=("/continue"))
            message = t.RenderJson()
            self.wfile.write(bytes(message, "utf8"))
            return
예제 #3
0
def index(request):

    r = Result(request.body)
    t = Tropo()

    userType = r.getUserType()

    t.say("You are a " + userType)

    return t.RenderJson()
예제 #4
0
def discern_intention_to_connect_from_answerer(request, provider):
    '''
    Figures out if an answerer wants to answer a call.
    '''
    intends_to_answer = False #Assume that they don't want to answer unless they affirmatively indicate that they do.
    result = Result(request.raw_post_data)  # TODO: Uncouple from tropo
    try:
        if result._actions['disposition'] == "SUCCESS": #If we've found a match....
            vocal_response = result.getValue() #...then grab that match and see.....
            if vocal_response in ["0","1","2","3","4","5","6","7","8","9",SLASHROOT_EXPRESSIONS['phrase_to_answer_call']]: #....if it matches the phrase we're looking for.
                intends_to_answer = True
    except AttributeError:
        return False
    return intends_to_answer
def index(request):

    r = Result(request.body)
    print "request.body : %s" % request.body

    t = Tropo()

    answer = r.getInterpretation()
    value = r.getValue()

    answer1 = r.getNamedActionInterpretation("directory")
    value1 = r.getNamedActionValue("directory")
    t.say("You said " + answer1 + ", which is a " + value1)

    answer2 = r.getNamedActionInterpretation("color")
    value2 = r.getNamedActionValue("color")
    t.say("You also said " + answer2 + ", which is a " + value2)

    count = r.getActionsCount()
    t.say("actions count is  " + str(count))
    for i in range(count):
        answer = r.getIndexdedInterpretation(i)
        value = r.getIndexedValue(i)
        t.say("You said " + answer + ", which is a " + value)

    actions_options_array = [
        'name', 'attempts', 'disposition', 'confidence', 'interpretation',
        'utterance', 'value', 'concept', 'xml', 'uploadStatus'
    ]
    actions = r.getActions()
    if (type(actions) is list):
        for item in actions:
            for opt in actions_options_array:
                print 'action object filed %(actionfieldname)s\'s value is %(vaalue)s' % {
                    'actionfieldname': opt,
                    "vaalue": item.get(opt, 'NoValue')
                }
            print '------------------------------'

    else:
        dict = actions
        for opt in actions_options_array:
            print 'action object filed %(actionfieldname)s\'s value is %(vaalue)s' % {
                'actionfieldname': opt,
                "vaalue": dict.get(opt, 'NoValue')
            }

    json = t.RenderJson()
    print json
    return json
예제 #6
0
def index(request):

    r = Result(request.body)
    print "Result : %s" % r
    #        dump(r)
    t = Tropo()

    answer = r.getInterpretation()

    t.say("You said ")
    t.say(answer, _as="DIGITS")

    json = t.RenderJson()
    print json
    return json
예제 #7
0
def index(request):

	r = Result(request.body)        
        print "Result : %s" % r

	t = Tropo()

	answer = r.getInterpretation()
	value = r.getValue()

	t.say("You said " + answer + ", which is a " + value)

        json = t.RenderJson()
        print json
	return json
예제 #8
0
def verify_yes(request):
	r = Result(request.body)
	t = Tropo()

	answer = r.getValue()

	t.say("You said " + str(answer))

	if answer == "yes" :
		t.say("Ok, just checkin.")
	else :
		t.say("What are you waiting for?")

	json = t.RenderJson()
	print json
	return HttpResponse(json)
예제 #9
0
def hello():
    r = Result(request.data)
    s = CallSession(r)

    t = Tropo()

    s_country = s.get('country')
    s_language = s.get('language')

    if s_country:
        t.say('Country set to %s' % s_country)

    if s_language:
        t.say('Language set to %s' % s_language)

    return t.RenderJson()
예제 #10
0
def country_select():
    r = Result(request.data)
    s = CallSession(r)

    answer = r.getInterpretation()

    s.set('country', answer)

    s_language = s.get('language')
    if not s_language:
        countries = data.get_countries()
        for s_country in countries:
            if s_country['name'].lower() == answer.lower():
                s.set('language', s_country['languages'][0]['name'])

    t = Tropo()
    t.on(event='continue', next=url_for('phone.hello'))

    return t.RenderJson()
예제 #11
0
def country():
    r = Result(request.data)
    s = CallSession(r)

    answer = r.getInterpretation()

    countries = data.country_for_code(answer)

    t = Tropo()

    if not countries:
        t.ask(
            choices='[1-3 DIGITS]',
            name='code',
            say=_('Invalid country code, please try again.'),
            timeout=5,
        )
        t.on(event='continue', next=url_for('phone.country'))
    elif len(countries) == 1:
        t.say(_('You selected'))
        t.say(countries[0]['name'])
        s.set('country', countries[0]['name'])

        t.on(event='continue', next=url_for('phone.hello'))
    else:
        country_list = ', '.join(
            list(map(lambda country: country['name'], countries)))

        t.ask(
            choices=country_list,
            name='country',
            say=_('Please select one of the following countries. %s') %
            country_list,
            timeout=5,
        )
        t.on(event='continue', next=url_for('phone.country_select'))

    return t.RenderJson()
예제 #12
0
def index(request):

    r = Result(request.body)
    print "request.body : %s" % request.body

    t = Tropo()

    answer = r.getInterpretation()
    value = r.getValue()

    t.say("You said " + answer + ", which is a " + value)

    actions_options_array = [
        'name', 'attempts', 'disposition', 'confidence', 'interpretation',
        'utterance', 'value', 'concept', 'xml', 'uploadStatus'
    ]
    actions = r.getActions()
    if (type(actions) is list):
        for item in actions:
            for opt in actions_options_array:
                print 'action object filed %(actionfieldname)s\'s value is %(vaalue)s' % {
                    'actionfieldname': opt,
                    "vaalue": item.get(opt, 'NoValue')
                }
            print '------------------------------'

    else:
        dict = actions
        for opt in actions_options_array:
            print 'action object filed %(actionfieldname)s\'s value is %(vaalue)s' % {
                'actionfieldname': opt,
                "vaalue": dict.get(opt, 'NoValue')
            }

    json = t.RenderJson()
    print json
    return json
예제 #13
0
    def do_POST(self):
        if "/continue" in self.path:
            content_len = int(self.headers['content-length'])
            post_body = self.rfile.read(content_len)
            print("IN CONTINUE")
            print(post_body)
            self.send_response(200)
            self.send_header('Content-type', 'text/html')
            self.end_headers()

            r = Result(post_body.decode('utf-8'))
            t = Tropo()
            answer = r.getValue()
            print("ANSWER " + answer)
            t.say("You chose " + answer)
            t.transfer("+14075550100")
            message = t.RenderJson()
            self.wfile.write(bytes(message, "utf8"))
            return
        else:
            content_len = int(self.headers['content-length'])
            post_body = self.rfile.read(content_len)
            self.send_response(200)
            self.send_header('Content-type', 'text/html')
            self.end_headers()

            print(post_body)
            s = Session(post_body.decode('utf-8'))
            t = Tropo()
            t.ask(choices="0,1,2,3,4,5,6,7,8,9",
                  timeout=60,
                  name="digit",
                  say="Pick a number from 0 to 9")
            t.on(event="continue", next=("/continue"))
            message = t.RenderJson()
            self.wfile.write(bytes(message, "utf8"))
            return