TaskModule.OnFetch Method
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.
Overloads
| Name | Description |
|---|---|
| OnFetch(String, TaskFetchHandler, String, String[], UInt16) |
Registers a handler to process the fetch of a task module. The value of the |
| OnFetch(Regex, TaskFetchHandler, String, String[], UInt16) |
Registers a handler to process the fetch of a task module. The value of the |
OnFetch(String, TaskFetchHandler, String, String[], UInt16)
Registers a handler to process the fetch 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 OnFetch(string value, Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskFetchHandler handler, string key = default, string[] autoSignInHandlers = default, ushort rank = 32767);
member this.OnFetch : string * Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskFetchHandler * string * string[] * uint16 -> Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskModule
Public Function OnFetch (value As String, handler As TaskFetchHandler, 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.
- handler
- TaskFetchHandler
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 TeamsTaskFetchRouteAttribute can be used to decorate a TaskFetchHandler method for the same purpose.
The following example opens a simple Adaptive Card form inside a task module dialog. The card's submit action includes "task": "simple_form" so that the matching submit handler is triggered when the user submits the form.
[TeamsTaskFetchRoute("simple_form")]
public Task<Microsoft.Teams.Api.TaskModules.Response> OnSimpleFormFetchAsync(
ITeamsTurnContext turnContext, ITurnState turnState,
Microsoft.Teams.Api.TaskModules.Request data, CancellationToken cancellationToken)
{
// Simple Adaptive Card form. The submit action data includes "task": "simple_form"
// so the OnSimpleFormSubmitAsync handler below is called when the user submits.
const string cardJson = """
{
"type": "AdaptiveCard",
"version": "1.4",
"body": [{ "type": "Input.Text", "id": "name", "label": "Name" }],
"actions": [{
"type": "Action.Submit",
"title": "Submit",
"data": { "task": "simple_form" }
}]
}
""";
return Task.FromResult(new Microsoft.Teams.Api.TaskModules.Response(
new Microsoft.Teams.Api.TaskModules.ContinueTask(
new Microsoft.Teams.Api.TaskModules.TaskInfo
{
Card = new Microsoft.Teams.Api.Attachment(ContentTypes.AdaptiveCard, cardJson),
Title = "Simple Form",
Height = new Microsoft.Teams.Common.Union<int, Microsoft.Teams.Api.TaskModules.Size>(Microsoft.Teams.Api.TaskModules.Size.Small),
Width = new Microsoft.Teams.Common.Union<int, Microsoft.Teams.Api.TaskModules.Size>(Microsoft.Teams.Api.TaskModules.Size.Small)
})));
}
Applies to
OnFetch(Regex, TaskFetchHandler, String, String[], UInt16)
Registers a handler to process the fetch 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 OnFetch(System.Text.RegularExpressions.Regex valuePattern, Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskFetchHandler handler, string key = default, string[] autoSignInHandlers = default, ushort rank = 32767);
member this.OnFetch : System.Text.RegularExpressions.Regex * Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskFetchHandler * string * string[] * uint16 -> Microsoft.Agents.Extensions.MSTeams.TaskModules.TaskModule
Public Function OnFetch (valuePattern As Regex, handler As TaskFetchHandler, 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 key value.
- handler
- TaskFetchHandler
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 TeamsTaskFetchRouteAttribute can be used to decorate a TaskFetchHandler method for the same purpose.