Jaa


ActivityHandler.OnEventActivityAsync Method

Definition

Invoked when an event activity is received from the connector when the base behavior of OnTurnAsync(ITurnContext, CancellationToken) is used. Event activities can be used to communicate many different things. By default, this method will call OnTokenResponseEventAsync(ITurnContext<IEventActivity>, CancellationToken) if the activity's name is tokens/response or OnEventAsync(ITurnContext<IEventActivity>, CancellationToken) otherwise. A tokens/response event can be triggered by an OAuthCard.

protected virtual System.Threading.Tasks.Task OnEventActivityAsync (Microsoft.Bot.Builder.ITurnContext<Microsoft.Bot.Schema.IEventActivity> turnContext, System.Threading.CancellationToken cancellationToken);
abstract member OnEventActivityAsync : Microsoft.Bot.Builder.ITurnContext<Microsoft.Bot.Schema.IEventActivity> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.OnEventActivityAsync : Microsoft.Bot.Builder.ITurnContext<Microsoft.Bot.Schema.IEventActivity> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Protected Overridable Function OnEventActivityAsync (turnContext As ITurnContext(Of IEventActivity), cancellationToken As CancellationToken) As Task

Parameters

turnContext
ITurnContext<IEventActivity>

A strongly-typed context object for this turn.

cancellationToken
CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

A task that represents the work queued to execute.

Remarks

When the OnTurnAsync(ITurnContext, CancellationToken) method receives an event activity, it calls this method. If the event Name is `tokens/response`, it calls OnTokenResponseEventAsync(ITurnContext<IEventActivity>, CancellationToken); otherwise, it calls OnEventAsync(ITurnContext<IEventActivity>, CancellationToken).

In a derived class, override this method to add logic that applies to all event activities. Add logic to apply before the specific event-handling logic before the call to the base class OnEventActivityAsync(ITurnContext<IEventActivity>, CancellationToken) method. Add logic to apply after the specific event-handling logic after the call to the base class OnEventActivityAsync(ITurnContext<IEventActivity>, CancellationToken) method.

Event activities communicate programmatic information from a client or channel to a bot. The meaning of an event activity is defined by the Name property, which is meaningful within the scope of a channel. A `tokens/response` event can be triggered by an OAuthCard or an OAuth prompt.

Applies to

See also