简体   繁体   English

在 Microsoft Bot Framework 中的每条消息后添加“喜欢”和“不喜欢”按钮

[英]Add Like and Dislike button after every message in Microsoft Bot Framework

How can I add like and dislike button after each message postback by bot to get user feedback.如何在机器人回发每条消息后添加喜欢和不喜欢按钮以获得用户反馈。 And if user click on dislike button then my bot should give some suggestions nearer to that topic.如果用户点击不喜欢按钮,那么我的机器人应该给出一些更接近该主题的建议。 Is this possible to implement in Azure Bot Framework?这可以在 Azure Bot Framework 中实现吗?

The best way is to respond with cards.最好的方法是用卡片来回应。 There are different types of cards for different purposes.有不同类型的卡用于不同的目的。 For an example, we can create a button card and assign action to that button as like and dislike for each message card in the bot conversation.例如,我们可以创建一个按钮卡,并为该按钮分配操作,如机器人对话中的每个消息卡的喜欢和不喜欢。

All the bot responses are stored in .lg file.所有机器人响应都存储在 .lg 文件中。 That file will be exposed to the composer in the bot response page.该文件将在机器人响应页面中公开给作曲家。 There are three different templates.共有三种不同的模板。 Simple response, conditional response and structured response.简单响应、条件响应和结构化响应。 Based on the requirement, design the bot with these templates.根据需求,使用这些模板设计机器人。

https://docs.microsoft.com/en-us/azure/bot-service/file-format/bot-builder-lg-file-format?view=azure-bot-service-4.0 https://docs.microsoft.com/en-us/azure/bot-service/file-format/bot-builder-lg-file-format?view=azure-bot-service-4.0

The above link can be used for structured response.上述链接可用于结构化响应。

The below link is to implement cards for different templates and purpose with flow of implementation.下面的链接是为不同的模板和目的实现卡片的实现流程。

https://docs.microsoft.com/en-us/composer/how-to-send-cards?tabs=v2x https://docs.microsoft.com/en-us/composer/how-to-send-cards?tabs=v2x

Is this possible to implement in Azure Bot Framework?这可以在 Azure Bot Framework 中实现吗?

Yes you can implement that using Azure Bot SDK V4.0 specifically on Asp.net Core Bot SDK V-4.0 you can do that.是的,您可以使用Azure Bot SDK V4.0专门在 Asp.net Core Bot SDK V-4.0 上实现这一点,您可以这样做。

How can I add like and dislike button after each message postback by bot to get user feedback?如何在机器人回发每条消息后添加喜欢和不喜欢按钮以获取用户反馈?

You can use a "Hero card" to add such kind of button then you can set Unicode for like 👍 and dislike 👎 option.您可以使用“英雄卡”添加此类按钮,然后您可以为like 👍dislike 👎选项设置 Unicode。 Here is the example how you can design that particular card.这是如何设计该特定卡的示例。

Like-Dislike PromptCard:喜欢-不喜欢提示卡:

public IMessageActivity LikeDislikeCard()
        {
            try
            {
                //Break in Segment
                var timeInfoCard = Activity.CreateMessageActivity();
                //Bind to Card
                var heroCard = new HeroCard
                {
                    Title = "How do you think about the answer?",
                    Images = new List<CardImage> { new CardImage("") },
                    Buttons = new List<CardAction> {
                        new CardAction(ActionTypes.ImBack, "👍👍👍👍👍", value: "like") ,
                        new CardAction(ActionTypes.ImBack, "👎👎👎👎👎", value: "dislike")
                    },
                };

                // Create the attachment.
                var attachment = heroCard.ToAttachment();

                timeInfoCard.Attachments.Add(attachment);
                timeInfoCard.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                return timeInfoCard;
            }
            catch (Exception ex)
            {
                throw new NotImplementedException(ex.Message, ex.InnerException);
            }

        }

Call Like-Dislike PromptCard when sending Response:发送响应时调用 Like-Dislike PromptCard:

        var likeDislikeCard = LikeDislikeCard();
        await turnContext.SendActivityAsync(likeDislikeCard);

Note: But as you pointed out that you would like to take user feedback on bot conversation so there are better way out to achieve that.注意:但正如您所指出的,您希望获取用户对机器人对话的反馈,因此有更好的方法来实现这一目标。 In that case you can use below way to collect user feedback:在这种情况下,您可以使用以下方式收集用户反馈:

User Feedback Card:用户反馈卡:

public IMessageActivity UserFeedbackCard()
        {
            try
            {
                //Break in Segment
                var timeInfoCard = Activity.CreateMessageActivity();
                var thanks = "Thank you very much for your interaction";
                var rate = "You could rate our service...";
                //Bind to Card
                var heroCard = new HeroCard
                {
                    // Title = "Thank you very much for your interaction, you could rate me..",
                    Text = string.Format("**{0}** " + Environment.NewLine + "**{1}**", thanks, rate),
                    Images = new List<CardImage> { new CardImage("") },
                    Buttons = new List<CardAction> {
                        new CardAction(ActionTypes.ImBack, "\U0001F929", value: "one") ,
                        new CardAction(ActionTypes.ImBack, "\U0001F929 \U0001F929 ", value: "two"),
                        new CardAction(ActionTypes.ImBack, "\U0001F929 \U0001F929 \U0001F929", value: "three"),
                        new CardAction(ActionTypes.ImBack, "\U0001F929 \U0001F929 \U0001F929 \U0001F929 \U0001F929", value: "four"),
                        new CardAction(ActionTypes.ImBack, "\U0001F929 \U0001F929 \U0001F929 \U0001F929 \U0001F929 \U0001F929", value: "five"),
                    },
                };

                // Create the attachment.
                var attachment = heroCard.ToAttachment();

                timeInfoCard.Attachments.Add(attachment);
                timeInfoCard.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                return timeInfoCard;
            }
            catch (Exception ex)
            {
                throw new NotImplementedException(ex.Message, ex.InnerException);
            }

        }

Output:输出:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM