ActivityHandler.OnCommandActivityAsync Method

Definition

Invoked when a command activity is received when the base behavior of OnTurnAsync(ITurnContext, CancellationToken) is used. Commands are requests to perform an action and receivers typically respond with one or more commandResult activities. Receivers are also expected to explicitly reject unsupported command activities.

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

Parameters

turnContext
ITurnContext<ICommandActivity>

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 a command activity, it calls this method.

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

Command activities communicate programmatic information from a client or channel to a bot. The meaning of an command activity is defined by the Name property, which is meaningful within the scope of a channel.

Applies to

See also