ActivityHandlerBase class

Defines the core behavior for event-emitting activity handlers for bots.

Remarks

This provides an extensible class for handling incoming activities in an event-driven way. You can register an arbitrary set of handlers for each event type.

To register a handler for an event, use the corresponding on event method. If multiple handlers are registered for an event, they are run in the order in which they were registered.

This object emits a series of events as it processes an incoming activity. A handler can stop the propagation of the event by not calling the continuation function.

Event type Description
Type-specific Emitted for the specific activity type, before emitting an event for any sub-type.
Sub-type Emitted for certain specialized events, based on activity content.

See also

Methods

run(TurnContext)

Called to initiate the event emission process.

Method Details

run(TurnContext)

Called to initiate the event emission process.

function run(context: TurnContext): Promise<void>

Parameters

context
TurnContext

The context object for the current turn.

Returns

Promise<void>

Remarks

Typically, you would provide this method as the function handler that the adapter calls to perform the bot's logic after the received activity has been pre-processed by the adapter and routed through any middleware.

For example:

 server.post('/api/messages', (req, res) => {
     adapter.processActivity(req, res, async (context) => {
         // Route to main dialog.
         await bot.run(context);
     });
});

See also