def _answer_question(guess): session_id = session.get('sessionId') response, response_type = game.respond_to_guess(session_id, guess) if response_type == constants.game_pb.ResponseType.QUESTION: return question(response) elif response_type == constants.game_pb.ResponseType.STATEMENT: return statement(response)
def repeat_question(): """Repeat the last question for the user""" session_id = session.get('sessionId') user_id = session['user']['userId'] rendered_question, question_id = game.ask_current_question( template_name='ask_question', session_id=session_id, user_id=user_id) title, content = game.display_card(question_id) return question(rendered_question).simple_card(title=title, content=content)
def start_quiz(): session_id = session.get('sessionId') user_id = session['user']['userId'] game.create_game(num_questions=3, session_id=session_id, user_id=user_id) rendered_question, question_id = game.ask_current_question( template_name='ask_question', session_id=session_id, user_id=user_id) title, content = game.display_card(question_id) return question(rendered_question).simple_card(title=title, content=content)
def No_intent(): if "question" in session.get('attributes', {}): if session.attributes['question'] == "Budget_status": output_txt = "You can ask me to Record Expense, Budget Status, Financial suggestion." return question(output_txt) else: output_txt = "Thanks for using Track X powered by J P Morgan. Have a Good day!" return statement(output_txt) output_txt = "Thanks for using Track X powered by J P Morgan. Have a Good day!" return statement(output_txt)
def get_user(): user_object = session.get('user') user_id = user_object.get('userId') user = None try: user = User.objects.get(user_id=user_id) print(user) except Exception as e: logging.error(e) return user
def Yes_intent(): if "question" in session.get('attributes', {}): if session.attributes['question'] == "Budget_status": call = client.calls.create(to='+18574520056', from_=TWILIO_NUMBER, url="http://demo.twilio.com/docs/voice.xml") output_txt = "Calling Mr. Andrew, your financial advisor at J P Morgan." return statement(output_txt) else: output_txt = "You can ask me to Record Expense, Budget Status, Financial suggestion." else: output_txt = "You can ask me to Record Expense, Budget Status, Financial suggestion." return question(output_txt)
def get_cube_otp_intent_handler(request): OTP = request.get_slot_value['OTP'] session = requests.Session() if ("numberOne", "numberTwo", "numberThree") in session.get('attributes'): numberOne = request.get_slot_value['numberOne'] numberTwo = request.get_slot_value['numberTwo'] numberThree = request.get_slot_value['numberThree'] request.session['numberOne'] = numberOne request.session['numberTwo'] = numberTwo request.session['numberThree'] = numberThree numberOne = remove_digits(numberOne) phoneNumber = numberOne + numberTwo + numberThree headers = { 'Authorization': 'Y3ViZWFuZHJvaWRhcHA6Y3ViZWFuZHJvaWRhcHAkMjA4MA==', 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': '58' } payload = { 'identifier': phoneNumber, 'grant_type': 'onetimepass', 'passcode': OTP } resp3 = session.post('https://api.bankoncube.com/v1/api/oauth/token', headers=headers, data=payload) return resp3, OTP else: print("phone number not in database")
def get_headlines(): with open(SECRETS_FILE) as f: secrets = json.load(f) login = { 'username': secrets['username'], 'password': secrets['password'], 'api_type': "json" } session = requests.Session() session.headers.update({'User-agent': "I am testing Alexa: SandChow"}) session.post("https://www.reddit.com/api/login", data=login) time.sleep(1) url = "https://reddit.com/r/worldnews/.json?limit=10" html = session.get(url) data = json.loads(html.content.decode('utf-8')) titles = [ unidecode.unidecode(listing['data']['title']) for listing in data['data']['children'] ] titles = "... ".join([i for i in titles]) return titles