MembersAddedRouteAttribute(Boolean, UInt16, String) Constructor

Definition

Attribute to define a route that handles conversation update activities when members are added.

public MembersAddedRouteAttribute(bool isAgenticOnly = false, ushort rank = 32767, string autoSignInHandlers = default);
new Microsoft.Agents.Builder.App.MembersAddedRouteAttribute : bool * uint16 * string -> Microsoft.Agents.Builder.App.MembersAddedRouteAttribute
Public Sub New (Optional isAgenticOnly As Boolean = false, Optional rank As UShort = 32767, Optional autoSignInHandlers As String = Nothing)

Parameters

isAgenticOnly
Boolean

When true, the route only fires for agentic turns. Defaults to false.

rank
UInt16

Route evaluation order. Lower values run first. Defaults to Unspecified.

autoSignInHandlers
String

A comma/space/semicolon-delimited list of OAuth sign-in handler names, or the name of an instance or static method on the agent class matching Func<ITurnContext, string[]>.

Remarks

Decorate a method with this attribute to register it as a handler for the MembersAdded event. The method must match the RouteHandler delegate signature.

[MembersAddedRoute]
public async Task OnMembersAddedAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
   foreach (ChannelAccount member in turnContext.Activity.MembersAdded)
   {
       if (member.Id != turnContext.Activity.Recipient.Id)
       {
           await turnContext.SendActivityAsync(MessageFactory.Text("Hello and Welcome!"), cancellationToken);
       }
   }
}

Applies to