Language

SlackEventRouteAttribute Class

Definition

Attribute to define a route that handles event activities, optionally matching a specific event name or name pattern.

[Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.Slack.SlackRouteHandler))]
[Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Builder.App.RouteHandler))]
[Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Builder.App.TypedRouteHandler<Microsoft.Agents.Extensions.Slack.ISlackActivity>))]
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public class SlackEventRouteAttribute : Attribute, Microsoft.Agents.Builder.App.IRouteAttribute
[<Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.Slack.SlackRouteHandler))>]
[<Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Builder.App.RouteHandler))>]
[<Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Builder.App.TypedRouteHandler<Microsoft.Agents.Extensions.Slack.ISlackActivity>))>]
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type SlackEventRouteAttribute = class
    inherit Attribute
    interface IRouteAttribute
Public Class SlackEventRouteAttribute
Inherits Attribute
Implements IRouteAttribute
Inheritance
SlackEventRouteAttribute
Attributes
Implements

Remarks

Decorate a method with this attribute to register it as a handler for event activities. Provide name for an exact match, nameRegex for a pattern match, or neither to match any event. name and nameRegex are mutually exclusive. The method must match the SlackRouteHandler, RouteHandler, or TypedRouteHandler<T> of ISlackActivity delegate signature.

// Match any event
[SlackEventRoute]
public async Task OnAnyEventAsync(ISlackTurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle any event activity
}

// Match a specific event
[SlackEventRoute("myEvent")]
public async Task OnMyEventAsync(ISlackTurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle "myEvent" event
}

// Match an event name pattern
[SlackEventRoute(nameRegex: "my.*Event")]
public async Task OnMyEventPatternAsync(ISlackTurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle events matching pattern
}

Constructors

Name Description
SlackEventRouteAttribute(String, String, Boolean, UInt16, String)

Attribute to define a route that handles event activities, optionally matching a specific event name or name pattern.

Methods

Name Description
AddRoute(AgentApplication, MethodInfo)

Applies to