Documentation - v1.2.0-alpha.3
    Preparing search index...

    Class AgentExtension<TState>

    Represents an extension that adds channel-specific routing functionality to an agent application. This class allows you to register routes that are only active for a specific channel.

    Type Parameters

    • TState extends TurnState

      The type of turn state that extends TurnState

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    channelId: string

    The channel ID that this extension is associated with

    Methods

    • Adds a route to the agent application that is only active for the channel specified in this extension. This method creates a channel-specific route by wrapping the provided route selector with an additional check to ensure the incoming activity matches the extension's channel ID.

      Parameters

      • app: AgentApplication<TState>

        The agent application instance to add the route to

      • routeSelector: Selector

        A function that determines if the route should handle the incoming activity

      • routeHandler: RouteHandler<TurnState<DefaultConversationState, DefaultUserState>>

        The handler function that will process the activity when the route is matched

      • isInvokeRoute: boolean = false

        Optional. Whether this route handles invoke activities. Defaults to false

      • rank: number = RouteRank.Unspecified

        Optional. The priority rank of this route for routing precedence. Defaults to RouteRank.Unspecified

      Returns void

      const teamsExtension = new AgentExtension<MyState>('msteams');
      teamsExtension.addRoute(
      app,
      (context) => context.activity.type === 'message',
      async (context, state) => {
      // Handle Teams-specific message
      await context.sendActivity('Hello from Teams!');
      }
      );