def _list_disease(response): global language with response.gather(numDigits=1, action=url_for('diseaselist'), method="POST") as g: if language == 'h': g.say("Malaria report karne ke liye, 1 dabayein. , , ," + "Dengue report karne ke liye, 2 dabayein. , , ," + "Tuberculosis report karne ke liye, 3 dabayein. , , ," "Main menyoo par jane ke liye 4 dabayein. , , ,", voice="Polly.Aditi", language="hi-IN", loop=3) else: g.say("To report Malaria, press 1." + "To report Dengue, press 2." + "To report Tuberculosis, press 3." "Press 4 to go the main menu.", voice="alice", language="en-GB", loop=3) return twiml(response)
def _give_symp(response): global language with response.gather(numDigits=1, action=url_for('symplist'), method="POST") as g: if language == "h": g.say( ", , khoon ki khaansi honee par 1 dabayein. , , ," + "seene mein dard aur saans lene mein takleef honee par 2 dabayein. , , ," + "tez bukhaar honee par 3 dabayein. , , ," + "yadi adhik paseena aa raha hai, to 4 dabayein. , , ," + "yadi sir dard ho to 5 dabayein. , , " + "rog ke jankari lene ke liye 6 dabayein. , , ,", voice="Polly.Aditi", language="hi-IN", loop=3) else: g.say("For cough and blood, , press 1. , , ," + "For chest pain, , press 2. , , ," + "For high fever, , press 3. , , ," "For profuse sweating, ,press 4. , , ," + "For headache, press 5. , , ," + "To Save and Exit, press 6. , , ,", voice="alice", language="en-GB", loop=3) return twiml(response)
def menu(): sympUpdateSet.clear() diseaseUpdate = -1 selected_option = request.form['Digits'] option_actions = { '1': _give_symp, '2': _list_disease, '3': _callmcd, '9': _redirect_welcome, '0': _disconnect } if option_actions.has_key(selected_option): if selected_option == '3': response = VoiceResponse() _callmcd() return _disconnect(response, "for Municipal Contact") else: response = VoiceResponse() option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
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)
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)
def menu(): selected_option = request.form["SpeechResult"] for option in option_actions: if selected_option in option_actions[option]["keywords"]: response = VoiceResponse() option_actions[option]["function"](response) return twiml(response) return _redirect_welcome()
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)
def menu(): selected_option = request.form['Digits'] option_actions = {'1': _give_instructions, '2': _list_planets} if option_actions.has_key(selected_option): response = VoiceResponse() option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
def menu(): selected_option = request.form['Digits'] option_actions = {'1': _give_instructions, '2': _list_planets} #needed to change for python3 if selected_option in option_actions: response = VoiceResponse() option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
def question_4(): selected_option = request.form['Digits'] option_actions = { '1': _q_5} if selected_option in option_actions: response = VoiceResponse() response.say('Heading on to question 5') option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
def account_menu(): selected_option = request.form['Digits'] option_actions = {'1': _send_account_balance, '2': _lazy_support_agent, } if selected_option in option_actions: response = VoiceResponse() option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
def question_7(): selected_option = request.form['Digits'] option_actions = { '1': bye} if selected_option in option_actions: response = VoiceResponse() response.say('You are done') option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
def menu(): selected_option = request.form['Digits'] option_actions = {'1': _authentication, '2': _lazy_support_agent, } if selected_option in option_actions: response = VoiceResponse() option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
def menu(): selected_option = request.form['Digits'] option_actions = { '1': _q_1 } if option_actions.has_key(selected_option): response = VoiceResponse() option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
def _list_planets(response): with response.gather( numDigits=1, action=url_for('planets'), method="POST" ) as g: g.say("To call the planet Broh doe As O G, press 2. To call the " + "planet DuhGo bah, press 3. To call an oober asteroid " + "to your location, press 4. To go back to the main menu " + " press the star key.", voice="alice", language="en-GB", loop=3) return twiml(response)
def planets(): selected_option = request.form['Digits'] option_actions = {'2': "+12024173378", '3': "+12027336386", "4": "+12027336637"} if selected_option in option_actions: response = VoiceResponse() response.dial(option_actions[selected_option]) return twiml(response) return _redirect_welcome()
def get_user_input_redirect(response,message,number,url,method): while user_data[request.form['Caller']]['count']<=2: #if user_data[request.form['Caller']]['count']>0: #response.say(message="Please give an input.") #sleep(1,response) with response.gather(num_digits=number, action=url_for(url), method=method) as g: g.say(message=message) user_data[request.form['Caller']]['count']=user_data[request.form['Caller']]['count']+1 if user_data[request.form['Caller']]['count']>2: response.say(message="Sorry, we didn't receive any input. Please try again later. Have a nice day!") response.hangup() return twiml(response)
def welcome(): response = VoiceResponse() gather = Gather(input='speech', action='/menu') name = "" for user_data in user_data_list: number_called = request.form["Called"] if number_called == user_data.phone_number: name = user_data.name response_text = "Welcome {}, please choose from one of the following options. To hear your location history, please say 'locations'. To hear your purchase history please say 'purchases'".format( name) gather.say(response_text) response.append(gather) return twiml(response)
def _redirect_welcome(): global language response = VoiceResponse() if language == 'h': response.say("main menyoo par vaapas laut rahe hai", voice="Polly.Aditi", language="hi-IN") else: response.say("Returning to the main menu", voice="alice", language="en-GB") response.redirect(url_for('welcome')) return twiml(response)
def set_UserOTP(): response = VoiceResponse() global user_data user_data[request.form['Caller']]['OTP']=str(request.form['Digits']) print(user_data) print("set otp done") print(verify_otp()) if verify_otp(): _AD_pass_reset() print("Password reset request submitted") response.say("Your new Active Directory password has been sent to your mobile number.") else: response.say("You have entered the wrong OTP. Please try again!") user_data[request.form['Caller']]['count']= 0 get_User_OTP(response) return twiml(response)
def welcome(): app.logger.debug(request.values) caller_phone_number = request.values['Caller'] _user, _factor, _auth = get_user(caller_phone_number) print("_user:"******"_factor:") print(_factor) print("_auth") print(_auth) session['user_id'] = _user['id'] session['factor_id'] = _factor['id'] session['factor_type'] = _factor['factorType'] session['state_token'] = _auth['stateToken'] caller_name = '{first_name} {last_name}'.format(first_name=_user['profile']['firstName'], last_name=_user['profile']['lastName']) caller_city = request.values['CallerCity'] caller_state = request.values['CallerState'] caller_country = request.values['CallerCountry'] _message = "Thanks for calling the {customer_name} automated Service. ".format(customer_name=app.config['APP_CUSTOMER_NAME']) _message += "Nice to meet you {caller_name}. ".format(caller_name=caller_name) _message += "You are calling from {caller_phone_number} in {caller_city} {caller_state} {caller_country}. ".format( caller_phone_number=caller_phone_number, caller_city=caller_city, caller_state=caller_state, caller_country=caller_country ) _menu_message = "Please press 1 to begin accessing your account. " _menu_message += "Press 2 for a list of departments. " response = VoiceResponse() with response.gather( num_digits=1, action=url_for('menu'), method="POST" ) as g: g.say(message=_message, voice='alice', language="en-GB") g.pause(length=2) g.say(message=_menu_message, voice='alice', language="en-GB", loop=3) return twiml(response)
def menu(): ''''print("VIJAY:", request) print("form type:", type(request.form)) print("ditionary:", request.form) for k in request.form.keys(): print(k, request.form[k])''' selected_option = request.form['Digits'] user_data[request.form['Caller']]['count']= 0 option_actions = {'1': _reset_ad_password_get_emp_id} if selected_option in option_actions: response = VoiceResponse() option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
def authenticate(): selected_option = session['factor_type'] print('request') print(request) print('selected_option') print(selected_option) option_actions = {'sms': _send_sms, 'push': _send_okta_push, } if selected_option in option_actions: response = VoiceResponse() option_actions[selected_option](response) return twiml(response) return _redirect_welcome()
def _disconnect(response, op=""): global language if language == 'h': response.say( "aap jald hee aavashyak jaanakaaree" + op + " SMS se praapt karenge , , , , " + "i o haikars helpline par sampark karane ke liye dhanyavaad ", voice="Polly.Aditi", language="hi-IN") else: response.say("You will soon receive the required information " + op + " via SMS " + "Thank you for calling I O Hackers Helpline ", voice="alice", language="en-GB") response.hangup() return twiml(response)
def verify_sms(): _passcode = request.form['Digits'] _factor_id = session['factor_id'] _state_token = session['state_token'] _message = "You enter {passcode}".format(passcode=_passcode) response = VoiceResponse() response.say(message=_message, voice="alice", language="en-GB") valid = sms_mfa_verify(factor_id=_factor_id, state_token=_state_token, pass_code=_passcode) if valid: response.say(message="Forwarding to your account menu.", voice="alice", language="en-GB") response.redirect(url_for('account_welcome')) else: response.say(message="Passcode was incorrect, please try again.", voice="alice", language="en-GB") response.redirect(url_for('authenticate')) return twiml(response)
def _reset_ad_password_send_otp(): user_data[request.form['Caller']]['count']= 0 set_Emp_id() response=VoiceResponse() _AE_generate_OTP() while user_data[request.form['Caller']]['count']<2: response.say("Please wait, we are sending OTP on your mobile number.") response.play('https://raw.githubusercontent.com/itsonlinevijay/demo_clips/master/melodyloops-preview-relaxing-acoustic-0m5s-%5BAudioTrimmer.com%5D.mp3') Wresponse = _get_Ae_Output(user_data[request.form['Caller']]['AEReqId']) if Wresponse: WRJson=json.loads(Wresponse) aeotp=str(WRJson["message"]) if aeotp: break user_data[request.form['Caller']]['count']=user_data[request.form['Caller']]['count']+1 user_data[request.form['Caller']]['count']= 0 get_User_OTP(response) user_data[request.form['Caller']]['count']= 0 print("This is AutomationEdgeRequestId:"+str(user_data[request.form['Caller']]['AEReqId'])) return twiml(response) return _redirect_welcome()
def newelcome(): global callcounter global callerNumber global language callerNumber = request.form['From'].replace('+91', '') # callerNumber = str(callerNumber.encode('utf8')).strip() print 'Caller = ', callerNumber callcounter += 1 response = VoiceResponse() with response.gather(num_digits=1, action=url_for('welcome'), method="POST") as g: g.say(message=", , , For English, press 1", voice='alice', language='en-GB') g.say(message=", , , Hindi ke liye 2 dabayein, ,", voice='Polly.Aditi', language="hi-IN") return twiml(response)
def verify_okta_push(): _factor_id = session['factor_id'] _state_token = session['state_token'] response = VoiceResponse() _success = push_mfa_polling(factor_id=_factor_id, state_token=_state_token) if _success: _message = """ Forwarding to your account menu. """ response.say(message=_message, voice="alice", language="en-GB") response.redirect(url_for('account_welcome')) else: _message = """ Sorry, there was no response from {customer_name} Verify Push. Please call again! """.format(customer_name=app.config['APP_CUSTOMER_NAME']) # noqa: F821 response.say(message=_message, voice="alice", language="en-GB") response.hangup() return twiml(response)
def _redirect_welcome(): response = VoiceResponse() response.say("Returning to the main menu", voice="alice", language="en-GB") response.redirect(url_for('welcome')) return twiml(response)
def account_welcome(): response = VoiceResponse() return twiml(_redirect_account_menu(response))