botbuilder-dialogs-adaptive
Version:
Rule system for the Microsoft BotBuilder dialog system.
59 lines • 2.78 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// 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.SendHandoffActivity = void 0;
/**
* @module botbuilder-dialogs-adaptive
*/
const botbuilder_1 = require("botbuilder");
const adaptive_expressions_1 = require("adaptive-expressions");
const botbuilder_dialogs_1 = require("botbuilder-dialogs");
/**
* Sends a handoff activity. Note that this is a single turn/step dialog (i.e. it calls
* this.endDialog).
*/
class SendHandoffActivity extends botbuilder_dialogs_1.Dialog {
/**
* @param property The key of the conditional selector configuration.
* @returns The converter for the selector configuration.
*/
getConverter(property) {
switch (property) {
case 'context':
return new adaptive_expressions_1.ObjectExpressionConverter();
case 'transcript':
return new adaptive_expressions_1.ObjectExpressionConverter();
default:
return super.getConverter(property);
}
}
/**
* Starts a new [Dialog](xref:botbuilder-dialogs.Dialog) and pushes it onto the dialog stack.
*
* @param {DialogContext} dc dialog context
* @returns {Promise<DialogTurnResult<ResourceResponse>>} result of sending handoff activity
*/
beginDialog(dc) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
const context = (_a = this.context) === null || _a === void 0 ? void 0 : _a.getValue(dc.state);
const transcript = (_b = this.transcript) === null || _b === void 0 ? void 0 : _b.getValue(dc.state);
const activity = botbuilder_1.EventFactory.createHandoffInitiation(dc.context, context, transcript);
const response = yield dc.context.sendActivity(activity);
return dc.endDialog(response);
});
}
}
exports.SendHandoffActivity = SendHandoffActivity;
SendHandoffActivity.$kind = 'Microsoft.SendHandoffActivity';
//# sourceMappingURL=sendHandoffActivity.js.map