Language

TeamsQueryLinkRouteAttribute Class

Definition

Attribute to define a route that handles Teams message extension query link (link unfurling) events.

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

Remarks

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

[TeamsQueryLinkRoute]
public async Task<Response> OnQueryLinkAsync(ITeamsTurnContext turnContext, ITurnState turnState, string url, CancellationToken cancellationToken)
{
    var preview = await _service.FetchPreviewAsync(url, cancellationToken);
    var attachment = preview.ToCard().ToMessagingExtensionAttachment();
    return new Response { ComposeExtension = new Result { Type = ResultType.List, Attachments = [attachment] } };
}

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

Constructors

Name Description
TeamsQueryLinkRouteAttribute(Boolean, UInt16, String)

Attribute to define a route that handles Teams message extension query link (link unfurling) events.

Methods

Name Description
AddRoute(AgentApplication, MethodInfo)

Applies to