Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replying to a Teams message with a Like reaction via C# #4499

tomorgan opened this issue Apr 20, 2018 · 4 comments


None yet
2 participants
Copy link

commented Apr 20, 2018

Bot Info

  • SDK Platform: NET
  • SDK Version: Microsoft.Bot.Connection v3.15.0
  • Active Channels: MS Teams
  • Deployment Environment: local via ngrok and testing in Teams client

Issue Description

I'm trying to write code to have my Bot respond to a message with a Like. I'm replicating what I'm seeing when someone else Likes a bot message, and trying to do the same, as I can't find this documented anywhere. (so I could be doing it wrong)

Code Example

 var connector = new ConnectorClient(new Uri(serviceURL));
 Activity newMessage = (Activity)Activity.CreateMessageActivity();
 newMessage.Type = ActivityTypes.MessageReaction;               
 var reactions = new List<MessageReaction>
                    new MessageReaction("like")
                newMessage.ReactionsAdded = reactions;
                var res =  await connector.Conversations.ReplyToActivityAsync(conversationID, activityID, newMessage);

Reproduction Steps

  1. Mention the bot in a channel message (i.e. "@bot hey do you like this?"
  2. In the bot code, catch the message, and reply with the code above
  3. Error is thrown (see below)

Expected Behavior

The bot should Like the message

Actual Results

{"Operation returned an invalid status code 'BadRequest'"}
at Microsoft.Bot.Connector.Conversations.d__8.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Connector.ConversationsExtensions.d__7.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown

Here are the Request / Response messages from the Exception:
Request Content: "{\r\n "type": "messageReaction",\r\n "reactionsAdded": [\r\n {\r\n "type": "like"\r\n }\r\n ],\r\n "attachments": [],\r\n "entities": []\r\n}"

Response Content:
"{"error":{"code":"BadArgument","message":"Unknown activity type"}}"


This comment has been minimized.

Copy link

commented Apr 20, 2018

I am looking into this, I will let you know what I find out. It looks like you are doing this in the messages controller is that correct?


This comment has been minimized.

Copy link

commented Apr 20, 2018

So upon some investigation, since I had never actually seen someone use the message reaction activity type. You are trying to use it not as it was intended to be used. This activity type will update the bot when someone has liked (or some sort of reaction) to an activity. It is not intended to actually send and registed a reaction from the bot.

From the docs:

Some channels will send messageReaction activities to your bot when a user reacted to an existing activity. For example, a user clicks the "Like" button on a message. The ReplyToId property will indicate which activity the user reacted to.

The messageReaction activity may correspond to any number of messageReactionTypes that the channel defined. For example, "Like" or "PlusOne" as reaction types that a channel may send.


This comment has been minimized.

Copy link

commented Apr 21, 2018

Hmm interesting. Any reason why it shouldn’t work like this (other than it not being coded in)? Can I add it to the backlog? For me, it seems to be a nice subtle way for the bot code to acknowledge that it’s received and understood the message: for instance, if you send a message to a bot to do something, a like is a good way of saying “ok, I understand what you asked and I’m doing it” where a full reply isn’t needed.


This comment has been minimized.

Copy link

commented Apr 23, 2018

Feel free to Submit a pull request if you would like. With V4 coming out soon we are not looking to add features to V3 at this point. So if you are not interested in adding the code yourself open a new issue as a feature request. No guarantees on if it will be considered in the future, or what kind of timeline it would have though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.