botbuilder-dialogs-adaptive
Version:
Rule system for the Microsoft BotBuilder dialog system.
42 lines • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OnActivity = void 0;
/**
* @module botbuilder-dialogs-adaptive
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const adaptive_expressions_1 = require("adaptive-expressions");
const botbuilder_dialogs_1 = require("botbuilder-dialogs");
const onDialogEvent_1 = require("./onDialogEvent");
const adaptiveEvents_1 = require("../adaptiveEvents");
/**
* Actions triggered when an [Activity](xref:botframework-schema.Activity) of a given type is received.
*/
class OnActivity extends onDialogEvent_1.OnDialogEvent {
/**
* Initializes a new instance of the [OnActivity](xref:botbuilder-dialogs-adaptive.OnActivity) class.
*
* @param type Optional, ActivityType which must be matched for this event to trigger.
* @param actions Optional, actions to add to the plan when the rule constraints are met.
* @param condition Optional, condition which needs to be met for the actions to be executed.
*/
constructor(type, actions = [], condition) {
super(adaptiveEvents_1.AdaptiveEvents.activityReceived, actions, condition);
this.type = type;
}
/**
* Create expression for this condition.
*
* @returns {Expression} An [Expression](xref:adaptive-expressions.Expression) used to evaluate this rule.
*/
createExpression() {
// add constraints for activity type
return adaptive_expressions_1.Expression.andExpression(adaptive_expressions_1.Expression.parse(`${botbuilder_dialogs_1.TurnPath.activity}.type == '${this.type}'`), super.createExpression());
}
}
exports.OnActivity = OnActivity;
OnActivity.$kind = 'Microsoft.OnActivity';
//# sourceMappingURL=onActivity.js.map