/// <summary> /// Sends feedback to be logged. /// </summary> /// <param name="record">FeedbackRecord object to be logged.</param> /// <param name="telemetryClient">IBotTelemetryClient object used to log feedback record<param> public static void LogFeedback(FeedbackRecord record, IBotTelemetryClient telemetryClient) { var properties = new Dictionary <string, string>() { { nameof(FeedbackRecord.Tag), record.Tag }, { nameof(FeedbackRecord.Feedback), record.Feedback }, { nameof(FeedbackRecord.Comment), record.Comment }, { nameof(FeedbackRecord.Request.Text), record.Request?.Text }, { nameof(FeedbackRecord.Request.Id), record.Request?.Conversation.Id }, { nameof(FeedbackRecord.Request.ChannelId), record.Request?.ChannelId }, }; telemetryClient.TrackEvent("Feedback", properties); }
// Will only be included if _feedbackOptions.FeedbackEnabled is set to true private async Task <DialogTurnResult> RequestFeedbackComment(WaterfallStepContext stepContext, CancellationToken cancellationToken) { // Clear feedback state await _feedbackAccessor.DeleteAsync(stepContext.Context).ConfigureAwait(false); var userResponse = stepContext.Context.Activity.Text; if (userResponse == (string)_feedbackOptions.DismissAction.Value) { // user dismissed feedback action prompt return(await stepContext.NextAsync()); } var botResponses = await _previousResponseAccessor.GetAsync(stepContext.Context, () => new List <Activity>()); // Get last activity of previous dialog to send with feedback data var feedbackActivity = botResponses.Count >= 2 ? botResponses[botResponses.Count - 2] : botResponses.LastOrDefault(); var record = new FeedbackRecord() { Request = feedbackActivity, Tag = "EndOfDialogFeedback" }; if (_feedbackOptions.FeedbackActions.Any(f => userResponse == (string)f.Value)) { // user selected a feedback action record.Feedback = userResponse; await _feedbackAccessor.SetAsync(stepContext.Context, record).ConfigureAwait(false); if (_feedbackOptions.CommentsEnabled) { return(await stepContext.PromptAsync(DialogIds.FeedbackPrompt, new PromptOptions() { Prompt = FeedbackUtil.GetFeedbackCommentPrompt(stepContext.Context), })); } else { return(await stepContext.NextAsync()); } } else { // user sent a query unrelated to feedback return(await stepContext.NextAsync(new FeedbackUtil.RouteQueryFlag { RouteQuery = true })); } }