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?
-
You can do it by using adaptive cards, add your response as text block, and then add two buttons for like and dislikes, you can use images as well. Prepare buttons actions and assign the required values. when user clicks on those buttons you will get post back values. – Sunil Soni Mar 29 '22 at 13:54
-
This is largely dependent on the client your bot will be available thru as it is usually a feature of the client. For example, Web Chat has this [sample](https://github.com/microsoft/BotFramework-WebChat/tree/main/samples/05.custom-components/d.reaction-buttons) that demonstrates how to implement this. However, you still need to configure your bot to respond accordingly when reactions are clicked. The recommendation from @SunilSoni is good but imperfect as you can't scale the card's UI very well for what you need. But, it may be your only option depending on the client. – Steven Kanberg Mar 30 '22 at 00:19
-
Yes, the answer not perfect @Steven Kanberg , I have implemented this solution in multiple projects, for different clients/channels Microsoft Teams and Direct Line. basically you can build any kind of card, and append like and dislike buttons at bottom right, create a fixed design template for buttons and reuse everywhere. In case you do not want to append buttons with Card, build separate card and sent it along with response where ever needed but I do not recommend this approach – Sunil Soni Mar 31 '22 at 06:34
-
@SunilSoni - actually, that is what I thought you meant (i.e. send a card with every response). So, I'm glad that isn't the case. I'd be curious to see your design if you have the code hosted somewhere. – Steven Kanberg Mar 31 '22 at 22:02
-
Hello @martian did you tried the solution has been given? Feel free to share if you have any further concern on this. – Md Farid Uddin Kiron Apr 12 '22 at 03:16
2 Answers
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. 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.
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://learn.microsoft.com/en-us/composer/how-to-send-cards?tabs=v2x

- 1,563
- 1
- 3
- 11
Is this possible to implement in 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.
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. 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:
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:

- 16,817
- 3
- 17
- 43
-
Hi there Farid. Please allow me to give you seem feedback on your use of the formatting tools here. There are so many to choose from, and surely using them to the maximum is fun! More the merrier, right? – halfer Jun 02 '22 at 18:37
-
Unfortunately - no, you're just misusing them. 416 posts that require substantial repair! Quote blocks formatted as inline code formatting, your commentary as quote blocks, your lists as code blocks. Would you ease up a bit? Ordinary paragraphs for your stuff, quote blocks (`>`) for other people's stuff. – halfer Jun 02 '22 at 18:41
-
Okay got your point and keep that upfront from now on. Thanks, Man. – Md Farid Uddin Kiron Jun 03 '22 at 01:08
-
Thank you. Also it's worth noting that ["hope that helps" is routinely edited out](https://meta.stackoverflow.com/questions/258187/is-it-ok-to-write-hope-that-helps-or-why-is-my-answer-being-edited), and it is better if it is not added. Everyone hopes their answer helps, and thus it can be removed as redundant. – halfer Jun 03 '22 at 09:55
-
1Okay @halfer I have already modified most of the recent posts and keep continue following your instruction while getting few extra time. Thanks once again Man. – Md Farid Uddin Kiron Jun 03 '22 at 09:57