Skip to main content

Reactions and Mentions

Reactions​

Reactions use the Microsoft Graph v1.0 setReaction and unsetReaction actions.

teams message react --team "$TEAM_ID" --channel "$CHANNEL_ID" --message-id "$MESSAGE_ID" --reaction like
teams message unreact --team "$TEAM_ID" --channel "$CHANNEL_ID" --message-id "$MESSAGE_ID" --reaction like

Chat messages are addressed with --chat instead of the --team/--channel pair:

teams message react --chat "$CHAT_ID" --message-id "$MESSAGE_ID" --reaction 🎉

To react to a reply in a channel thread, add --reply with the reply's ID; --message-id is then the parent post. --reply needs --team and --channel, and is a usage error (exit code 2) with --chat.

teams message react --team "$TEAM_ID" --channel "$CHANNEL_ID" \
--message-id "$ROOT_MESSAGE_ID" --reply "$REPLY_ID" --reaction like

Graph requires a unicode emoji on writes and rejects the classic names by name, so the CLI translates them for you: like, heart, laugh, surprised, sad, angry, plus thumbsup, thumbsdown, eyes, tada, rocket and fire. Any emoji character passes through unchanged.

A user has one reaction per message — reacting again replaces the previous one. Removing a reaction that is not there is a no-op rather than an error.

Mentions​

message send --mention, message reply --mention and message update --mention tag a person with a real Teams @mention, in chats, channels and channel replies. The flag is repeatable and takes an Entra object ID or a user principal name.

teams message send --chat "$CHAT_ID" \
--body "can you take a look?" \
--mention alice@contoso.com \
--output json
teams message send --team "$TEAM_ID" --channel "$CHANNEL_ID" \
--body "deploy is green" \
--mention alice@contoso.com \
--mention 32cbca05-dc05-454f-b0f3-072f331d4c97 \
--output json
teams message reply --team "$TEAM_ID" --channel "$CHANNEL_ID" --message-id "$ROOT_MESSAGE_ID" \
--body "I have picked this up." \
--mention alice@contoso.com \
--output json

Graph only keeps a mention when the message body's <at id="N"> elements are synchronized with a top-level mentions array, so the CLI builds both halves and keeps their IDs in step. Each value is resolved through Graph first and must yield a canonical object ID and a display name.

Things worth knowing:

  • Without placement tokens (below), mentions are prefixed to the body in flag order.
  • Two values that resolve to the same person collapse to one mention.
  • A mention on its own is a complete message for send and reply: --body is optional when you pass --mention.
  • A plain-text body is promoted to HTML safely, with the text escaped.
  • Raw <at> markup in an HTML body without --mention is rejected before anything is sent, because Graph would strip a mention whose IDs do not line up.

Resolving a name needs User.ReadBasic.All, which is in the default scope set. message list and message get return any mentions Graph reports, so a read-back shows what was tagged. Each mention's mentioned object holds whichever identity Graph returned: user for a person; conversation for @Everyone, an @channel or an @team, with conversationIdentityType set to chat, channel or team; tag for a team tag; and application for a bot or app. Before v0.8.0 only user was kept, and the other kinds read back as an empty {}. A message posted by a bot, workflow or connector carries its sender in from.application, and the human table's From column shows the application's name.

Place a mention inside the sentence​

Write {@N} in the body where the mention belongs, N being the 0-based position of the --mention flag. {@} stands for the only mention when there is one.

teams message send --chat "$CHAT_ID" \
--mention alice@contoso.com --mention bob@contoso.com \
--body "Hey {@0}, could you review this? cc {@1}" \
--output json

This works for text and HTML bodies on send, reply and update. A person placed twice gets two <at> elements and two mentions entries, which is what Teams itself sends. Once a body uses tokens, every --mention must be placed and every token must match a --mention; otherwise the command exits with code 2 before any user is looked up or anything is sent.

Tokens are read in every body, with or without --mention, so a body containing {@0} and no --mention exits with code 2 rather than posting what looks like a broken mention. Write {{@0}} (or {{@}}) for the literal text. Other braces, such as {0} or {@name}, are left alone.

Keep mentions when editing​

Graph clears a message's mentions when an edit sends only a new body, and it strips <at> markup that arrives without a mentions array. message update --mention sends the body and the mentions array together, so an edit can keep or add a mention:

teams message update --chat "$CHAT_ID" "$MESSAGE_ID" \
--mention alice@contoso.com \
--body "Hey {@0}, could you review this today?" \
--output json

The edit replaces the whole body: pass --mention again for every mention that should survive. Before v0.12.0 message update had no --mention, so any edit dropped the message's mentions.