diff --git a/teams.md/src/components/include/essentials/sending-messages/csharp.incl.md b/teams.md/src/components/include/essentials/sending-messages/csharp.incl.md index 9bc4775a6..c8fade896 100644 --- a/teams.md/src/components/include/essentials/sending-messages/csharp.incl.md +++ b/teams.md/src/components/include/essentials/sending-messages/csharp.incl.md @@ -86,3 +86,93 @@ In .NET, reaction APIs are marked with `[Experimental("ExperimentalTeamsReaction ``` ::: + + + + +`GetQuotedMessages()` + + + +`Reply()` + + + +`Quote()` + + + +`app.Send()` + + + +`AddQuote()` + + + +```csharp +app.OnMessage(async context => +{ + var quotes = context.Activity.GetQuotedMessages(); + + if (quotes.Count > 0) + { + var quote = quotes[0].QuotedReply; + await context.Reply( + $"You quoted message {quote.MessageId} from {quote.SenderName}: \"{quote.Preview}\""); + } +}); +``` + + + +```csharp +app.OnMessage(async context => +{ + // Reply() automatically quotes the inbound message + await context.Reply("Got it!"); +}); +``` + + + +```csharp +app.OnMessage(async context => +{ + // Quote a specific message by its ID + await context.Quote("1772050244572", "Referencing an earlier message"); +}); +``` + + + +```csharp +// Single quote with response below it +var msg = new MessageActivity() + .AddQuote("1772050244572", "Here is my response"); +await app.Send(conversationId, msg); + +// Multiple quotes with interleaved responses +msg = new MessageActivity() + .AddQuote("msg-1", "response to first") + .AddQuote("msg-2", "response to second"); +await app.Send(conversationId, msg); + +// Grouped quotes — omit response to group quotes together +msg = new MessageActivity("see below for previous messages") + .AddQuote("msg-1") + .AddQuote("msg-2", "response to both"); +await app.Send(conversationId, msg); +``` + + + +:::tip[.NET] +In .NET, quoted reply APIs are marked with `[Experimental("ExperimentalTeamsQuotedReplies")]` and will produce a compiler error until you opt in. Suppress the diagnostic inline with `#pragma warning disable ExperimentalTeamsQuotedReplies` or project-wide in your `.csproj`: + +```xml + + $(NoWarn);ExperimentalTeamsQuotedReplies + +``` +::: \ No newline at end of file diff --git a/teams.md/src/components/include/essentials/sending-messages/python.incl.md b/teams.md/src/components/include/essentials/sending-messages/python.incl.md index ddfb14fd8..d8c0fa790 100644 --- a/teams.md/src/components/include/essentials/sending-messages/python.incl.md +++ b/teams.md/src/components/include/essentials/sending-messages/python.incl.md @@ -67,5 +67,85 @@ async def handle_message(ctx: ActivityContext[MessageActivity]): ``` +N/A +N/A + + + +`get_quoted_messages()` + + + +`reply()` + + + +`quote()` + + + +`app.send()` + + + +`add_quote()` + + + +```python +@app.on_message +async def handle_message(ctx: ActivityContext[MessageActivity]): + quotes = ctx.activity.get_quoted_messages() + + if quotes: + quote = quotes[0].quoted_reply + await ctx.reply( + f"You quoted message {quote.message_id} from {quote.sender_name}: \"{quote.preview}\"" + ) +``` + + + +```python +@app.on_message +async def handle_message(ctx: ActivityContext[MessageActivity]): + # reply() automatically quotes the inbound message + await ctx.reply("Got it!") +``` + + + +```python +@app.on_message +async def handle_message(ctx: ActivityContext[MessageActivity]): + # Quote a specific message by its ID + await ctx.quote("1772050244572", "Referencing an earlier message") +``` + + + +```python +from microsoft_teams.api.activities.message import MessageActivityInput + +# Single quote with response below it +msg = (MessageActivityInput() + .add_quote("1772050244572", "Here is my response")) +await app.send(conversation_id, msg) + +# Multiple quotes with interleaved responses +msg = (MessageActivityInput() + .add_quote("msg-1", "response to first") + .add_quote("msg-2", "response to second")) +await app.send(conversation_id, msg) + +# Grouped quotes — omit response to group quotes together +msg = (MessageActivityInput(text="see below for previous messages") + .add_quote("msg-1") + .add_quote("msg-2", "response to both")) +await app.send(conversation_id, msg) +``` + + +N/A diff --git a/teams.md/src/components/include/essentials/sending-messages/typescript.incl.md b/teams.md/src/components/include/essentials/sending-messages/typescript.incl.md index 920a47873..53c019cca 100644 --- a/teams.md/src/components/include/essentials/sending-messages/typescript.incl.md +++ b/teams.md/src/components/include/essentials/sending-messages/typescript.incl.md @@ -61,5 +61,87 @@ app.on('message', async ({ send, activity }) => { ``` +N/A +N/A + + + + +`getQuotedMessages()` + + + +`reply()` + + + +`quote()` + + + +`app.send()` + + + +`addQuote()` + + + +```typescript +app.on('message', async ({ activity, reply }) => { + const quotes = activity.getQuotedMessages(); + + if (quotes.length > 0) { + const quote = quotes[0].quotedReply; + await reply( + `You quoted message ${quote.messageId} from ${quote.senderName}: "${quote.preview}"` + ); + } +}); +``` + + + +```typescript +app.on('message', async ({ reply }) => { + // reply() automatically quotes the inbound message + await reply('Got it!'); +}); +``` + + + +```typescript +app.on('message', async ({ quote }) => { + // Quote a specific message by its ID + await quote('1772050244572', 'Referencing an earlier message'); +}); +``` + + + +```typescript +import { MessageActivity } from '@microsoft/teams.api'; + +// Single quote with response below it +let msg = new MessageActivity() + .addQuote('1772050244572', 'Here is my response'); +await app.send(conversationId, msg); + +// Multiple quotes with interleaved responses +msg = new MessageActivity() + .addQuote('msg-1', 'response to first') + .addQuote('msg-2', 'response to second'); +await app.send(conversationId, msg); + +// Grouped quotes — omit response to group quotes together +msg = new MessageActivity('see below for previous messages') + .addQuote('msg-1') + .addQuote('msg-2', 'response to both'); +await app.send(conversationId, msg); +``` + + +N/A \ No newline at end of file diff --git a/teams.md/src/pages/templates/essentials/sending-messages/README.mdx b/teams.md/src/pages/templates/essentials/sending-messages/README.mdx index 5ffbf4058..4db938c6c 100644 --- a/teams.md/src/pages/templates/essentials/sending-messages/README.mdx +++ b/teams.md/src/pages/templates/essentials/sending-messages/README.mdx @@ -50,7 +50,6 @@ To send a targeted message when responding to an incoming activity, use the -### Targeted messages in preview ## Reactions @@ -61,6 +60,39 @@ Reactions are currently in preview. Reactions allow your agent to add or remove emoji reactions on messages in a conversation. The reactions client is available via the API client. -### Reactions in preview + +## Quoted Replies + +:::info[Preview] +Quoted replies are currently in preview. +::: + +Quoted replies let your agent reference a previous message in the conversation. When a user sends a message that quotes another message, your agent receives structured metadata about the quoted content. Your agent can also send messages that quote previous messages. + +### Receiving Quoted Replies + +When a user quotes a message and sends it to your agent, the quoted reply metadata is available on the inbound activity. Use the method to access all quoted reply entities. + + + +Each quoted reply entity contains the quoted message's ID, sender information, a preview of the quoted text, and whether the quoted message has been deleted. + +### Sending a Quoted Reply + +When your agent calls , the SDK automatically stamps a quoted reply entity referencing the inbound message. No extra code is needed — the reply will appear as a quoted reply in Teams. + + + +To quote a different message in the same conversation (not the inbound message), use the method with the message ID you want to quote. + + + +### Building Quoted Replies for Proactive Send + +For proactive scenarios (using ) or when quoting multiple messages, use the method on a message activity. Pass the message ID and an optional response text. + + + + \ No newline at end of file