Language

TaskModule.OnSubmit Method

Definition

Overloads

Name Description
OnSubmit(String, TaskSubmitHandler, String, String[], UInt16)

Registers a handler to process the submission of a task module. The value of the "task" key (or the specified key) in the activity data is matched against value to determine whether this handler should be triggered.

OnSubmit(Regex, TaskSubmitHandler, String, String[], UInt16)

Registers a handler to process the submission of a task module. The value of the "task" key (or the specified key) in the activity data is matched against valuePattern to determine whether this handler should be triggered.

OnSubmit(String, TaskSubmitHandler, String, String[], UInt16)

Registers a handler to process the submission of a task module. The value of the "task" key (or the specified key) in the activity data is matched against value to determine whether this handler should be triggered.

public Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskModule OnSubmit(string value, Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskSubmitHandler handler, string key = default, string[] autoSignInHandlers = default, ushort rank = 32767);
member this.OnSubmit : string * Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskSubmitHandler * string * string[] * uint16 -> Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskModule
Public Function OnSubmit (value As String, handler As TaskSubmitHandler, Optional key As String = Nothing, Optional autoSignInHandlers As String() = Nothing, Optional rank As UShort = 32767) As TaskModule

Parameters

value
String

The value of the key to match on. If null, this will match for any submit request.

handler
TaskSubmitHandler

Function to call when the route is triggered.

key
String

The JSON field name used to identify the key in the task data. Defaults to "task" if not specified.

autoSignInHandlers
String[]

OAuth sign-in handler names for automatic sign-in before the route handler is invoked. Specify null to skip automatic sign-in.

rank
UInt16

Route evaluation order. Lower values run first. Defaults to Unspecified.

Returns

The application instance for chaining purposes.

Remarks

Alternatively, the TeamsTaskSubmitRouteAttribute can be used to decorate a TaskSubmitHandler method for the same purpose.

The following example reads a field from the submitted form data and returns a completion message.

[TeamsTaskSubmitRoute("simple_form")]
public async Task<Microsoft.Teams.Api.TaskModules.Response> OnSimpleFormSubmitAsync(
    ITeamsTurnContext turnContext, ITurnState turnState,
    Microsoft.Teams.Api.TaskModules.Request request, CancellationToken cancellationToken)
{
    var name = request.GetDataString("name", "Unknown");
    await turnContext.SendActivityAsync($"Hi {name}, thanks for submitting the form!", cancellationToken: cancellationToken);
    return new Microsoft.Teams.Api.TaskModules.Response(
        new Microsoft.Teams.Api.TaskModules.MessageTask("Form was submitted"));
}

Applies to

OnSubmit(Regex, TaskSubmitHandler, String, String[], UInt16)

Registers a handler to process the submission of a task module. The value of the "task" key (or the specified key) in the activity data is matched against valuePattern to determine whether this handler should be triggered.

public Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskModule OnSubmit(System.Text.RegularExpressions.Regex valuePattern, Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskSubmitHandler handler, string key = default, string[] autoSignInHandlers = default, ushort rank = 32767);
member this.OnSubmit : System.Text.RegularExpressions.Regex * Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskSubmitHandler * string * string[] * uint16 -> Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskModule
Public Function OnSubmit (valuePattern As Regex, handler As TaskSubmitHandler, Optional key As String = Nothing, Optional autoSignInHandlers As String() = Nothing, Optional rank As UShort = 32767) As TaskModule

Parameters

valuePattern
Regex

Regular expression to match against the task data key value.

handler
TaskSubmitHandler

Function to call when the route is triggered.

key
String

The JSON field name used to identify the key in the task data. Defaults to "task" if not specified.

autoSignInHandlers
String[]

OAuth sign-in handler names for automatic sign-in before the route handler is invoked. Specify null to skip automatic sign-in.

rank
UInt16

Route evaluation order. Lower values run first. Defaults to Unspecified.

Returns

The application instance for chaining purposes.

Remarks

Alternatively, the TeamsTaskSubmitRouteAttribute can be used to decorate a TaskSubmitHandler method for the same purpose.

Applies to