feat: SuggestedActionSubmitActivity for suggestedAction/submit invoke#464
feat: SuggestedActionSubmitActivity for suggestedAction/submit invoke#464singhk97 wants to merge 15 commits into
Conversation
…invoke (ADO 5323021) Replaces the prior generic-fallback approach with a typed activity subclass and dedicated OnSuggestedActionSubmit route extension, mirroring the existing HandoffActivity pattern. See SuggestedActionInvoke design spec for the platform contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds first-class SDK support for the new suggestedAction/submit invoke by introducing a typed activity and a dedicated routing extension, and wires it into invoke dispatch + JSON serialization so apps no longer fail on this invoke name.
Changes:
- Introduces
SuggestedActionSubmitActivity(API) andOnSuggestedActionSubmit/SuggestedActionSubmitAttribute(Apps routing). - Updates invoke type dispatch (
InvokeActivity.ToType/InvokeActivity.ToType(Type, …)) and the JSON converter to read/write the new activity type. - Adds tests + a sample handler that reads a
votefield from the invoke payload.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/Microsoft.Teams.Api.Tests/Json/Activity/Invokes/SuggestedActionSubmitActivity.json | Adds a representative JSON payload used by tests. |
| Tests/Microsoft.Teams.Api.Tests/Activities/Invokes/SuggestedActionSubmitActivityTests.cs | Adds deserialization + dispatch + path tests for the new activity type. |
| Samples/Samples.Dialogs/Program.cs | Demonstrates handling suggestedAction/submit and echoing a payload field. |
| Libraries/Microsoft.Teams.Apps/Activities/Invokes/SuggestedActionSubmitActivity.cs | Adds routing extension methods + attribute for suggestedAction/submit. |
| Libraries/Microsoft.Teams.Api/Activities/Invokes/SuggestedActionSubmitActivity.cs | Adds the Name.SuggestedActionSubmit constant and SuggestedActionSubmitActivity type. |
| Libraries/Microsoft.Teams.Api/Activities/Invokes/InvokeActivity.cs | Adds invoke-name-to-type dispatch for the new activity. |
| Libraries/Microsoft.Teams.Api/Activities/InvokeActivity.cs | Adds casting + ToType routing for SuggestedActionSubmitActivity. |
| Libraries/Microsoft.Teams.Api/Activities/InvokeActivity.JsonConverter.cs | Adds JSON read/write support for the new invoke activity type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Move suggestedAction/submit handler out of Samples.Dialogs into a new
dedicated Samples.SuggestedAction project, registered in the solution.
- Mark the new public surface with [Experimental("ExperimentalTeamsSuggestedAction")]:
SuggestedActionSubmitActivity, Name.SuggestedActionSubmit, IsSuggestedActionSubmit,
ToSuggestedActionSubmit(), and the OnSuggestedActionSubmit extensions. Internal
references and the test/sample suppress the warning via #pragma.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add ActionType.Submit ("Action.Submit") to Microsoft.Teams.Api.Cards.ActionType,
marked [Experimental("ExperimentalTeamsSuggestedAction")].
- Update sample to construct a reply MessageActivity with two suggested-action
chips that emit { type: Action.Submit, title, value } per the design spec.
Uses using-aliases to disambiguate Cards vs MessageActivity types.
- Add wire-format test asserting the bot's outgoing JSON matches the spec.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ructure with Samples.Threading
…edAction Agent-Logs-Url: https://github.com/microsoft/teams.net/sessions/c7c0a5bb-4933-4e7f-8ff3-ae89404157ce Co-authored-by: singhk97 <115390646+singhk97@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// <summary> | ||
| /// Suggested action of type Action.Submit. The action's Value is delivered to the bot | ||
| /// as a <c>suggestedAction/submit</c> invoke without sending a chat-visible message. | ||
| /// </summary> | ||
| [Experimental("ExperimentalTeamsSuggestedAction")] | ||
| public static readonly ActionType Submit = new("Action.Submit"); | ||
|
|
||
| [Experimental("ExperimentalTeamsSuggestedAction")] | ||
| public bool IsSubmit => Submit.Equals(Value); |
|
|
||
| ## Experimental API | ||
|
|
||
| `CardActionType.Submit`, `SuggestedActionSubmitActivity`, and `OnSuggestedActionSubmit` are marked `[Experimental("ExperimentalTeamsSuggestedAction")]` because the underlying platform feature is still rolling out. The C# compiler reports references to them as **errors** by default, so consuming code has to opt in. |
| @@ -0,0 +1,52 @@ | |||
| // SuggestedAction.Submit and the OnSuggestedActionSubmit handler are marked | |||
corinagum
left a comment
There was a problem hiding this comment.
Can last item in test plan be checked off? I think I recall you saying you tested it manually. Approved, pending resolution/close of last Copilot remarks.
Aligns the experimental invoke name with the platform's actual wire shape (plural, matching the suggestedActions container on outgoing messages). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
||
| ## Experimental API | ||
|
|
||
| `CardActionType.Submit`, `SuggestedActionSubmitActivity`, and `OnSuggestedActionSubmit` are marked `[Experimental("ExperimentalTeamsSuggestedAction")]` because the underlying platform feature is still rolling out. The C# compiler reports references to them as **errors** by default, so consuming code has to opt in. |
| Assert.Equal("suggestedActionSubmitId", activity!.Id); | ||
| Assert.Equal("channelId", activity.ChannelId.Value); | ||
| Assert.Equal("suggestedActions/submit", activity.Name.Value); | ||
| Assert.NotNull(activity.Value); |
| [Experimental("ExperimentalTeamsSuggestedAction")] | ||
| public static readonly Name SuggestedActionSubmit = new("suggestedActions/submit"); |
| [Experimental("ExperimentalTeamsSuggestedAction")] | ||
| public static readonly ActionType Submit = new("Action.Submit"); |
Summary
Adds first-class support for the
suggestedAction/submitinvoke activity (the platform-side dispatch of anAction.Submitsuggested-action click).SuggestedActionSubmitActivityandOnSuggestedActionSubmitroute extension, modeled afterHandoffActivity/OnHandoff.Microsoft.Teams.Api.Cards.ActionType.Submitvalue, so bots can construct outboundsuggestedActions.actions[]chips withtype: "Action.Submit",title, and structuredvalue.[Experimental("ExperimentalTeamsSuggestedAction")]. Internal references suppress via#pragma.Samples.SuggestedActionproject demonstrates both directions: bot replies with Approve/Reject chips, then handles the resulting invoke.Test plan
dotnet build Microsoft.Teams.sln— cleandotnet test Microsoft.Teams.sln— 1293/1293 pass on bothnet8.0andnet10.0. Includes a wire-format test asserting the outgoingsuggestedActions.actions[].{type,title,value}JSON matches the design spec.SuggestedActionSubmitActivityand thatactivity.Valueround-trips as aJsonElement.