-
Notifications
You must be signed in to change notification settings - Fork 263
Quoted replies docs #2727
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
base: main
Are you sure you want to change the base?
Quoted replies docs #2727
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,3 +87,93 @@ In .NET, reaction APIs are marked with `[Experimental("ExperimentalTeamsReaction | |
| </PropertyGroup> | ||
| ``` | ||
| ::: | ||
|
|
||
|
|
||
| <!-- get-quoted-messages-method-name --> | ||
|
|
||
| `GetQuotedMessages()` | ||
|
|
||
| <!-- reply-method-name --> | ||
|
|
||
| `Reply()` | ||
|
|
||
| <!-- quote-reply-method-name --> | ||
|
|
||
| `Quote()` | ||
|
|
||
| <!-- app-send-method-name --> | ||
|
|
||
| `app.Send()` | ||
|
|
||
| <!-- add-quoted-reply-method-name --> | ||
|
|
||
| `AddQuote()` | ||
|
|
||
| <!-- quoted-replies-receive-example --> | ||
|
|
||
| ```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}\""); | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| <!-- quoted-replies-reply-example --> | ||
|
|
||
| ```csharp | ||
| app.OnMessage(async context => | ||
| { | ||
|
Comment on lines
+131
to
+132
|
||
| // Reply() automatically quotes the inbound message | ||
| await context.Reply("Got it!"); | ||
| }); | ||
| ``` | ||
|
|
||
| <!-- quoted-replies-quote-reply-example --> | ||
|
|
||
| ```csharp | ||
| app.OnMessage(async context => | ||
| { | ||
|
Comment on lines
+141
to
+142
|
||
| // Quote a specific message by its ID | ||
| await context.Quote("1772050244572", "Referencing an earlier message"); | ||
| }); | ||
| ``` | ||
|
|
||
| <!-- quoted-replies-builder-example --> | ||
|
|
||
| ```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); | ||
| ``` | ||
|
|
||
| <!-- quoted-replies-preview-note --> | ||
|
|
||
| :::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 | ||
| <PropertyGroup> | ||
| <NoWarn>$(NoWarn);ExperimentalTeamsQuotedReplies</NoWarn> | ||
| </PropertyGroup> | ||
| ``` | ||
| ::: | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,4 +70,82 @@ async def handle_message(ctx: ActivityContext[MessageActivity]): | |
| N/A | ||
|
|
||
| <!-- reactions-preview-note --> | ||
| N/A | ||
| N/A | ||
|
|
||
| <!-- get-quoted-messages-method-name --> | ||
|
|
||
| `get_quoted_messages()` | ||
|
|
||
| <!-- reply-method-name --> | ||
|
|
||
| `reply()` | ||
|
|
||
| <!-- quote-reply-method-name --> | ||
|
|
||
| `quote()` | ||
|
|
||
| <!-- app-send-method-name --> | ||
|
|
||
| `app.send()` | ||
|
|
||
| <!-- add-quoted-reply-method-name --> | ||
|
|
||
| `add_quote()` | ||
|
|
||
| <!-- quoted-replies-receive-example --> | ||
|
|
||
| ```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}\"" | ||
| ) | ||
| ``` | ||
|
|
||
| <!-- quoted-replies-reply-example --> | ||
|
|
||
| ```python | ||
| @app.on_message | ||
| async def handle_message(ctx: ActivityContext[MessageActivity]): | ||
| # reply() automatically quotes the inbound message | ||
| await ctx.reply("Got it!") | ||
| ``` | ||
|
|
||
| <!-- quoted-replies-quote-reply-example --> | ||
|
|
||
| ```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") | ||
| ``` | ||
|
|
||
| <!-- quoted-replies-builder-example --> | ||
|
|
||
| ```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) | ||
|
Comment on lines
+130
to
+135
|
||
|
|
||
| # 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) | ||
| ``` | ||
|
|
||
| <!-- quoted-replies-preview-note --> | ||
| N/A | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[HIGH] This
OnMessagesample drops the(context, cancellationToken)parameters used everywhere else in the .NET docs. If the overload withoutcancellationTokendoesn’t exist, this won’t compile; suggest matching the standard signature used in other examples.