async def _fill_out_user_profile(self, flow: ConversationFlow, profile: UserProfile, turn_context: TurnContext): user_input = turn_context.activity.text.strip() # ask for name if flow.last_question_asked == Question.NONE: await turn_context.send_activity( MessageFactory.text("Let's get started. What is your name?")) flow.last_question_asked = Question.NAME # validate name then ask for age elif flow.last_question_asked == Question.NAME: validate_result = self._validate_name(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message)) else: profile.name = validate_result.value await turn_context.send_activity( MessageFactory.text(f"Hi {profile.name}")) await turn_context.send_activity( MessageFactory.text("How old are you?")) flow.last_question_asked = Question.AGE # validate age then ask for date elif flow.last_question_asked == Question.AGE: validate_result = self._validate_age(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message)) else: profile.age = validate_result.value await turn_context.send_activity( MessageFactory.text(f"I have your age as {profile.age}.")) await turn_context.send_activity( MessageFactory.text("When is your flight?")) flow.last_question_asked = Question.DATE # validate date and wrap it up elif flow.last_question_asked == Question.DATE: validate_result = self._validate_date(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message)) else: profile.date = validate_result.value await turn_context.send_activity( MessageFactory.text( f"Your cab ride to the airport is scheduled for {profile.date}." )) await turn_context.send_activity( MessageFactory.text( f"Thanks for completing the booking {profile.name}.")) await turn_context.send_activity( MessageFactory.text("Type anything to run the bot again.")) flow.last_question_asked = Question.NONE
async def _fill_out_user_profile( self, flow: ConversationFlow, profile: UserProfile, turn_context: TurnContext ): user_input = turn_context.activity.text.strip() # ask for name if flow.last_question_asked == Question.NONE: await turn_context.send_activity( MessageFactory.text("Let's get started. What is your name?") ) flow.last_question_asked = Question.NAME # validate name then ask for age elif flow.last_question_asked == Question.NAME: validate_result = self._validate_name(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message) ) else: profile.name = validate_result.value await turn_context.send_activity( MessageFactory.text(f"Hi {profile.name}") ) await turn_context.send_activity( MessageFactory.text("How old are you?") ) flow.last_question_asked = Question.AGE # validate age then ask for date elif flow.last_question_asked == Question.AGE: validate_result = self._validate_age(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message) ) else: profile.age = validate_result.value await turn_context.send_activity( MessageFactory.text(f"I have your age as {profile.age}.") ) await turn_context.send_activity( MessageFactory.text("what is your address?") ) flow.last_question_asked = Question.ADDR # validate date and wrap it up elif flow.last_question_asked == Question.ADDR: validate_result = self._validate_addr(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message) ) else: profile.addr = validate_result.value await turn_context.send_activity( MessageFactory.text( f"Your address {profile.addr} is saved." ) ) await turn_context.send_activity( MessageFactory.text( f"Thanks for completing the booking {profile.name}." ) ) await turn_context.send_activity( MessageFactory.text("Type anything to run the bot again.") ) flow.last_question_asked = Question.NONE flow.CalenderState = State.NONE await self._send_welcome_message(turn_context)
async def _fill_out_user_profile( self, flow: ConversationFlow, profile: UserProfile, turn_context: TurnContext ): user_object = dict(eval(json.dumps(Activity.serialize(turn_context.activity)))) self.update_user_login(user_object) user_input = turn_context.activity.text.strip() # ask for name if flow.last_question_asked == Question.NONE: auth_user = self.get_account_by_login(self.user_skype_login) self.update_user_object(auth_user) if not self.user_skype_object: await turn_context.send_activity( MessageFactory.text("We can't identify you. Please contact to support skype") ) else: await turn_context.send_activity( MessageFactory.text(f"Hello, {self.user_skype_object['name']}") ) self.auth = True if self.user_skype_object else False if self.auth: flow.last_question_asked = Question.ALLOCATION # await turn_context.send_activity( # MessageFactory.text(f"Hello") # ) # flow.last_question_asked = Question.ALLOCATION # validate name then ask for age elif flow.last_question_asked == Question.ALLOCATION: validate_result = self._recognize_allocation(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message) ) else: profile.name = validate_result.value print(profile) await turn_context.send_activity( MessageFactory.text(f"Hi {profile.name}") ) await turn_context.send_activity( MessageFactory.text("How old are you?") ) flow.last_question_asked = Question.NONE # validate age then ask for date elif flow.last_question_asked == Question.AGE: validate_result = self._validate_age(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message) ) else: profile.age = validate_result.value await turn_context.send_activity( MessageFactory.text(f"I have your age as {profile.age}.") ) await turn_context.send_activity( MessageFactory.text("When is your flight?") ) # flow.last_question_asked = Question.DATE # validate date and wrap it up elif flow.last_question_asked == Question.DATE: validate_result = self._validate_date(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message) ) else: profile.date = validate_result.value await turn_context.send_activity( MessageFactory.text( f"Your cab ride to the airport is scheduled for {profile.date}." ) ) await turn_context.send_activity( MessageFactory.text( f"Thanks for completing the booking {profile.name}." ) ) await turn_context.send_activity( MessageFactory.text("Type anything to run the bot again.") ) flow.last_question_asked = Question.NONE