UNPKG

twilio-ccai-fulfillment-tools

Version:

A collection of tools to assist in the creation of Twilio CCAI Integration cards via fulfillment scripts

36 lines (35 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addIntentsToMapContext = void 0; var __1 = require(".."); exports.addIntentsToMapContext = function (mapContext, dfRequest) { var _a, _b, _c; var parameters = (_a = dfRequest.queryResult) === null || _a === void 0 ? void 0 : _a.parameters; if (parameters) { var intentParams_1 = []; Object.keys(parameters).forEach(function (param) { intentParams_1.push(__1.createTextItem({ title: "Intent Param: " + param, data: parameters[param], })); }); mapContext.parameters.sync_attributes.data['HELPERS_CURRENT_INTENT'] = __1.createDetail({ width: __1.SIZES.THIRD, items: [ __1.createTextItem({ title: 'Current Intent', data: ((_c = (_b = dfRequest.queryResult) === null || _b === void 0 ? void 0 : _b.intent) === null || _c === void 0 ? void 0 : _c.displayName) || 'No intent detected', }), ], }); mapContext.parameters.sync_attributes.data['HELPERS_INTENT_DETAILS'] = __1.createDetail({ width: __1.SIZES.TWO_THIRD, items: intentParams_1 !== null && intentParams_1 !== void 0 ? intentParams_1 : __1.createTextItem({ title: 'Intent Params', data: 'No parameters', }), }); } return mapContext; };