UNPKG

botbuilder-dialogs-adaptive

Version:

Rule system for the Microsoft BotBuilder dialog system.

46 lines 1.94 kB
"use strict"; /** * @module botbuilder-dialogs-adaptive */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.OnChooseIntent = void 0; const adaptive_expressions_1 = require("adaptive-expressions"); const botbuilder_dialogs_1 = require("botbuilder-dialogs"); const onIntent_1 = require("./onIntent"); /** * Actions triggered when an Intent of "ChooseIntent" has been emitted by a [Recognizer](xref:botbuilder-dialogs-adaptive.Recognizer). */ class OnChooseIntent extends onIntent_1.OnIntent { /** * Initializes a new instance of the [OnChooseIntent](xref:botbuilder-dialogs-adaptive.OnChooseIntent) class. * * @param {Dialog[]} actions Optional, actions to add to the plan when the rule constraints are met. * @param {string} condition Optional, condition which needs to be met for the actions to be executed. */ constructor(actions = [], condition) { super('ChooseIntent', [], actions, condition); this.intents = []; } /** * Create the expression for this condition. * * @returns [Expression](xref:adaptive-expressions.Expression) used to evaluate this rule. */ createExpression() { var _a; if ((_a = this.intents) === null || _a === void 0 ? void 0 : _a.length) { const constraints = this.intents.map((intent) => { return adaptive_expressions_1.Expression.parse(`contains(jPath(${botbuilder_dialogs_1.TurnPath.recognized}, '.candidates.intent'), '${intent}')`); }); return adaptive_expressions_1.Expression.andExpression(super.createExpression(), ...constraints); } return super.createExpression(); } } exports.OnChooseIntent = OnChooseIntent; OnChooseIntent.$kind = 'Microsoft.OnChooseIntent'; //# sourceMappingURL=onChooseIntent.js.map