/// <summary>
        /// This method will construct the card for SME team which will have the
        /// feedback details given by the user.
        /// </summary>
        /// <param name="data">User activity payload.</param>
        /// <param name="userDetails">User details.</param>
        /// <param name="localTimestamp">Local timestamp of the user activity.</param>
        /// <returns>Sme facing feedback notification card.</returns>
        public static Attachment GetCard(ShareFeedbackCardPayload data, TeamsChannelAccount userDetails, DateTimeOffset?localTimestamp)
        {
            // Constructing adaptive card that is sent to SME team.
            AdaptiveCard smeFeedbackCard = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
            {
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveTextBlock()
                    {
                        Text   = Strings.SMEFeedbackHeaderText,
                        Weight = AdaptiveTextWeight.Bolder,
                        Size   = AdaptiveTextSize.Large,
                    },
                },
                Actions = new List <AdaptiveAction>
                {
                    new AdaptiveOpenUrlAction
                    {
                        Title     = string.Format(CultureInfo.InvariantCulture, Strings.ChatTextButton, userDetails?.GivenName),
                        UrlString = $"https://teams.microsoft.com/l/chat/0/0?users={Uri.EscapeDataString(userDetails.UserPrincipalName)}",
                    },
                },
            };

            smeFeedbackCard.Body.Add(new AdaptiveFactSet
            {
                Facts = BuildFactSet(data, localTimestamp, userDetails?.Name),
            });

            // Question asked fact and view article show card is available when feedback is on QnA Maker response.
            if (!string.IsNullOrWhiteSpace(data.KnowledgeBaseAnswer) && !string.IsNullOrWhiteSpace(data.UserQuestion))
            {
                smeFeedbackCard.Actions.AddRange(new List <AdaptiveAction>
                {
                    new AdaptiveShowCardAction
                    {
                        Title = Strings.ViewArticleButtonText,
                        Card  = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
                        {
                            Body = new List <AdaptiveElement>
                            {
                                new AdaptiveTextBlock
                                {
                                    Text = CardHelper.TruncateStringIfLonger(data.KnowledgeBaseAnswer, CardHelper.KnowledgeBaseAnswerMaxDisplayLength),
                                    Wrap = true,
                                },
                            },
                        },
                    },
                });
            }

            return(new Attachment
            {
                ContentType = AdaptiveCard.ContentType,
                Content = smeFeedbackCard,
            });
        }
Esempio n. 2
0
 /// <summary>
 /// This method will construct the card for share feedback, when invoked from the feedback card submit.
 /// </summary>
 /// <param name="payload">Payload from the response card.</param>
 /// <returns>Ask an expert card.</returns>
 public static Attachment GetCard(ShareFeedbackCardPayload payload)
 {
     if (payload == null)
     {
         return(null);
     }
     else
     {
         return(GetCard(payload, showValidationErrors: true));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// This method will construct the card for share feedback, when invoked from the response card.
        /// </summary>
        /// <param name="payload">Payload from the response card.</param>
        /// <returns>Ask an expert card.</returns>
        public static Attachment GetCard(ResponseCardPayload payload)
        {
            var cardPayload = new ShareFeedbackCardPayload
            {
                Description         = payload.UserQuestion, // Pre-populate the description with the user's question
                UserQuestion        = payload.UserQuestion,
                KnowledgeBaseAnswer = payload?.KnowledgeBaseAnswer,
            };

            return(GetCard(cardPayload, showValidationErrors: false));
        }
Esempio n. 4
0
        /// <summary>
        /// This method will construct the card for share feedback, when invoked from the response card.
        /// </summary>
        /// <param name="payload">Payload from the response card.</param>
        /// <returns>Ask an expert card.</returns>
        public static Attachment GetCard(ResponseCardPayload payload)
        {
            var data = new ShareFeedbackCardPayload
            {
                Description         = payload.UserQuestion, // Pre-populate the description with the user's question
                UserQuestion        = payload.UserQuestion,
                KnowledgeBaseAnswer = payload.KnowledgeBaseAnswer,
            };

            return(GetCard(false, data));
        }
        /// <summary>
        /// This method will construct the card for share feedback, when invoked from the response card.
        /// </summary>
        /// <param name="payload">Payload from the response card.</param>
        /// <returns>Ask an expert card.</returns>
        public static Attachment GetCard(ResponseCardPayload payload)
        {
            var cardPayload = new ShareFeedbackCardPayload
            {
                UserQuestion          = payload.UserQuestion,
                KnowledgeBaseAnswer   = payload?.KnowledgeBaseAnswer,
                KnowledgeBaseQuestion = payload?.KnowledgeBaseQuestion,
                TicketId = payload?.TicketId,
            };

            return(GetCard(cardPayload, showValidationErrors: false));
        }
 /// <summary>
 /// This method will construct the card  for share feedback bot menu.
 /// </summary>
 /// <param name="data">Data from the share feedback card.</param>
 /// <param name="showValidationErrors">Flag to determine rating value.</param>
 /// <returns>Share feedback card.</returns>
 private static Attachment GetCard(ShareFeedbackCardPayload data, bool showValidationErrors)
 {
     AdaptiveCard shareFeedbackCard = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
     {
         Body = new List <AdaptiveElement>
         {
             new AdaptiveTextBlock
             {
                 Weight = AdaptiveTextWeight.Bolder,
                 Text   = Strings.ShareFeedbackDisplayText,
                 Size   = AdaptiveTextSize.Large,
                 Wrap   = true,
             },
             new AdaptiveTextBlock
             {
                 Weight = AdaptiveTextWeight.Default,
                 Text   = !string.IsNullOrWhiteSpace(data.UserQuestion) ? string.Format(CultureInfo.InvariantCulture, Strings.QuestionTitle, data.UserQuestion) : Strings.ShareFeedbackTitleText,
                 Size   = AdaptiveTextSize.Medium,
                 Wrap   = true,
             },
             new AdaptiveColumnSet
             {
                 Columns = new List <AdaptiveColumn>
                 {
                     new AdaptiveColumn
                     {
                         Width = AdaptiveColumnWidth.Auto,
                         Items = new List <AdaptiveElement>
                         {
                             new AdaptiveTextBlock
                             {
                                 Text = Strings.FeedbackRatingRequired,
                                 Wrap = true,
                             },
                         },
                     },
                     new AdaptiveColumn
                     {
                         Items = new List <AdaptiveElement>
                         {
                             new AdaptiveTextBlock
                             {
                                 Text  = (showValidationErrors && !Enum.TryParse(data.Rating, out FeedbackRating rating)) ? Strings.RatingMandatoryText : string.Empty,
                                 Color = AdaptiveTextColor.Attention,
                                 HorizontalAlignment = AdaptiveHorizontalAlignment.Right,
                                 Wrap = true,
                             },
                         },
                     },
                 },
             },
        /// <summary>
        /// Return the appropriate fact set based on the state and information in the ticket.
        /// </summary>
        /// <param name="data">User activity payload.</param>
        /// <param name="localTimestamp">The current timestamp.</param>
        /// <param name="userName">The user who sent the feeback.</param>
        /// <returns>The fact set showing the necessary details.</returns>
        private static List <AdaptiveFact> BuildFactSet(ShareFeedbackCardPayload data, DateTimeOffset?localTimestamp, string userName)
        {
            List <AdaptiveFact> factList = new List <AdaptiveFact>();

            if (string.IsNullOrEmpty(data.TicketId))
            {
                factList.Add(new AdaptiveFact
                {
                    Title = Strings.QuestionMessageFeedbackText,
                    Value = data.UserQuestion,
                });
            }
            else
            {
                factList.Add(new AdaptiveFact
                {
                    Title = Strings.QuestionMessageFeedbackText,
                    Value = string.Format(CultureInfo.InvariantCulture, Strings.SMEFeedbackTicketIDFact, data.TicketId, data.UserQuestion),
                });
            }

            factList.Add(new AdaptiveFact
            {
                Title = Strings.RatingTitle,
                Value = GetRatingDisplayText(data?.Rating),
            });

            // Description fact is available in the card only when user enters description text.
            if (!string.IsNullOrWhiteSpace(data.Description))
            {
                factList.Add(new AdaptiveFact
                {
                    Title = Strings.DescriptionText,
                    Value = CardHelper.TruncateStringIfLonger(data.Description, CardHelper.DescriptionMaxDisplayLength),
                });
            }

            factList.Add(new AdaptiveFact
            {
                Title = Strings.DateFactTitle,
                Value = CardHelper.GetFormattedDateInUserTimeZone(DateTime.Now, localTimestamp),
            });

            factList.Add(new AdaptiveFact
            {
                Title = Strings.ProvidedByFact,
                Value = userName,
            });

            return(factList);
        }
Esempio n. 8
0
        /// <summary>
        /// This method will construct the card for share feedback, when invoked from the response card.
        /// </summary>
        /// <param name="payload">Payload from the response card.</param>
        /// <param name="appBaseUri">The base URI where the app is hosted.</param>
        /// <returns>Ask an expert card.</returns>
        public static Attachment GetCard(ResponseCardPayload payload, string appBaseUri)
        {
            var cardPayload = new ShareFeedbackCardPayload
            {
                DescriptionHelpful          = payload.UserQuestion,    // Pre-populate the description with the user's question
                DescriptionNeedsImprovement = payload.UserQuestion,    // Pre-populate the description with the user's question
                DescriptionNotHelpful       = payload.UserQuestion,    // Pre-populate the description with the user's question
                UserQuestion        = payload.UserQuestion,
                KnowledgeBaseAnswer = payload?.KnowledgeBaseAnswer,
                Project             = payload.Project,
            };

            return(GetCard(cardPayload, showValidationErrors: false, appBaseUri));
        }
 private static Attachment GetCard(ShareFeedbackCardPayload data, bool showValidationErrors)
 {
     var shareFeedbackCard = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
     {
         Body = new List <AdaptiveElement>
         {
             new AdaptiveTextBlock
             {
                 Weight = AdaptiveTextWeight.Bolder,
                 Text   = !string.IsNullOrWhiteSpace(data.UserQuestion)
                     ? "todo ResultsFeedbackText"
                     : "todo ShareFeedbackTitleText",
                 Size = AdaptiveTextSize.Large,
                 Wrap = true,
             },
             new AdaptiveColumnSet
             {
                 Columns = new List <AdaptiveColumn>
                 {
                     new AdaptiveColumn
                     {
                         Width = AdaptiveColumnWidth.Auto,
                         Items = new List <AdaptiveElement>
                         {
                             new AdaptiveTextBlock
                             {
                                 Text = !string.IsNullOrWhiteSpace(data.UserQuestion)
                                     ? "todo FeedbackRatingRequired"
                                     : "todo ShareAppFeedbackRating",
                                 Wrap = true,
                             },
                         },
                     },
                     new AdaptiveColumn
                     {
                         Items = new List <AdaptiveElement>
                         {
                             new AdaptiveTextBlock
                             {
                                 Text = (showValidationErrors && !Enum.TryParse(data.Rating, out FeedbackRating rating))
                                     ? "todo RatingMandatoryText"
                                     : string.Empty,
                                 Color = AdaptiveTextColor.Attention,
                                 HorizontalAlignment = AdaptiveHorizontalAlignment.Right,
                                 Wrap = true,
                             },
                         },
                     },
                 },
             },
Esempio n. 10
0
        /// <summary>
        /// This method will construct the card  for share feedback bot menu.
        /// </summary>
        /// <param name="data">Data from the share feedback card.</param>
        /// <param name="showValidationErrors">Flag to determine rating value.</param>
        /// <returns>Share feedback card.</returns>
        private static Attachment GetCard(ShareFeedbackCardPayload data, bool showValidationErrors)
        {
            var textAlignment  = CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ? AdaptiveHorizontalAlignment.Right : AdaptiveHorizontalAlignment.Left;
            var errorAlignment = CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ? AdaptiveHorizontalAlignment.Left : AdaptiveHorizontalAlignment.Right;

            AdaptiveCard shareFeedbackCard = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
            {
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveTextBlock
                    {
                        Weight = AdaptiveTextWeight.Bolder,
                        Text   = !string.IsNullOrWhiteSpace(data.UserQuestion) ? Strings.ResultsFeedbackText : Strings.ShareFeedbackTitleText,
                        Size   = AdaptiveTextSize.Large,
                        Wrap   = true,
                        HorizontalAlignment = textAlignment,
                    },
                    new AdaptiveColumnSet
                    {
                        Columns = new List <AdaptiveColumn>
                        {
                            new AdaptiveColumn
                            {
                                Width = AdaptiveColumnWidth.Auto,
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        Text = !string.IsNullOrWhiteSpace(data.UserQuestion) ? Strings.FeedbackRatingRequired : Strings.ShareAppFeedbackRating,
                                        Wrap = true,
                                        HorizontalAlignment = textAlignment,
                                    },
                                },
                            },
                            new AdaptiveColumn
                            {
                                Items = new List <AdaptiveElement>
                                {
                                    new AdaptiveTextBlock
                                    {
                                        Text  = (showValidationErrors && !Enum.TryParse(data.Rating, out FeedbackRating rating)) ? Strings.RatingMandatoryText : string.Empty,
                                        Color = AdaptiveTextColor.Attention,
                                        HorizontalAlignment = errorAlignment,
                                        Wrap = true,
                                    },
                                },
                            },
                        },
                    },
Esempio n. 11
0
 /// <summary>
 /// This method will construct the card  for share feedback bot menu.
 /// </summary>
 /// <param name="showValidationErrors">Flag to determine rating value.</param>
 /// <param name="data">Data from the share feedback card.</param>
 /// <returns>Share feedback card.</returns>
 private static Attachment GetCard(bool showValidationErrors, ShareFeedbackCardPayload data)
 {
     AdaptiveCard shareFeedbackCard = new AdaptiveCard("1.0")
     {
         Body = new List <AdaptiveElement>
         {
             new AdaptiveTextBlock
             {
                 Weight = AdaptiveTextWeight.Bolder,
                 Text   = !string.IsNullOrWhiteSpace(data.UserQuestion) ? Resource.ResultsFeedbackText : Resource.ShareFeedbackTitleText,
                 Size   = AdaptiveTextSize.Large,
                 Wrap   = true
             },
             new AdaptiveColumnSet
             {
                 Columns = new List <AdaptiveColumn>
                 {
                     new AdaptiveColumn
                     {
                         Width = AdaptiveColumnWidth.Auto,
                         Items = new List <AdaptiveElement>
                         {
                             new AdaptiveTextBlock
                             {
                                 Text = Resource.FeedbackRatingRequired,
                                 Wrap = true
                             }
                         }
                     },
                     new AdaptiveColumn
                     {
                         Items = new List <AdaptiveElement>
                         {
                             new AdaptiveTextBlock
                             {
                                 Text  = (showValidationErrors && !Enum.TryParse(data.Rating, out FeedbackRating rating)) ? Resource.RatingMandatoryText : string.Empty,
                                 Color = AdaptiveTextColor.Attention,
                                 HorizontalAlignment = AdaptiveHorizontalAlignment.Right,
                                 Wrap = true
                             }
                         }
                     }
                 },
             },
        /// <summary>
        /// Create a new Feedback entity from the input.
        /// </summary>
        /// <param name="message">A message in a conversation.</param>
        /// <param name="data">Represents the submit data associated with the Share feedback card.</param>
        /// <param name="member">Teams channel account detailing user Azure Active Directory details.</param>
        /// <param name="feedbackProvider">Tickets Provider.</param>
        /// <returns>TicketEntity object.</returns>
        private static async Task <FeedbackEntity> CreateFeedbackAsync(
            IMessageActivity message,
            ShareFeedbackCardPayload data,
            TeamsChannelAccount member,
            IFeedbackProvider feedbackProvider)
        {
            string description = null;

            if (data.Rating == nameof(FeedbackRating.Helpful))
            {
                description = data.DescriptionHelpful;
            }
            else if (data.Rating == nameof(FeedbackRating.NeedsImprovement))
            {
                description = data.DescriptionNeedsImprovement;
            }
            else if (data.Rating == nameof(FeedbackRating.NotHelpful))
            {
                description = data.DescriptionNotHelpful;
            }

            FeedbackEntity feedbackEntity = new FeedbackEntity
            {
                FeedbackId          = Guid.NewGuid().ToString(),
                UserPrincipalName   = member.UserPrincipalName,
                UserName            = member.Name,
                UserGivenName       = member.GivenName,
                Rating              = data.Rating,
                Description         = description,
                UserQuestion        = data.UserQuestion,
                KnowledgeBaseAnswer = data.KnowledgeBaseAnswer,
                Subject             = data.Project,
            };

            await feedbackProvider.UpsertFeecbackAsync(feedbackEntity).ConfigureAwait(false);

            return(feedbackEntity);
        }
Esempio n. 13
0
        /// <summary>
        /// This method will construct the card for SME team which will have the
        /// feedback details given by the user.
        /// </summary>
        /// <param name="data">User activity payload.</param>
        /// <param name="userDetails">User details.</param>
        /// <returns>Sme facing feedback notification card.</returns>
        public static Attachment GetCard(ShareFeedbackCardPayload data, TeamsChannelAccount userDetails)
        {
            var textAlignment = CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ? AdaptiveHorizontalAlignment.Right : AdaptiveHorizontalAlignment.Left;

            // Constructing adaptive card that is sent to SME team.
            AdaptiveCard smeFeedbackCard = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
            {
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveTextBlock()
                    {
                        Text   = Strings.SMEFeedbackHeaderText,
                        Weight = AdaptiveTextWeight.Bolder,
                        Size   = AdaptiveTextSize.Medium,
                        HorizontalAlignment = textAlignment,
                    },
                    new AdaptiveTextBlock()
                    {
                        Text = string.Format(CultureInfo.InvariantCulture, Strings.FeedbackAlertText, userDetails?.Name),
                        Wrap = true,
                        HorizontalAlignment = textAlignment,
                    },
                    new AdaptiveTextBlock()
                    {
                        Text   = Strings.RatingTitle,
                        Weight = AdaptiveTextWeight.Bolder,
                        Wrap   = true,
                        HorizontalAlignment = textAlignment,
                    },
                    new AdaptiveTextBlock()
                    {
                        Text                = GetRatingDisplayText(data?.Rating),
                        Spacing             = AdaptiveSpacing.None,
                        Wrap                = true,
                        HorizontalAlignment = textAlignment,
                    },
                },
                Actions = new List <AdaptiveAction>
                {
                    new AdaptiveOpenUrlAction
                    {
                        Title     = string.Format(CultureInfo.InvariantCulture, Strings.ChatTextButton, userDetails?.GivenName),
                        UrlString = $"https://teams.microsoft.com/l/chat/0/0?users={Uri.EscapeDataString(userDetails.UserPrincipalName)}",
                    },
                },
            };

            // Description fact is available in the card only when user enters description text.
            if (!string.IsNullOrWhiteSpace(data.Description))
            {
                smeFeedbackCard.Body.Add(new AdaptiveTextBlock()
                {
                    Text   = Strings.DescriptionText,
                    Weight = AdaptiveTextWeight.Bolder,
                    Wrap   = true,
                    HorizontalAlignment = textAlignment,
                });

                smeFeedbackCard.Body.Add(new AdaptiveTextBlock()
                {
                    Text                = CardHelper.TruncateStringIfLonger(data.Description, CardHelper.DescriptionMaxDisplayLength),
                    Spacing             = AdaptiveSpacing.None,
                    Wrap                = true,
                    HorizontalAlignment = textAlignment,
                });
            }

            // Question asked fact and view article show card is available when feedback is on QnA Maker response.
            if (!string.IsNullOrWhiteSpace(data.KnowledgeBaseAnswer) && !string.IsNullOrWhiteSpace(data.UserQuestion))
            {
                smeFeedbackCard.Body.Add(new AdaptiveFactSet
                {
                    Facts = new List <AdaptiveFact>
                    {
                        new AdaptiveFact()
                        {
                            Title = Strings.QuestionAskedFactTitle,
                            Value = data.UserQuestion,
                        },
                    },
                });

                smeFeedbackCard.Actions.AddRange(new List <AdaptiveAction>
                {
                    new AdaptiveShowCardAction
                    {
                        Title = Strings.ViewArticleButtonText,
                        Card  = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
                        {
                            Body = new List <AdaptiveElement>
                            {
                                new AdaptiveTextBlock
                                {
                                    Text = CardHelper.TruncateStringIfLonger(data.KnowledgeBaseAnswer, CardHelper.KnowledgeBaseAnswerMaxDisplayLength),
                                    Wrap = true,
                                    HorizontalAlignment = textAlignment,
                                },
                            },
                        },
                    },
                });
            }

            return(new Attachment
            {
                ContentType = AdaptiveCard.ContentType,
                Content = smeFeedbackCard,
            });
        }
Esempio n. 14
0
        /// <summary>
        /// This method will construct the card  for share feedback bot menu.
        /// </summary>
        /// <param name="data">Data from the share feedback card.</param>
        /// <param name="showValidationErrors">Flag to determine rating value.</param>
        /// <param name="appBaseUri">The base URI where the app is hosted.</param>
        /// <returns>Share feedback card.</returns>
        private static Attachment GetCard(ShareFeedbackCardPayload data, bool showValidationErrors, string appBaseUri)
        {
            AdaptiveCard shareFeedbackCard = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
            {
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveTextBlock
                    {
                        Weight = AdaptiveTextWeight.Bolder,
                        Text   = !string.IsNullOrWhiteSpace(data.UserQuestion) ? string.Format(CultureInfo.InvariantCulture, Strings.ResultsFeedbackText, data.UserQuestion) : Strings.ShareFeedbackTitleText,
                        Size   = AdaptiveTextSize.Large,
                        Wrap   = true,
                    },
                },
                Actions = new List <AdaptiveAction>
                {
                    new AdaptiveShowCardAction
                    {
                        IconUrl = appBaseUri + "/content/face_smile.png",
                        Title   = " ",
                        Card    = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
                        {
                            Body = new List <AdaptiveElement>
                            {
                                new AdaptiveColumnSet
                                {
                                    Columns = new List <AdaptiveColumn>
                                    {
                                        new AdaptiveColumn
                                        {
                                            Width = AdaptiveColumnWidth.Auto,
                                            Items = new List <AdaptiveElement>
                                            {
                                                new AdaptiveTextBlock
                                                {
                                                    Text = Strings.DescriptionText,
                                                    Wrap = true,
                                                },
                                            },
                                        },
                                        new AdaptiveColumn
                                        {
                                            Items = new List <AdaptiveElement>
                                            {
                                                new AdaptiveTextBlock
                                                {
                                                    Text  = (showValidationErrors && data?.DescriptionHelpful?.Length > 500) ? Strings.MaxCharactersText : string.Empty,
                                                    Color = AdaptiveTextColor.Attention,
                                                    HorizontalAlignment = AdaptiveHorizontalAlignment.Right,
                                                    Wrap = true,
                                                },
                                            },
                                        },
                                    },
                                },
                                new AdaptiveTextInput
                                {
                                    Spacing     = AdaptiveSpacing.Small,
                                    Id          = nameof(ShareFeedbackCardPayload.DescriptionHelpful),
                                    Placeholder = Strings.FeedbackDescriptionPlaceholderText,
                                    IsMultiline = true,
                                    Value       = data?.DescriptionHelpful,
                                },
                            },
                            Actions = new List <AdaptiveAction>
                            {
                                new AdaptiveSubmitAction
                                {
                                    Data = new ShareFeedbackCardPayload
                                    {
                                        MsTeams = new CardAction
                                        {
                                            Type        = ActionTypes.MessageBack,
                                            DisplayText = Strings.ShareFeedbackDisplayText,
                                            Text        = ShareFeedbackSubmitText,
                                        },
                                        UserQuestion        = data.UserQuestion,
                                        KnowledgeBaseAnswer = data.KnowledgeBaseAnswer,
                                        Rating  = nameof(FeedbackRating.Helpful),
                                        Project = data.Project,
                                    },
                                },
                            },
                        },
                    },
                    new AdaptiveShowCardAction
                    {
                        IconUrl = appBaseUri + "/content/face_straigh.png",
                        Title   = " ",
                        Card    = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
                        {
                            Body = new List <AdaptiveElement>
                            {
                                new AdaptiveColumnSet
                                {
                                    Columns = new List <AdaptiveColumn>
                                    {
                                        new AdaptiveColumn
                                        {
                                            Width = AdaptiveColumnWidth.Auto,
                                            Items = new List <AdaptiveElement>
                                            {
                                                new AdaptiveTextBlock
                                                {
                                                    Text = Strings.DescriptionText,
                                                    Wrap = true,
                                                },
                                            },
                                        },
                                        new AdaptiveColumn
                                        {
                                            Items = new List <AdaptiveElement>
                                            {
                                                new AdaptiveTextBlock
                                                {
                                                    Text  = (showValidationErrors && data?.DescriptionNeedsImprovement?.Length > 500) ? Strings.MaxCharactersText : string.Empty,
                                                    Color = AdaptiveTextColor.Attention,
                                                    HorizontalAlignment = AdaptiveHorizontalAlignment.Right,
                                                    Wrap = true,
                                                },
                                            },
                                        },
                                    },
                                },
                                new AdaptiveTextInput
                                {
                                    Spacing     = AdaptiveSpacing.Small,
                                    Id          = nameof(ShareFeedbackCardPayload.DescriptionNeedsImprovement),
                                    Placeholder = Strings.FeedbackDescriptionPlaceholderText,
                                    IsMultiline = true,
                                    Value       = data?.DescriptionNeedsImprovement,
                                },
                            },
                            Actions = new List <AdaptiveAction>
                            {
                                new AdaptiveSubmitAction
                                {
                                    Data = new ShareFeedbackCardPayload
                                    {
                                        MsTeams = new CardAction
                                        {
                                            Type        = ActionTypes.MessageBack,
                                            DisplayText = Strings.ShareFeedbackDisplayText,
                                            Text        = ShareFeedbackSubmitText,
                                        },
                                        UserQuestion        = data.UserQuestion,
                                        KnowledgeBaseAnswer = data.KnowledgeBaseAnswer,
                                        Rating  = nameof(FeedbackRating.NeedsImprovement),
                                        Project = data.Project,
                                    },
                                },
                            },
                        },
                    },
                    new AdaptiveShowCardAction
                    {
                        IconUrl = appBaseUri + "/content/face_sad.png",
                        Title   = " ",
                        Card    = new AdaptiveCard(new AdaptiveSchemaVersion(1, 0))
                        {
                            Body = new List <AdaptiveElement>
                            {
                                new AdaptiveColumnSet
                                {
                                    Columns = new List <AdaptiveColumn>
                                    {
                                        new AdaptiveColumn
                                        {
                                            Width = AdaptiveColumnWidth.Auto,
                                            Items = new List <AdaptiveElement>
                                            {
                                                new AdaptiveTextBlock
                                                {
                                                    Text = Strings.DescriptionText,
                                                    Wrap = true,
                                                },
                                            },
                                        },
                                        new AdaptiveColumn
                                        {
                                            Items = new List <AdaptiveElement>
                                            {
                                                new AdaptiveTextBlock
                                                {
                                                    Text  = (showValidationErrors && data?.DescriptionNotHelpful?.Length > 500) ? Strings.MaxCharactersText : string.Empty,
                                                    Color = AdaptiveTextColor.Attention,
                                                    HorizontalAlignment = AdaptiveHorizontalAlignment.Right,
                                                    Wrap = true,
                                                },
                                            },
                                        },
                                    },
                                },
                                new AdaptiveTextInput
                                {
                                    Spacing     = AdaptiveSpacing.Small,
                                    Id          = nameof(ShareFeedbackCardPayload.DescriptionNotHelpful),
                                    Placeholder = Strings.FeedbackDescriptionPlaceholderText,
                                    IsMultiline = true,
                                    Value       = data?.DescriptionNotHelpful,
                                },
                            },
                            Actions = new List <AdaptiveAction>
                            {
                                new AdaptiveSubmitAction
                                {
                                    Data = new ShareFeedbackCardPayload
                                    {
                                        MsTeams = new CardAction
                                        {
                                            Type        = ActionTypes.MessageBack,
                                            DisplayText = Strings.ShareFeedbackDisplayText,
                                            Text        = ShareFeedbackSubmitText,
                                        },
                                        UserQuestion        = data.UserQuestion,
                                        KnowledgeBaseAnswer = data.KnowledgeBaseAnswer,
                                        Rating  = nameof(FeedbackRating.NotHelpful),
                                        Project = data.Project,
                                    },
                                },
                            },
                        },
                    },
                },
            };

            //shareFeedbackCard.Actions[0].AdditionalProperties.Add("iconUrl", appBaseUri + "/content/face_smile.png");
            //shareFeedbackCard.Actions[1].AdditionalProperties.Add("iconUrl", appBaseUri + "/content/face_straigh.png");
            //shareFeedbackCard.Actions[2].AdditionalProperties.Add("iconUrl", appBaseUri + "/content/face_sad.png");

            return(new Attachment
            {
                ContentType = AdaptiveCard.ContentType,
                Content = shareFeedbackCard,
            });
        }
 public static Attachment GetCard(ShareFeedbackCardPayload payload) =>
 payload != null
         ? GetCard(payload, showValidationErrors : true)
         : null;
Esempio n. 16
0
 /// <summary>
 /// This method will construct the card for share feedback, when invoked from the feedback card submit.
 /// </summary>
 /// <param name="payload">Payload from the response card.</param>
 /// <returns>Ask an expert card.</returns>
 public static Attachment GetCard(ShareFeedbackCardPayload payload)
 {
     return(GetCard(true, payload));
 }