private async Task <DialogTurnResult> SendResponseToUserAsync( WaterfallStepContext stepContext, CancellationToken cancellationToken) { UserProfile userProfile = await this.state.UserProfile.GetAsync( stepContext.Context, () => new UserProfile(), cancellationToken); userProfile.SurveyState.Progress = ProgressState.InProgress; MultipleChoiceQuestionResponse feedbackResponse = this.HandleUserResponse(stepContext); userProfile.SurveyState.Responses.Add(feedbackResponse); ApprenticeFeedback feedback = userProfile.ToApprenticeFeedback(); await this.feedbackService.SaveFeedbackAsync(feedback); await this.Responses.Create( stepContext.Context, userProfile.SurveyState, this.botSettings, this.features, cancellationToken); // Ask next question return(await stepContext.NextAsync(cancellationToken : cancellationToken)); }
private MultipleChoiceQuestionResponse HandleUserResponse(WaterfallStepContext stepContext) { string utterance = stepContext.Context.Activity.Text; // What did they say? string intent = (stepContext.Result as FoundChoice)?.Value; // What did they mean? bool positive = intent == "yes"; // Was it positive? var feedbackResponse = new MultipleChoiceQuestionResponse() { Question = this.PromptText, Answer = utterance, Intent = intent, Score = positive ? this.PointsAvailable : -this.PointsAvailable, }; return(feedbackResponse); }