Language

TeamsSettingRouteAttribute Class

Definition

Attribute to define a route that handles Teams message extension configure settings events.

[Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.MSTeams.MessageExtensions.SettingHandler))]
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public class TeamsSettingRouteAttribute : Attribute, Microsoft.Agents.Builder.App.IRouteAttribute
[<Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.MSTeams.MessageExtensions.SettingHandler))>]
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type TeamsSettingRouteAttribute = class
    inherit Attribute
    interface IRouteAttribute
Public Class TeamsSettingRouteAttribute
Inherits Attribute
Implements IRouteAttribute
Inheritance
TeamsSettingRouteAttribute
Attributes
Implements

Remarks

Decorate a method with this attribute to register it as a handler for message extension configure settings events in Teams. The method must match the SettingHandler delegate signature.

[TeamsSettingRoute]
public Task<Response> OnSettingAsync(ITeamsTurnContext turnContext, ITurnState turnState, Microsoft.Teams.Api.MessageExtensions.Query query, CancellationToken cancellationToken)
{
    // Persist user settings and return an updated result
    var setting = query.Parameters.FirstOrDefault()?.Value ?? string.Empty;
    _settingsStore.Save(turnContext.Activity.From.Id, setting);
    return Task.FromResult(new Response { ComposeExtension = new Result { Type = ResultType.Config } });
}

Alternatively, OnSetting(SettingHandler, String[], UInt16) can be used to register the handler via the fluent API.

Constructors

Name Description
TeamsSettingRouteAttribute(Boolean, UInt16, String)

Attribute to define a route that handles Teams message extension configure settings events.

Methods

Name Description
AddRoute(AgentApplication, MethodInfo)

Applies to