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_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
async def _fill_out_user_profile(self, flow: ConversationFlow, profile: UserProfile, turn_context: TurnContext): # Begins flow process user_input = turn_context.activity.text.strip() # Ask for date; starts conversation flow if flow.last_question_asked == Question.NONE: await turn_context.send_activity( MessageFactory.text( "Let's get started. What date and time would you like to book your movie for?" )) flow.last_question_asked = Question.DATE # Validate date; ask for movie selection elif flow.last_question_asked == Question.DATE: # This is where date must be bound to profile.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"Great! We have a good selection of movies showing at {profile.date}" )) await turn_context.send_activity( MessageFactory.text( "Which movie would you like to watch? Please type the name of the movie as your reply." )) # movies attachment message = Activity(type=ActivityTypes.message) message.text = "Moana, Once Upon a Time in Hollywood, Ready Player One, Sicario, The Girl With the Dragon Tattoo." message.attachments = [self._get_inline_attachment()] await turn_context.send_activity(message) flow.last_question_asked = Question.MOVIE # Validate movie; ask for seat reservations elif flow.last_question_asked == Question.MOVIE: ## This is where movie must be bound to profile.movie validate_result = self._validate_movie(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message)) else: profile.movie = validate_result.value await turn_context.send_activity( MessageFactory.text( f"Sounds good! {profile.movie} is a great pick!")) await turn_context.send_activity( MessageFactory.text("How many seats are you reserving?")) flow.last_question_asked = Question.SEATS # Validate seats; ask about row preferences elif flow.last_question_asked == Question.SEATS: validate_result = self._validate_seats(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message)) else: profile.seats = validate_result.value await turn_context.send_activity( MessageFactory.text( f"You are booking {profile.seats} seats.")) await turn_context.send_activity( MessageFactory.text( "What is your row preference? There are 50 rows in our theater." )) flow.last_question_asked = Question.PREFERENCE # Validate preferences; ask about email elif flow.last_question_asked == Question.PREFERENCE: validate_result = self._validate_preference(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message)) else: profile.preference = validate_result.value await turn_context.send_activity( MessageFactory.text( f"Your row preference has been set as {profile.preference}" )) await turn_context.send_activity( MessageFactory.text( "Please enter your email for booking confirmation.")) flow.last_question_asked = Question.EMAIL # Validate email, confirm by displaying all info, wrap up w/ NONE elif flow.last_question_asked == Question.EMAIL: validate_result = self._validate_email(user_input) if not validate_result.is_valid: await turn_context.send_activity( MessageFactory.text(validate_result.message)) else: profile.email = validate_result.value await turn_context.send_activity( MessageFactory.text( f"You have now completed the booking process.")) await turn_context.send_activity( MessageFactory.text( f"Booking for {profile.email}: {profile.movie} on {profile.date}" )) await turn_context.send_activity( MessageFactory.text( f"You are reserving {profile.seats} seats in row {profile.preference}" )) await turn_context.send_activity( MessageFactory.text("Type anything to run the bot again.")) flow.last_question_asked = Question.NONE #End of flow, able to restart again