TeamsSubmitActionRouteAttribute Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Attribute to define a route that handles Teams message extension submit action events for a specific command.
public TeamsSubmitActionRouteAttribute(string commandId = default, string commandIdPattern = default, bool isAgenticOnly = false, ushort rank = 32767, string signInHandlers = default);
new Microsoft.Agents.Extensions.MSTeams.MessageExtensions.TeamsSubmitActionRouteAttribute : string * string * bool * uint16 * string -> Microsoft.Agents.Extensions.MSTeams.MessageExtensions.TeamsSubmitActionRouteAttribute
Public Sub New (Optional commandId As String = Nothing, Optional commandIdPattern As String = Nothing, Optional isAgenticOnly As Boolean = false, Optional rank As UShort = 32767, Optional signInHandlers As String = Nothing)
Parameters
- commandId
- String
The message extension command ID to match. Mutually exclusive with commandIdPattern.
- commandIdPattern
- String
The regular expression pattern to match the message extension command ID. Mutually exclusive with commandId.
- isAgenticOnly
- Boolean
When true, the route only fires for agentic turns. Defaults to false.
- rank
- UInt16
Route evaluation order. Lower values run first. Defaults to Unspecified.
- signInHandlers
- String
A comma/space/semicolon-delimited list of OAuth sign-in handler names, or the name of an instance method on the agent class matching Func<ITurnContext, string[]>.
Remarks
Decorate a method with this attribute to register it as a handler for message extension submit action events in Teams. The method must match the SubmitActionHandler delegate signature — the third parameter must be Microsoft.Teams.Api.MessageExtensions.Action.
[TeamsSubmitActionRoute("createTask")]
public async Task<Response> OnCreateTaskAsync(ITeamsTurnContext turnContext, ITurnState turnState, Microsoft.Teams.Api.MessageExtensions.Action action, CancellationToken cancellationToken)
{
var task = await _taskService.CreateAsync(action.Data["title"]?.ToString(), action.Data["assignedTo"]?.ToString(), cancellationToken);
var card = task.ToAdaptiveCard().ToMessagingExtensionAttachment();
return new Response { ComposeExtension = new Result { Type = ResultType.List, Attachments = [card] } };
}
Alternatively, OnSubmitAction(String, SubmitActionHandler, String[], UInt16) can be used to register the handler via the fluent API.