1045 lines
No EOL
49 KiB
JavaScript
1045 lines
No EOL
49 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License.
|
|
*/
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.ActivityHandler = void 0;
|
|
const activityHandlerBase_1 = require("./activityHandlerBase");
|
|
const invokeException_1 = require("./invokeException");
|
|
const signInConstants_1 = require("./signInConstants");
|
|
const botframework_schema_1 = require("botframework-schema");
|
|
/**
|
|
* Event-emitting activity handler for bots. Extends [ActivityHandlerBase](xref:botbuilder-core.ActivityHandlerBase).
|
|
*
|
|
* @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 |
|
|
* | :--- | :--- |
|
|
* | Turn | Emitted first for every activity. |
|
|
* | 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. |
|
|
* | Dialog | Emitted as the final activity processing event. |
|
|
*
|
|
* For example:
|
|
*
|
|
* ```typescript
|
|
* const bot = new ActivityHandler();
|
|
*
|
|
* server.post('/api/messages', (req, res) => {
|
|
* adapter.processActivity(req, res, async (context) => {
|
|
* // Route to bot's activity logic.
|
|
* await bot.run(context);
|
|
* });
|
|
* });
|
|
*
|
|
* bot.onTurn(async (context, next) => {
|
|
* // Handle a "turn" event.
|
|
* await context.sendActivity(`${ context.activity.type } activity received.`);
|
|
* // Continue with further processing.
|
|
* await next();
|
|
* })
|
|
* .onMessage(async (context, next) => {
|
|
* // Handle a message activity.
|
|
* await context.sendActivity(`Echo: ${ context.activity.text }`);
|
|
* // Continue with further processing.
|
|
* await next();
|
|
* });
|
|
* ```
|
|
*
|
|
* **See also**
|
|
* - The [Bot Framework Activity schema](https://aka.ms/botSpecs-activitySchema)
|
|
*/
|
|
class ActivityHandler extends activityHandlerBase_1.ActivityHandlerBase {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.handlers = {};
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _turn_ event, emitted for every incoming activity, regardless of type.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
*/
|
|
onTurn(handler) {
|
|
return this.on('Turn', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _message_ event, emitted for every incoming message activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* Message activities represent content intended to be shown within a conversational interface
|
|
* and can contain text, speech, interactive cards, and binary or unknown attachments.
|
|
* Not all message activities contain text, the activity's [text](xref:botframework-schema.Activity.text)
|
|
* property can be `null` or `undefined`.
|
|
*/
|
|
onMessage(handler) {
|
|
return this.on('Message', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _message update_ event, emitted for every incoming message activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* Message update activities represent an update of an existing message activity within a conversation.
|
|
* The updated activity is referred to by the [id](xref:botbuilder-core.TurnContext.activity.id) and
|
|
* [conversation](xref:botbuilder-core.TurnContext.activity.conversation) fields within the activity, and the
|
|
* message update activity contains all fields in the revised message activity.
|
|
* Message update activities are identified by a [type](xref:botbuilder-core.TurnContext.activity.type) value of
|
|
* `messageUpdate`.
|
|
*/
|
|
onMessageUpdate(handler) {
|
|
return this.on('MessageUpdate', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _message delete_ event, emitted for every incoming message activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* Message delete activities represent a deletion of an existing message activity within a conversation.
|
|
* The deleted activity is referred to by the [id](xref:botbuilder-core.TurnContext.activity.id) and
|
|
* [conversation](xref:botbuilder-core.TurnContext.activity.conversation) fields within the activity.
|
|
* Message delete activities are identified by a [type](xref:botbuilder-core.TurnContext.activity.type) value of
|
|
* `messageDelete`.
|
|
*/
|
|
onMessageDelete(handler) {
|
|
return this.on('MessageDelete', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _conversation update_ event, emitted for every incoming
|
|
* conversation update activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* Conversation update activities describe a changes to a conversation's metadata, such as title, participants,
|
|
* or other channel-specific information.
|
|
*
|
|
* To handle when members are added to or removed from the conversation, use the
|
|
* [onMembersAdded](xref:botbuilder-core.ActivityHandler.onMembersAdded) and
|
|
* [onMembersRemoved](xref:botbuilder-core.ActivityHandler.onMembersRemoved) sub-type event handlers.
|
|
*/
|
|
onConversationUpdate(handler) {
|
|
return this.on('ConversationUpdate', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _members added_ event, emitted for any incoming
|
|
* conversation update activity that includes members added to the conversation.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* The activity's [membersAdded](xref:botframework-schema.Activity.membersAdded) property
|
|
* contains the members added to the conversation, which can include the bot.
|
|
*
|
|
* To handle conversation update events in general, use the
|
|
* [onConversationUpdate](xref:botbuilder-core.ActivityHandler.onConversationUpdate) type-specific event handler.
|
|
*/
|
|
onMembersAdded(handler) {
|
|
return this.on('MembersAdded', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _members removed_ event, emitted for any incoming
|
|
* conversation update activity that includes members removed from the conversation.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* The activity's [membersRemoved](xref:botframework-schema.Activity.membersRemoved) property
|
|
* contains the members removed from the conversation, which can include the bot.
|
|
*
|
|
* To handle conversation update events in general, use the
|
|
* [onConversationUpdate](xref:botbuilder-core.ActivityHandler.onConversationUpdate) type-specific event handler.
|
|
*/
|
|
onMembersRemoved(handler) {
|
|
return this.on('MembersRemoved', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _message reaction_ event, emitted for every incoming
|
|
* message reaction activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* Message reaction activities represent a social interaction on an existing message activity
|
|
* within a conversation. The original activity is referred to by the message reaction activity's
|
|
* [replyToId](xref:botframework-schema.Activity.replyToId) property. The
|
|
* [from](xref:botframework-schema.Activity.from) property represents the source of the reaction,
|
|
* such as the user that reacted to the message.
|
|
*
|
|
* To handle when reactions are added to or removed from messages in the conversation, use the
|
|
* [onReactionsAdded](xref:botbuilder-core.ActivityHandler.onReactionsAdded) and
|
|
* [onReactionsRemoved](xref:botbuilder-core.ActivityHandler.onReactionsRemoved) sub-type event handlers.
|
|
*/
|
|
onMessageReaction(handler) {
|
|
return this.on('MessageReaction', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _reactions added_ event, emitted for any incoming
|
|
* message reaction activity that describes reactions added to a message.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* The activity's [reactionsAdded](xref:botframework-schema.Activity.reactionsAdded) property
|
|
* includes one or more reactions that were added.
|
|
*
|
|
* To handle message reaction events in general, use the
|
|
* [onMessageReaction](xref:botbuilder-core.ActivityHandler.onMessageReaction) type-specific event handler.
|
|
*/
|
|
onReactionsAdded(handler) {
|
|
return this.on('ReactionsAdded', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _reactions removed_ event, emitted for any incoming
|
|
* message reaction activity that describes reactions removed from a message.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* The activity's [reactionsRemoved](xref:botframework-schema.Activity.reactionsRemoved) property
|
|
* includes one or more reactions that were removed.
|
|
*
|
|
* To handle message reaction events in general, use the
|
|
* [onMessageReaction](xref:botbuilder-core.ActivityHandler.onMessageReaction) type-specific event handler.
|
|
*/
|
|
onReactionsRemoved(handler) {
|
|
return this.on('ReactionsRemoved', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _event_ event, emitted for every incoming event activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* Event activities communicate programmatic information from a client or channel to a bot.
|
|
* The meaning of an event activity is defined by the activity's
|
|
* [name](xref:botframework-schema.Activity.name) property, which is meaningful within the scope
|
|
* of a channel. Event activities are designed to carry both interactive information (such as
|
|
* button clicks) and non-interactive information (such as a notification of a client
|
|
* automatically updating an embedded speech model).
|
|
*
|
|
* To handle a `tokens/response` event event, use the
|
|
* [onTokenResponseEvent](xref:botbuilder-core.ActivityHandler.onTokenResponseEvent) sub-type
|
|
* event handler. To handle other named events, add logic to this handler.
|
|
*/
|
|
onEvent(handler) {
|
|
return this.on('Event', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _end of conversation_ activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* This activity is typically send from a Skill to a Skill caller indicating the end of that particular child conversation.
|
|
*
|
|
* To handle an End of Conversation, use the
|
|
* [onEndOfConversation](xref:botbuilder-core.ActivityHandler.onEndOfConversation) type-specific event handler.
|
|
*/
|
|
onEndOfConversation(handler) {
|
|
return this.on('EndOfConversation', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _typing_ activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* To handle a Typing event, use the
|
|
* [onTyping](xref:botbuilder-core.ActivityHandler.onTyping) type-specific event handler.
|
|
*/
|
|
onTyping(handler) {
|
|
return this.on('Typing', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _installationupdate_ activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* To handle a InstallationUpdate event, use the
|
|
* [onInstallationUpdate](xref:botbuilder-core.ActivityHandler.onInstallationUpdate) type-specific event handler.
|
|
*/
|
|
onInstallationUpdate(handler) {
|
|
return this.on('InstallationUpdate', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _installationupdate add_ activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* To handle a InstallationUpdateAdd event, use the
|
|
* [onInstallationUpdateAdd](xref:botbuilder-core.ActivityHandler.onInstallationUpdateAdd) type-specific event handler.
|
|
*/
|
|
onInstallationUpdateAdd(handler) {
|
|
return this.on('InstallationUpdateAdd', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _installationupdate remove_ activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* To handle a InstallationUpdateRemove event, use the
|
|
* [onInstallationUpdateRemove](xref:botbuilder-core.ActivityHandler.onInstallationUpdateRemove) type-specific event handler.
|
|
*/
|
|
onInstallationUpdateRemove(handler) {
|
|
return this.on('InstallationUpdateRemove', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _tokens-response_ event, emitted for any incoming
|
|
* `tokens/response` event activity. These are generated as part of the OAuth authentication flow.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* The activity's [value](xref:botframework-schema.Activity.value) property contains the user token.
|
|
*
|
|
* If your bot handles authentication using an [OAuthPrompt](xref:botbuilder-dialogs.OAuthPrompt)
|
|
* within a dialog, then the dialog will need to receive this activity to complete the authentication flow.
|
|
*
|
|
* To handle other named events and event events in general, use the
|
|
* [onEvent](xref:botbuilder-core.ActivityHandler.onEvent) type-specific event handler.
|
|
*/
|
|
onTokenResponseEvent(handler) {
|
|
return this.on('TokenResponseEvent', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _command_ activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* To handle a Command event, use the
|
|
* [onCommand](xref:botbuilder-core.ActivityHandler.onCommand) type-specific event handler.
|
|
*/
|
|
onCommand(handler) {
|
|
return this.on('Command', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _CommandResult_ activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* To handle a CommandResult event, use the
|
|
* [onCommandResult](xref:botbuilder-core.ActivityHandler.onCommandResult) type-specific event handler.
|
|
*/
|
|
onCommandResult(handler) {
|
|
return this.on('CommandResult', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _unrecognized activity type_ event, emitted for an
|
|
* incoming activity with a type for which the [ActivityHandler](xref:botbuilder-core.ActivityHandler)
|
|
* doesn't provide an event handler.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
* @remarks
|
|
* The `ActivityHandler` does not define events for all activity types defined in the
|
|
* [Bot Framework Activity schema](http://aka.ms/botSpecs-activitySchema). In addition,
|
|
* channels and custom adapters can create [Activities](xref:botframework-schema.Activity) with
|
|
* types not in the schema. When the activity handler receives such an event, it emits an unrecognized activity type event.
|
|
*
|
|
* The activity's [type](xref:botframework-schema.Activity.type) property contains the activity type.
|
|
*/
|
|
onUnrecognizedActivityType(handler) {
|
|
return this.on('UnrecognizedActivityType', handler);
|
|
}
|
|
/**
|
|
* Registers an activity event handler for the _dialog_ event, emitted as the last event for an incoming activity.
|
|
*
|
|
* @param handler The event handler.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
*/
|
|
onDialog(handler) {
|
|
return this.on('Dialog', handler);
|
|
}
|
|
/**
|
|
* Called to initiate the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @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:
|
|
* ```javascript
|
|
* server.post('/api/messages', (req, res) => {
|
|
* adapter.processActivity(req, res, async (context) => {
|
|
* // Route to bot's activity logic.
|
|
* await bot.run(context);
|
|
* });
|
|
* });
|
|
* ```
|
|
*
|
|
* **See also**
|
|
* - [BotFrameworkAdapter.processActivity](xref:botbuilder.BotFrameworkAdapter.processActivity)
|
|
*/
|
|
run(context) {
|
|
const _super = Object.create(null, {
|
|
run: { get: () => super.run }
|
|
});
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield _super.run.call(this, context);
|
|
});
|
|
}
|
|
/**
|
|
* Called at the start of the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to use custom logic for emitting events.
|
|
*
|
|
* The default logic is to call any handlers registered via [onTurn](xref:botbuilder-core.ActivityHandler.onTurn),
|
|
* and then continue by calling [ActivityHandlerBase.onTurnActivity](xref:botbuilder-core.ActivityHandlerBase.onTurnActivity).
|
|
*/
|
|
onTurnActivity(context) {
|
|
const _super = Object.create(null, {
|
|
onTurnActivity: { get: () => super.onTurnActivity }
|
|
});
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'Turn', () => __awaiter(this, void 0, void 0, function* () {
|
|
yield _super.onTurnActivity.call(this, context);
|
|
}));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _message_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onMessage](xref:botbuilder-core.ActivityHandler.onMessage),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onMessageActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'Message', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _message update_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onMessageUpdate](xref:botbuilder-core.ActivityHandler.onMessageUpdate),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onMessageUpdateActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'MessageUpdate', () => __awaiter(this, void 0, void 0, function* () {
|
|
yield this.dispatchMessageUpdateActivity(context);
|
|
}));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _message delete_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onMessageDelete](xref:botbuilder-core.ActivityHandler.onMessageDelete),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onMessageDeleteActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'MessageDelete', () => __awaiter(this, void 0, void 0, function* () {
|
|
yield this.dispatchMessageDeleteActivity(context);
|
|
}));
|
|
});
|
|
}
|
|
/**
|
|
* Provides default behavior for invoke activities.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @returns {Promise<InvokeResponse>} An Invoke Response for the activity.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
* The default logic is to check for a signIn invoke and handle that
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onInvokeActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
switch (context.activity.name) {
|
|
case 'application/search': {
|
|
const invokeValue = this.getSearchInvokeValue(context.activity);
|
|
const response = yield this.onSearchInvoke(context, invokeValue);
|
|
return { status: response.statusCode, body: response };
|
|
}
|
|
case 'adaptiveCard/action': {
|
|
const invokeValue = this.getAdaptiveCardInvokeValue(context.activity);
|
|
const response = yield this.onAdaptiveCardInvoke(context, invokeValue);
|
|
return { status: response.statusCode, body: response };
|
|
}
|
|
case signInConstants_1.verifyStateOperationName:
|
|
case signInConstants_1.tokenExchangeOperationName:
|
|
yield this.onSignInInvoke(context);
|
|
return { status: botframework_schema_1.StatusCodes.OK };
|
|
default:
|
|
throw new invokeException_1.InvokeException(botframework_schema_1.StatusCodes.NOT_IMPLEMENTED);
|
|
}
|
|
}
|
|
catch (err) {
|
|
if (err.message === 'NotImplemented') {
|
|
return { status: botframework_schema_1.StatusCodes.NOT_IMPLEMENTED };
|
|
}
|
|
if (err instanceof invokeException_1.InvokeException) {
|
|
return err.createInvokeResponse();
|
|
}
|
|
throw err;
|
|
}
|
|
finally {
|
|
this.defaultNextEvent(context)();
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Handle _signin invoke activity type_.
|
|
*
|
|
* @param _context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*/
|
|
onSignInInvoke(_context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
throw new invokeException_1.InvokeException(botframework_schema_1.StatusCodes.NOT_IMPLEMENTED);
|
|
});
|
|
}
|
|
/**
|
|
* Invoked when the bot is sent an Adaptive Card Action Execute.
|
|
*
|
|
* @param _context the context object for the current turn
|
|
* @param _invokeValue incoming activity value
|
|
* @returns {Promise<AdaptiveCardInvokeResponse>} An Adaptive Card Invoke Response for the activity.
|
|
*/
|
|
onAdaptiveCardInvoke(_context, _invokeValue) {
|
|
return Promise.reject(new invokeException_1.InvokeException(botframework_schema_1.StatusCodes.NOT_IMPLEMENTED));
|
|
}
|
|
/**
|
|
* Invoked when the bot is sent an invoke activity with name of 'application/search'.
|
|
*
|
|
* @param _context the context object for the current turn.
|
|
* @param _invokeValue incoming activity value.
|
|
* @returns {Promise<SearchInvokeResponse>} A Search Invoke Response for the activity.
|
|
*/
|
|
onSearchInvoke(_context, _invokeValue) {
|
|
return Promise.reject(new invokeException_1.InvokeException(botframework_schema_1.StatusCodes.NOT_IMPLEMENTED));
|
|
}
|
|
/**
|
|
* Runs all registered _endOfConversation_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onEndOfConversationActivity](xref:botbuilder-core.ActivityHandler.onMessage),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onEndOfConversationActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'EndOfConversation', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _typing_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onTypingActivity](xref:botbuilder-core.ActivityHandler.onTypingActivity),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onTypingActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'Typing', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _instllationupdate_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onInstallationUpdateActivity](xref:botbuilder-core.ActivityHandler.onInstallationUpdateActivity),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onInstallationUpdateActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'InstallationUpdate', () => __awaiter(this, void 0, void 0, function* () {
|
|
yield this.dispatchInstallationUpdateActivity(context);
|
|
}));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _command_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
*/
|
|
onCommandActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'Command', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _commandresult_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
*/
|
|
onCommandResultActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'CommandResult', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
/**
|
|
* Runs the _installation update_ sub-type handlers, as appropriate, and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels or to add
|
|
* custom conversation update sub-type events.
|
|
*
|
|
* The default logic is:
|
|
* - If any members were added, call handlers registered via [onMembersAdded](xref:botbuilder-core.ActivityHandler.onMembersAdded).
|
|
* - If any members were removed, call handlers registered via [onMembersRemoved](xref:botbuilder-core.ActivityHandler.onMembersRemoved).
|
|
* - Continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
dispatchInstallationUpdateActivity(context) {
|
|
const _super = Object.create(null, {
|
|
onInstallationUpdateActivity: { get: () => super.onInstallationUpdateActivity }
|
|
});
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
switch (context.activity.action) {
|
|
case 'add':
|
|
case 'add-upgrade':
|
|
case 'remove':
|
|
case 'remove-upgrade':
|
|
yield _super.onInstallationUpdateActivity.call(this, context);
|
|
break;
|
|
default:
|
|
yield this.defaultNextEvent(context)();
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _installation update add_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onInstallationUpdateAdd](xref:botbuilder-core.ActivityHandler.onInstallationUpdateAdd),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onInstallationUpdateAddActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'InstallationUpdateAdd', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _installation update remove_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onInstallationUpdateRemove](xref:botbuilder-core.ActivityHandler.onInstallationUpdateRemove),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onInstallationUpdateRemoveActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'InstallationUpdateRemove', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _unrecognized activity type_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onUnrecognizedActivityType](xref:botbuilder-core.ActivityHandler.onUnrecognizedActivityType),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onUnrecognizedActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'UnrecognizedActivityType', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
getSearchInvokeValue(activity) {
|
|
const { value } = activity;
|
|
if (!value) {
|
|
const response = this.createAdaptiveCardInvokeErrorResponse(botframework_schema_1.StatusCodes.BAD_REQUEST, 'BadRequest', 'Missing value property for search');
|
|
throw new invokeException_1.InvokeException(botframework_schema_1.StatusCodes.BAD_REQUEST, response);
|
|
}
|
|
if (!value.kind) {
|
|
if (activity.channelId === botframework_schema_1.Channels.Msteams) {
|
|
value.kind = 'search';
|
|
}
|
|
else {
|
|
const response = this.createAdaptiveCardInvokeErrorResponse(botframework_schema_1.StatusCodes.BAD_REQUEST, 'BadRequest', 'Missing kind property for search.');
|
|
throw new invokeException_1.InvokeException(botframework_schema_1.StatusCodes.BAD_REQUEST, response);
|
|
}
|
|
}
|
|
if (!value.queryText) {
|
|
const response = this.createAdaptiveCardInvokeErrorResponse(botframework_schema_1.StatusCodes.BAD_REQUEST, 'BadRequest', 'Missing queryText for search.');
|
|
throw new invokeException_1.InvokeException(botframework_schema_1.StatusCodes.BAD_REQUEST, response);
|
|
}
|
|
return value;
|
|
}
|
|
getAdaptiveCardInvokeValue(activity) {
|
|
const { value } = activity;
|
|
if (!value) {
|
|
const response = this.createAdaptiveCardInvokeErrorResponse(botframework_schema_1.StatusCodes.BAD_REQUEST, 'BadRequest', 'Missing value property');
|
|
throw new invokeException_1.InvokeException(botframework_schema_1.StatusCodes.BAD_REQUEST, response);
|
|
}
|
|
if (value.action.type !== 'Action.Execute') {
|
|
const response = this.createAdaptiveCardInvokeErrorResponse(botframework_schema_1.StatusCodes.BAD_REQUEST, 'NotSupported', `The action '${value.action.type}' is not supported.`);
|
|
throw new invokeException_1.InvokeException(botframework_schema_1.StatusCodes.BAD_REQUEST, response);
|
|
}
|
|
const { action, authentication, state } = value;
|
|
const { data, id: actionId, type, verb } = action !== null && action !== void 0 ? action : {};
|
|
const { connectionName, id: authenticationId, token } = authentication !== null && authentication !== void 0 ? authentication : {};
|
|
return {
|
|
action: {
|
|
data,
|
|
id: actionId,
|
|
type,
|
|
verb,
|
|
},
|
|
authentication: {
|
|
connectionName,
|
|
id: authenticationId,
|
|
token,
|
|
},
|
|
state,
|
|
};
|
|
}
|
|
createAdaptiveCardInvokeErrorResponse(statusCode, code, message) {
|
|
return {
|
|
statusCode,
|
|
type: 'application/vnd.microsoft.error',
|
|
value: { code, message },
|
|
};
|
|
}
|
|
/**
|
|
* Runs all registered _conversation update_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onConversationUpdate](xref:botbuilder-core.ActivityHandler.onConversationUpdate),
|
|
* and then continue by calling
|
|
* [dispatchConversationUpdateActivity](xref:botbuilder-core.ActivityHandler.dispatchConversationUpdateActivity).
|
|
*/
|
|
onConversationUpdateActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'ConversationUpdate', () => __awaiter(this, void 0, void 0, function* () {
|
|
yield this.dispatchConversationUpdateActivity(context);
|
|
}));
|
|
});
|
|
}
|
|
/**
|
|
* Runs the _conversation update_ sub-type handlers, as appropriate, and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels or to add
|
|
* custom conversation update sub-type events.
|
|
*
|
|
* The default logic is:
|
|
* - If any members were added, call handlers registered via [onMembersAdded](xref:botbuilder-core.ActivityHandler.onMembersAdded).
|
|
* - If any members were removed, call handlers registered via [onMembersRemoved](xref:botbuilder-core.ActivityHandler.onMembersRemoved).
|
|
* - Continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
dispatchConversationUpdateActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (context.activity.membersAdded && context.activity.membersAdded.length > 0) {
|
|
yield this.handle(context, 'MembersAdded', this.defaultNextEvent(context));
|
|
}
|
|
else if (context.activity.membersRemoved && context.activity.membersRemoved.length > 0) {
|
|
yield this.handle(context, 'MembersRemoved', this.defaultNextEvent(context));
|
|
}
|
|
else {
|
|
yield this.defaultNextEvent(context)();
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Runs the _message update_ sub-type handlers, as appropriate, and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels or to add
|
|
* custom conversation update sub-type events.
|
|
*
|
|
* The default logic to simple call [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
dispatchMessageUpdateActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.defaultNextEvent(context)();
|
|
});
|
|
}
|
|
/**
|
|
* Runs the _message delete_ sub-type handlers, as appropriate, and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels or to add
|
|
* custom conversation update sub-type events.
|
|
*
|
|
* The default logic to simple call [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
dispatchMessageDeleteActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.defaultNextEvent(context)();
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _message reaction_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onMessageReaction](xref:botbuilder-core.ActivityHandler.onMessageReaction),
|
|
* and then continue by calling
|
|
* [dispatchMessageReactionActivity](xref:botbuilder-core.ActivityHandler.dispatchMessageReactionActivity).
|
|
*/
|
|
onMessageReactionActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'MessageReaction', () => __awaiter(this, void 0, void 0, function* () {
|
|
yield this.dispatchMessageReactionActivity(context);
|
|
}));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _reactions added_ handlers and then continues the event emission process.
|
|
*
|
|
* @param reactionsAdded The list of reactions added.
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onReactionsAdded](xref:botbuilder-core.ActivityHandler.onReactionsAdded),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onReactionsAddedActivity(reactionsAdded, context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'ReactionsAdded', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered _reactions removed_ handlers and then continues the event emission process.
|
|
*
|
|
* @param reactionsRemoved The list of reactions removed.
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onReactionsRemoved](xref:botbuilder-core.ActivityHandler.onReactionsRemoved),
|
|
* and then continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
onReactionsRemovedActivity(reactionsRemoved, context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'ReactionsRemoved', this.defaultNextEvent(context));
|
|
});
|
|
}
|
|
/**
|
|
* Runs the _message reaction_ sub-type handlers, as appropriate, and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels or to add
|
|
* custom message reaction sub-type events.
|
|
*
|
|
* The default logic is:
|
|
* - If reactions were added, call handlers registered via [onReactionsAdded](xref:botbuilder-core.ActivityHandler.onReactionsAdded).
|
|
* - If reactions were removed, call handlers registered via [onMembersRemoved](xref:botbuilder-core.ActivityHandler.onMembersRemoved).
|
|
* - Continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
dispatchMessageReactionActivity(context) {
|
|
const _super = Object.create(null, {
|
|
onMessageReactionActivity: { get: () => super.onMessageReactionActivity }
|
|
});
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (context.activity.reactionsAdded || context.activity.reactionsRemoved) {
|
|
yield _super.onMessageReactionActivity.call(this, context);
|
|
}
|
|
else {
|
|
yield this.defaultNextEvent(context)();
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Runs all registered event_ handlers and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels.
|
|
*
|
|
* The default logic is to call any handlers registered via
|
|
* [onEvent](xref:botbuilder-core.ActivityHandler.onEvent),
|
|
* and then continue by calling
|
|
* [dispatchEventActivity](xref:botbuilder-core.ActivityHandler.dispatchEventActivity).
|
|
*/
|
|
onEventActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'Event', () => __awaiter(this, void 0, void 0, function* () {
|
|
yield this.dispatchEventActivity(context);
|
|
}));
|
|
});
|
|
}
|
|
/**
|
|
* Runs the _event_ sub-type handlers, as appropriate, and then continues the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @remarks
|
|
* Override this method to support channel-specific behavior across multiple channels or to add custom event sub-type events.
|
|
* For certain channels, such as Web Chat and custom Direct Line clients, developers can emit custom event activities from the client.
|
|
*
|
|
* The default logic is:
|
|
* - If the activity is a 'tokens/response' event, call handlers registered via
|
|
* [onTokenResponseEvent](xref:botbuilder-core.ActivityHandler.onTokenResponseEvent).
|
|
* - Continue by calling [defaultNextEvent](xref:botbuilder-core.ActivityHandler.defaultNextEvent).
|
|
*/
|
|
dispatchEventActivity(context) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (context.activity.name === signInConstants_1.tokenResponseEventName) {
|
|
yield this.handle(context, 'TokenResponseEvent', this.defaultNextEvent(context));
|
|
}
|
|
else {
|
|
yield this.defaultNextEvent(context)();
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Called at the end of the event emission process.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @returns {Promise<void>} A promise representing the async operation.
|
|
* @remarks
|
|
* Override this method to use custom logic for emitting events.
|
|
*
|
|
* The default logic is to call any handlers registered via [onDialog](xref:botbuilder-core.ActivityHandler.onDialog),
|
|
* and then complete the event emission process.
|
|
*/
|
|
defaultNextEvent(context) {
|
|
const runDialogs = () => __awaiter(this, void 0, void 0, function* () {
|
|
yield this.handle(context, 'Dialog', () => __awaiter(this, void 0, void 0, function* () {
|
|
// noop
|
|
}));
|
|
});
|
|
return runDialogs;
|
|
}
|
|
/**
|
|
* Registers a bot event handler to receive a specific event.
|
|
*
|
|
* @param type The identifier for the event type.
|
|
* @param handler The event handler to register.
|
|
* @returns A reference to the [ActivityHandler](xref:botbuilder-core.ActivityHandler) object.
|
|
*/
|
|
on(type, handler) {
|
|
if (!this.handlers[type]) {
|
|
this.handlers[type] = [handler];
|
|
}
|
|
else {
|
|
this.handlers[type].push(handler);
|
|
}
|
|
return this;
|
|
}
|
|
/**
|
|
* Emits an event and executes any registered handlers.
|
|
*
|
|
* @param context The context object for the current turn.
|
|
* @param type The identifier for the event type.
|
|
* @param onNext The continuation function to call after all registered handlers for this event complete.
|
|
* @returns {Promise<any>} The handler's return value.
|
|
* @remarks
|
|
* Runs any registered handlers for this event type and then calls the continuation function.
|
|
*
|
|
* This optionally produces a return value, to support _invoke_ activities. If multiple handlers
|
|
* produce a return value, the first one produced is returned.
|
|
*/
|
|
handle(context, type, onNext) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let returnValue = null;
|
|
function runHandler(index) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (index < handlers.length) {
|
|
const val = yield handlers[index](context, () => runHandler(index + 1));
|
|
// if a value is returned, and we have not yet set the return value,
|
|
// capture it. This is used to allow InvokeResponses to be returned.
|
|
if (typeof val !== 'undefined' && returnValue === null) {
|
|
returnValue = val;
|
|
}
|
|
}
|
|
else {
|
|
const val = yield onNext();
|
|
if (typeof val !== 'undefined') {
|
|
returnValue = val;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
const handlers = this.handlers[type] || [];
|
|
yield runHandler(0);
|
|
return returnValue;
|
|
});
|
|
}
|
|
/**
|
|
* An [InvokeResponse](xref:botbuilder.InvokeResponse) factory that initializes the body to the parameter passed and status equal to OK.
|
|
*
|
|
* @param body JSON serialized content from a POST response.
|
|
* @returns A new [InvokeResponse](xref:botbuilder.InvokeResponse) object.
|
|
*/
|
|
static createInvokeResponse(body) {
|
|
return { status: 200, body };
|
|
}
|
|
}
|
|
exports.ActivityHandler = ActivityHandler;
|
|
//# sourceMappingURL=activityHandler.js.map
|