@cognigy/rest-api-client 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.snyk +1 -1
- package/build/GenericUploadFn.js +1 -1
- package/build/RestAPIClient.js +14 -0
- package/build/apigroups/AdministrationAPIGroup_2_0.js +25 -3
- package/build/apigroups/AnalyticsAPIGroup_2_0.js +12 -0
- package/build/apigroups/InsightsAPIGroup_2_0.js +53 -0
- package/build/apigroups/ResourcesAPIGroup_2_0.js +23 -2
- package/build/apigroups/index.js +5 -1
- package/build/authentication/BasicAuthentication/BasicAuthentication.js +8 -1
- package/build/authentication/OAuth2/ILoginByClientCredentialsParameters.js +3 -0
- package/build/authentication/OAuth2/IOAuth2ClientCredentialsGrantAccessTokenRequest.js +11 -0
- package/build/authentication/OAuth2/OAuth2Authentication.js +41 -15
- package/build/shared/charts/createNodeDescriptor.js +1 -1
- package/build/shared/charts/descriptors/apps/index.js +8 -0
- package/build/shared/charts/descriptors/apps/initAppSession.js +33 -0
- package/build/shared/charts/descriptors/apps/setAppState.js +46 -0
- package/build/shared/charts/descriptors/connectionNodes/smtp/emailNotification.js +6 -4
- package/build/shared/charts/descriptors/connectionNodes/smtp/sendEmail.js +2 -2
- package/build/shared/charts/descriptors/end.js +1 -0
- package/build/shared/charts/descriptors/index.js +86 -67
- package/build/shared/charts/descriptors/logic/goTo.js +1 -0
- package/build/shared/charts/descriptors/logic/if/else.js +2 -0
- package/build/shared/charts/descriptors/logic/if/if.js +2 -1
- package/build/shared/charts/descriptors/logic/if/then.js +2 -0
- package/build/shared/charts/descriptors/logic/index.js +5 -3
- package/build/shared/charts/descriptors/logic/interval/elseInterval.js +1 -0
- package/build/shared/charts/descriptors/logic/interval/onInterval.js +1 -0
- package/build/shared/charts/descriptors/logic/once/afterwards.js +1 -0
- package/build/shared/charts/descriptors/logic/once/onFirstExecution.js +1 -0
- package/build/shared/charts/descriptors/logic/setTranslation.js +88 -0
- package/build/shared/charts/descriptors/logic/switch/case.js +2 -0
- package/build/shared/charts/descriptors/logic/switch/default.js +2 -0
- package/build/shared/charts/descriptors/logic/switch/switch.js +52 -4
- package/build/shared/charts/descriptors/logic/switchLocale.js +30 -2
- package/build/shared/charts/descriptors/logic/think.js +7 -3
- package/build/shared/charts/descriptors/logic/thinkV2.js +104 -0
- package/build/shared/charts/descriptors/logic/wait.js +2 -9
- package/build/shared/charts/descriptors/message/checkChannelChange/checkChannelChange.js +1 -0
- package/build/shared/charts/descriptors/message/checkChannelChange/onNo.js +3 -1
- package/build/shared/charts/descriptors/message/checkChannelChange/onYes.js +3 -1
- package/build/shared/charts/descriptors/message/checkChannelChange/unchanged.js +3 -1
- package/build/shared/charts/descriptors/message/question/onAnswer.js +3 -1
- package/build/shared/charts/descriptors/message/question/onQuestion.js +3 -1
- package/build/shared/charts/descriptors/message/question/question.js +474 -56
- package/build/shared/charts/descriptors/message/question/utils/datepickerUtils.js +1 -0
- package/build/shared/charts/descriptors/message/question/utils/evaluateQuestionAnswer.js +9 -3
- package/build/shared/charts/descriptors/message/question/utils/generateAnswerShortForm.js +37 -0
- package/build/shared/charts/descriptors/message/question/utils/getQuestionText.js +36 -0
- package/build/shared/charts/descriptors/message/question/utils/resetNodeState.js +12 -0
- package/build/shared/charts/descriptors/message/question/utils/storeQuestionAnswer.js +30 -0
- package/build/shared/charts/descriptors/message/question/utils/validateQuestionAnswer.js +22 -0
- package/build/shared/charts/descriptors/microsoft/getToken.js +34 -0
- package/build/shared/charts/descriptors/microsoft/index.js +22 -0
- package/build/shared/charts/descriptors/microsoft/invalidateToken.js +29 -0
- package/build/shared/charts/descriptors/microsoft/tokenStatus/index.js +51 -0
- package/build/shared/charts/descriptors/microsoft/tokenStatus/tokenGranted.js +24 -0
- package/build/shared/charts/descriptors/microsoft/tokenStatus/tokenNotGranted.js +24 -0
- package/build/shared/charts/descriptors/microsoft/utils/design.js +5 -0
- package/build/shared/charts/descriptors/nlu/executeCognigyNLU.js +5 -0
- package/build/shared/charts/descriptors/nlu/extractAnswer.js +115 -0
- package/build/shared/charts/descriptors/nlu/fuzzySearch.js +270 -0
- package/build/shared/charts/descriptors/nlu/index.js +7 -1
- package/build/shared/charts/descriptors/nlu/matchPattern.js +104 -0
- package/build/shared/charts/descriptors/nlu/utils/patternMatcher.js +197 -0
- package/build/shared/charts/descriptors/profile/index.js +5 -1
- package/build/shared/charts/descriptors/profile/overwriteAnalytics.js +54 -2
- package/build/shared/charts/descriptors/profile/requestRating.js +57 -0
- package/build/shared/charts/descriptors/profile/setRating.js +39 -0
- package/build/shared/charts/descriptors/service/handover.js +29 -2
- package/build/shared/charts/descriptors/service/handoverV2.js +129 -0
- package/build/shared/charts/descriptors/service/httpRequest.js +26 -7
- package/build/shared/charts/descriptors/service/index.js +3 -1
- package/build/shared/charts/descriptors/service/triggerFunction/onScheduled.js +2 -0
- package/build/shared/charts/descriptors/service/triggerFunction/onSchedulingError.js +2 -0
- package/build/shared/charts/descriptors/start.js +1 -0
- package/build/shared/charts/descriptors/voicegateway/nodes/callRecording.js +36 -16
- package/build/shared/charts/descriptors/voicegateway/nodes/handover.js +2 -2
- package/build/shared/charts/descriptors/voicegateway/nodes/playURL.js +9 -0
- package/build/shared/charts/descriptors/voicegateway/nodes/sendMessage.js +1 -1
- package/build/shared/charts/descriptors/voicegateway/utils/paramUtils.js +9 -1
- package/build/shared/charts/descriptors/voicegateway2/index.js +21 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/dtmf.js +56 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/hangup.js +48 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/play.js +199 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/refer.js +44 -0
- package/build/shared/charts/descriptors/voicegateway2/nodes/setSessionConfig.js +584 -0
- package/build/shared/charts/descriptors/voicegateway2/utils/design.js +5 -0
- package/build/shared/charts/descriptors/voicegateway2/utils/strip-nulls.js +19 -0
- package/build/shared/constants.js +9 -1
- package/build/shared/errors/baseError.js +34 -1
- package/build/shared/helper/rest/array.js +19 -0
- package/build/shared/helper/rest/boolean.js +5 -1
- package/build/shared/helper/rest/index.js +4 -1
- package/build/shared/interfaces/IEndpointTranslationSettings.js +32 -0
- package/build/shared/interfaces/IHandoverRequestStatus.js +3 -0
- package/build/shared/interfaces/{restAPI/administration/user/v2.0/IDeleteUserMeRest_2_0.js → IHttpRequest.js} +1 -1
- package/build/shared/interfaces/IOrganisation.js +1 -1
- package/build/shared/interfaces/TEntrypointType.js +2 -0
- package/build/shared/interfaces/amqpInterface.js +3 -0
- package/build/shared/interfaces/analytics/IAnalyticsFlowHistoryData.js +3 -0
- package/build/shared/interfaces/analytics/IAnalyticsSourceData.js +196 -45
- package/build/shared/interfaces/analytics/IStepEvent.js +2 -1
- package/build/shared/interfaces/analytics/TAnalyticsMode.js +10 -0
- package/build/shared/interfaces/analytics/TAnalyticsType.js +5 -0
- package/build/shared/interfaces/debugEvents/IErrorEventPayload.js +3 -0
- package/build/shared/interfaces/debugEvents/TDebugEndpointEvent.js +1 -0
- package/build/shared/interfaces/debugEvents/TDebugEventType.js +2 -1
- package/build/shared/interfaces/debugEvents/TSessionStateEmitParams.js +3 -0
- package/build/shared/interfaces/handover.js +81 -3
- package/build/shared/interfaces/license.js +34 -0
- package/build/shared/interfaces/license.js.map +1 -0
- package/build/shared/interfaces/messageAPI/ai.js +15 -1
- package/build/shared/interfaces/messageAPI/endpoints.js +273 -9
- package/build/shared/interfaces/resources/IAuditEvent.js +15 -2
- package/build/shared/interfaces/resources/IChartNode.js +56 -10
- package/build/shared/interfaces/resources/IEndpoint.js +5 -2
- package/build/shared/interfaces/resources/IFlow.js +1 -1
- package/build/shared/interfaces/resources/ILexicon.js +8 -2
- package/build/shared/interfaces/resources/INLUConnector.js +15 -2
- package/build/shared/interfaces/resources/INodeDescriptorSet.js +164 -52
- package/build/shared/interfaces/resources/IOptionsResolverFunction.js +18 -0
- package/build/shared/interfaces/resources/IPlaybookRun.js +61 -0
- package/build/shared/interfaces/resources/IProject.js +7 -1
- package/build/shared/interfaces/resources/ISlotFiller.js +38 -21
- package/build/shared/interfaces/resources/ISnapshot.js +1 -1
- package/build/shared/interfaces/resources/ITrackAnalyticsStepsArguments.js +3 -0
- package/build/shared/interfaces/resources/TNLUConnectorType.js +2 -1
- package/build/shared/interfaces/resources/TResourceType.js +1 -0
- package/build/shared/interfaces/resources/TRestChannelType.js +5 -0
- package/build/shared/interfaces/resources/TSocketChannelType.js +5 -1
- package/build/shared/interfaces/resources/chart/IChartExecutable.js +3 -2
- package/build/shared/interfaces/resources/chart/IChartExecutableNode.js +1 -0
- package/build/shared/interfaces/resources/intent/IIntent.js +4 -2
- package/build/shared/interfaces/resources/intent/IIntentTrainGroup.js +3 -1
- package/build/shared/interfaces/resources/intent/ISentence.js +32 -8
- package/build/shared/interfaces/resources/settings/IAgentSettings.js +40 -2
- package/build/shared/interfaces/resources/settings/IFlowSettings.js +1 -1
- package/build/shared/interfaces/restAPI/administration/liveAgent/v2.0/IReadLiveAgentAccountRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/administration/liveAgent/v2.0/IReadProjectInboxRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/administration/liveAgent/v2.0/ISetupCognigyLiveAgentInboxRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/administration/liveAgent/v2.0/ISetupCognigyLiveAgentRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/administration/liveAgent/v2.0/index.js +3 -0
- package/build/shared/interfaces/restAPI/analytics/IDeleteAnalyticsRecordsRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/analytics/IUpdateAnalyticsRecordProperties_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/analytics/IUpdateAnalyticsRecordsRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/IAnalyticsQueryFilter_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/TAnalyticsQueryFilterOperator_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/messages/IGenerateMessagesRest_2_0.js +5 -0
- package/build/shared/interfaces/restAPI/insights/messages/ILoadMessagesReportByQueryHashResponse_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/messages/ILoadMessagesReportByQueryHashRestData_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/messages/ITopNMessages_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/reports/IGenerateReportResponse_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/reports/IGenerateReportRest_2_0.js +41 -0
- package/build/shared/interfaces/restAPI/insights/reports/ILoadReportByQueryHashResponse_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/reports/ILoadReportByQueryHashRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/steps/IGenerateStepReportRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/steps/IIndexStepsRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/steps/ILoadStepReportByQueryHashResponse_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/steps/ILoadStepReportByQueryHashRestData_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/steps/IStepIndexItem_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/steps/IStepReport_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/steps/IStep_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/transcripts/IGenerateTranscriptsRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/transcripts/ILoadTranscriptsReportByQueryHashResponse_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/transcripts/ILoadTranscriptsReportByQueryHashRestData_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/insights/transcripts/IStepPath_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/chart/v2.0/ISearchChartNodesRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/extension/v2.0/IUpdateExtensionPackageRest_2_0.js +4 -0
- package/build/shared/interfaces/restAPI/resources/flow/v2.0/ICreateFlowFromChildrenRest_2_0.js +4 -0
- package/build/shared/interfaces/restAPI/resources/flow/v2.0/intent/ITrainYesNoIntentsRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/lexicon/v2.0/IComposeLexiconDownloadLinkRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/nluconnector/v2.0/TNLUConnectorType_2_0.js +3 -1
- package/build/shared/interfaces/restAPI/resources/nodedescriptorsets/v2.0/IOptionsResolverRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/playbook/v2.0/IDeletePlaybookRunRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/playbook/v2.0/IIndexPlaybookRunsRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/playbook/v2.0/IPlaybookRunIndexItem_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/playbook/v2.0/IPlaybookRun_2_0.js +7 -0
- package/build/shared/interfaces/restAPI/resources/playbook/v2.0/IReadPlaybookRunRest_2_0.js +3 -0
- package/build/shared/interfaces/restAPI/resources/playbook/v2.0/ISchedulePlaybookRunRest_2_0.js +3 -0
- package/build/shared/interfaces/security/IACL.js +1 -1
- package/build/shared/interfaces/security/IPermission.js +6 -0
- package/build/shared/interfaces/security/IRole.js +8 -2
- package/build/shared/interfaces/sessionstate/ISessionState.js +3 -0
- package/build/shared/interfaces/sessionstate/index.js +3 -0
- package/build/shared/interfaces/trainer/ITrainerRecord.js +4 -0
- package/build/shared/interfaces/translation.js +11 -0
- package/package.json +5 -5
- package/types/index.d.ts +3905 -1178
- package/build/shared/charts/descriptors/logic/checkFrustration.js +0 -82
|
@@ -124,6 +124,7 @@ const getDatePickerFields = (condition) => [{
|
|
|
124
124
|
{ label: "da", value: "da" },
|
|
125
125
|
{ label: "de", value: "de" },
|
|
126
126
|
{ label: "en", value: "en" },
|
|
127
|
+
{ label: "en_gb", value: "gb" },
|
|
127
128
|
{ label: "eo", value: "eo" },
|
|
128
129
|
{ label: "es", value: "es" },
|
|
129
130
|
{ label: "et", value: "et" },
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.evaluateQuestionAnswer = void 0;
|
|
4
|
+
/* Custom modules */
|
|
5
|
+
const getQuestionText_1 = require("./getQuestionText");
|
|
6
|
+
/**
|
|
7
|
+
* Evaluates the answer of a question against its type
|
|
8
|
+
*/
|
|
4
9
|
function evaluateQuestionAnswer({ cognigy, config }) {
|
|
5
|
-
var _a;
|
|
6
10
|
const { type, keyphraseTag, usePositiveOnly, regex: regexField, storeDetailedResults } = config;
|
|
7
11
|
const { input } = cognigy;
|
|
8
12
|
let result;
|
|
@@ -13,8 +17,10 @@ function evaluateQuestionAnswer({ cognigy, config }) {
|
|
|
13
17
|
case "date":
|
|
14
18
|
const foundDate = (input.slots.DATE) ? true : false;
|
|
15
19
|
if (foundDate) {
|
|
16
|
-
if (input.slots.DATE[0] && input.slots.DATE[0].
|
|
20
|
+
if (input.slots.DATE.length === 1 && input.slots.DATE[0].start && !input.slots.DATE[0].end)
|
|
17
21
|
result = input.slots.DATE[0].start;
|
|
22
|
+
else if (input.slots.DATE.length === 1 && input.slots.DATE[0].start && input.slots.DATE[0].end)
|
|
23
|
+
result = input.slots.DATE[0];
|
|
18
24
|
else
|
|
19
25
|
result = input.slots.DATE;
|
|
20
26
|
}
|
|
@@ -90,7 +96,7 @@ function evaluateQuestionAnswer({ cognigy, config }) {
|
|
|
90
96
|
if (storeDetailedResults && result !== null && result !== undefined) {
|
|
91
97
|
result = {
|
|
92
98
|
"value": result,
|
|
93
|
-
"question": (
|
|
99
|
+
"question": getQuestionText_1.getQuestionText(config),
|
|
94
100
|
"timestamp": cognigy.input.currentTime.ISODate,
|
|
95
101
|
"answer": cognigy.input.text
|
|
96
102
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateAnswerShortForm = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Generates a readable shortform answer from any Question Type answer
|
|
6
|
+
* Especially important for dates
|
|
7
|
+
*
|
|
8
|
+
* @param type The question type
|
|
9
|
+
* @param answer The result of the question
|
|
10
|
+
* @returns string
|
|
11
|
+
*/
|
|
12
|
+
const generateAnswerShortForm = (type, answer, text) => {
|
|
13
|
+
let shortForm = answer;
|
|
14
|
+
switch (type) {
|
|
15
|
+
case "date":
|
|
16
|
+
shortForm = answer.plain;
|
|
17
|
+
break;
|
|
18
|
+
case "yesNo":
|
|
19
|
+
shortForm = text;
|
|
20
|
+
break;
|
|
21
|
+
case "temperature":
|
|
22
|
+
case "age":
|
|
23
|
+
shortForm = answer.value;
|
|
24
|
+
break;
|
|
25
|
+
case "money":
|
|
26
|
+
shortForm = `${answer.value} ${answer.unit}`;
|
|
27
|
+
break;
|
|
28
|
+
// and either
|
|
29
|
+
case "data":
|
|
30
|
+
shortForm = JSON.stringify(answer);
|
|
31
|
+
break;
|
|
32
|
+
// there are no good short forms for duration and others, so we will just leave them out
|
|
33
|
+
}
|
|
34
|
+
return shortForm;
|
|
35
|
+
};
|
|
36
|
+
exports.generateAnswerShortForm = generateAnswerShortForm;
|
|
37
|
+
//# sourceMappingURL=generateAnswerShortForm.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getQuestionText = void 0;
|
|
4
|
+
function getQuestionText(config) {
|
|
5
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35;
|
|
6
|
+
if (((_a = config === null || config === void 0 ? void 0 : config.say) === null || _a === void 0 ? void 0 : _a.type) === "quickReplies") {
|
|
7
|
+
return ((_f = (_e = (_d = (_c = (_b = config === null || config === void 0 ? void 0 : config.say) === null || _b === void 0 ? void 0 : _b._data) === null || _c === void 0 ? void 0 : _c._cognigy) === null || _d === void 0 ? void 0 : _d._default) === null || _e === void 0 ? void 0 : _e._quickReplies) === null || _f === void 0 ? void 0 : _f.text) ||
|
|
8
|
+
((_l = (_k = (_j = (_h = (_g = config === null || config === void 0 ? void 0 : config.say) === null || _g === void 0 ? void 0 : _g._data) === null || _h === void 0 ? void 0 : _h._cognigy) === null || _j === void 0 ? void 0 : _j._default) === null || _k === void 0 ? void 0 : _k._quickReplies) === null || _l === void 0 ? void 0 : _l.fallbackText) ||
|
|
9
|
+
((_m = config === null || config === void 0 ? void 0 : config.say) === null || _m === void 0 ? void 0 : _m.text);
|
|
10
|
+
}
|
|
11
|
+
else if (((_o = config === null || config === void 0 ? void 0 : config.say) === null || _o === void 0 ? void 0 : _o.type) === "list") {
|
|
12
|
+
return ((_t = (_s = (_r = (_q = (_p = config === null || config === void 0 ? void 0 : config.say) === null || _p === void 0 ? void 0 : _p._data) === null || _q === void 0 ? void 0 : _q._cognigy) === null || _r === void 0 ? void 0 : _r._default) === null || _s === void 0 ? void 0 : _s._list) === null || _t === void 0 ? void 0 : _t.fallbackText) || ((_u = config === null || config === void 0 ? void 0 : config.say) === null || _u === void 0 ? void 0 : _u.text);
|
|
13
|
+
}
|
|
14
|
+
else if (((_v = config === null || config === void 0 ? void 0 : config.say) === null || _v === void 0 ? void 0 : _v.type) === "gallery") {
|
|
15
|
+
return ((_0 = (_z = (_y = (_x = (_w = config === null || config === void 0 ? void 0 : config.say) === null || _w === void 0 ? void 0 : _w._data) === null || _x === void 0 ? void 0 : _x._cognigy) === null || _y === void 0 ? void 0 : _y._default) === null || _z === void 0 ? void 0 : _z._gallery) === null || _0 === void 0 ? void 0 : _0.fallbackText) || ((_1 = config === null || config === void 0 ? void 0 : config.say) === null || _1 === void 0 ? void 0 : _1.text);
|
|
16
|
+
}
|
|
17
|
+
else if (((_2 = config === null || config === void 0 ? void 0 : config.say) === null || _2 === void 0 ? void 0 : _2.type) === "audio") {
|
|
18
|
+
return ((_7 = (_6 = (_5 = (_4 = (_3 = config === null || config === void 0 ? void 0 : config.say) === null || _3 === void 0 ? void 0 : _3._data) === null || _4 === void 0 ? void 0 : _4._cognigy) === null || _5 === void 0 ? void 0 : _5._default) === null || _6 === void 0 ? void 0 : _6._audio) === null || _7 === void 0 ? void 0 : _7.fallbackText) || ((_8 = config === null || config === void 0 ? void 0 : config.say) === null || _8 === void 0 ? void 0 : _8.text);
|
|
19
|
+
}
|
|
20
|
+
else if (((_9 = config === null || config === void 0 ? void 0 : config.say) === null || _9 === void 0 ? void 0 : _9.type) === "video") {
|
|
21
|
+
return ((_14 = (_13 = (_12 = (_11 = (_10 = config === null || config === void 0 ? void 0 : config.say) === null || _10 === void 0 ? void 0 : _10._data) === null || _11 === void 0 ? void 0 : _11._cognigy) === null || _12 === void 0 ? void 0 : _12._default) === null || _13 === void 0 ? void 0 : _13._video) === null || _14 === void 0 ? void 0 : _14.fallbackText) || ((_15 = config === null || config === void 0 ? void 0 : config.say) === null || _15 === void 0 ? void 0 : _15.text);
|
|
22
|
+
}
|
|
23
|
+
else if (((_16 = config === null || config === void 0 ? void 0 : config.say) === null || _16 === void 0 ? void 0 : _16.type) === "buttons") {
|
|
24
|
+
return ((_21 = (_20 = (_19 = (_18 = (_17 = config === null || config === void 0 ? void 0 : config.say) === null || _17 === void 0 ? void 0 : _17._data) === null || _18 === void 0 ? void 0 : _18._cognigy) === null || _19 === void 0 ? void 0 : _19._default) === null || _20 === void 0 ? void 0 : _20._buttons) === null || _21 === void 0 ? void 0 : _21.text) ||
|
|
25
|
+
((_26 = (_25 = (_24 = (_23 = (_22 = config === null || config === void 0 ? void 0 : config.say) === null || _22 === void 0 ? void 0 : _22._data) === null || _23 === void 0 ? void 0 : _23._cognigy) === null || _24 === void 0 ? void 0 : _24._default) === null || _25 === void 0 ? void 0 : _25._buttons) === null || _26 === void 0 ? void 0 : _26.fallbackText) ||
|
|
26
|
+
((_27 = config === null || config === void 0 ? void 0 : config.say) === null || _27 === void 0 ? void 0 : _27.text);
|
|
27
|
+
}
|
|
28
|
+
else if (((_28 = config === null || config === void 0 ? void 0 : config.say) === null || _28 === void 0 ? void 0 : _28.type) === "image") {
|
|
29
|
+
return ((_33 = (_32 = (_31 = (_30 = (_29 = config === null || config === void 0 ? void 0 : config.say) === null || _29 === void 0 ? void 0 : _29._data) === null || _30 === void 0 ? void 0 : _30._cognigy) === null || _31 === void 0 ? void 0 : _31._default) === null || _32 === void 0 ? void 0 : _32._image) === null || _33 === void 0 ? void 0 : _33.fallbackText) || ((_34 = config === null || config === void 0 ? void 0 : config.say) === null || _34 === void 0 ? void 0 : _34.text);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return (_35 = config === null || config === void 0 ? void 0 : config.say) === null || _35 === void 0 ? void 0 : _35.text;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.getQuestionText = getQuestionText;
|
|
36
|
+
//# sourceMappingURL=getQuestionText.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetNodeState = void 0;
|
|
4
|
+
function resetNodeState(api, nodeId) {
|
|
5
|
+
api.setLastExecutionMarker(nodeId, -1);
|
|
6
|
+
api.resetExecutionAmount(nodeId);
|
|
7
|
+
api.deleteSystemContext('activeQuestion');
|
|
8
|
+
api.deleteSystemContext('reconfirmationQuestionInProgress');
|
|
9
|
+
api.deleteSystemContext('reconfirmationQuestionInput');
|
|
10
|
+
}
|
|
11
|
+
exports.resetNodeState = resetNodeState;
|
|
12
|
+
//# sourceMappingURL=resetNodeState.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storeQuestionAnswer = void 0;
|
|
4
|
+
const BaseContext_1 = require("../../../../../helper/BaseContext");
|
|
5
|
+
/**
|
|
6
|
+
* Stores the question answer into the Context and/or Input
|
|
7
|
+
*/
|
|
8
|
+
const storeQuestionAnswer = ({ storeResultInContext, contextKey, context, result, input }) => {
|
|
9
|
+
if (storeResultInContext && contextKey) {
|
|
10
|
+
// check whether contextKey or inputKey is a deep query and set
|
|
11
|
+
// storage location accordingly
|
|
12
|
+
let location = context;
|
|
13
|
+
let target = contextKey;
|
|
14
|
+
// this is a deep query
|
|
15
|
+
if (target.indexOf(".") > -1) {
|
|
16
|
+
const splits = target.split(".");
|
|
17
|
+
location = BaseContext_1.BaseContext.findLocationPathStateless(splits, true, location);
|
|
18
|
+
target = splits[splits.length - 1];
|
|
19
|
+
}
|
|
20
|
+
location[target] = result;
|
|
21
|
+
// always store result also in input to allow for
|
|
22
|
+
// easy handling in conditions etc.
|
|
23
|
+
input.result = result;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
input.result = result;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.storeQuestionAnswer = storeQuestionAnswer;
|
|
30
|
+
//# sourceMappingURL=storeQuestionAnswer.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateQuestionAnswer = void 0;
|
|
4
|
+
const validateQuestionAnswer = (cognigy, config) => {
|
|
5
|
+
const { additionalValidation, escalateIntentsAction, escalateIntentsThreshold, escalateIntentsValidIntents, } = config;
|
|
6
|
+
const { input, api } = cognigy;
|
|
7
|
+
let isValid = true;
|
|
8
|
+
// check if there is an extra condition defined and check whether it was truthy
|
|
9
|
+
if (additionalValidation) {
|
|
10
|
+
isValid = !!api.parseCognigyScriptCondition(additionalValidation);
|
|
11
|
+
}
|
|
12
|
+
if (escalateIntentsAction && escalateIntentsAction !== "none") {
|
|
13
|
+
// Intent matched, intent score lte escalate threshold and intent is a
|
|
14
|
+
// valid intent of the escalate intent allow list
|
|
15
|
+
if (input.intent && input.intentScore >= escalateIntentsThreshold && escalateIntentsValidIntents.indexOf(input.intent) > -1) {
|
|
16
|
+
isValid = false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return isValid;
|
|
20
|
+
};
|
|
21
|
+
exports.validateQuestionAnswer = validateQuestionAnswer;
|
|
22
|
+
//# sourceMappingURL=validateQuestionAnswer.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.microsoftGetTokenNode = void 0;
|
|
4
|
+
/* Custom modules */
|
|
5
|
+
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
|
|
6
|
+
const design_1 = require("./utils/design");
|
|
7
|
+
/**
|
|
8
|
+
* Node name: 'microsoftGetToken'
|
|
9
|
+
*
|
|
10
|
+
* Purpose:
|
|
11
|
+
* Manually request permissions or token exchange
|
|
12
|
+
*/
|
|
13
|
+
exports.microsoftGetTokenNode = createNodeDescriptor_1.createNodeDescriptor({
|
|
14
|
+
type: "microsoftGetToken",
|
|
15
|
+
defaultLabel: "Get Token",
|
|
16
|
+
summary: "Get or renew a token for SSO",
|
|
17
|
+
appearance: {
|
|
18
|
+
showIcon: true,
|
|
19
|
+
color: design_1.nodeColor
|
|
20
|
+
},
|
|
21
|
+
tags: ["microsoft"],
|
|
22
|
+
function: async ({ cognigy }) => {
|
|
23
|
+
const { api } = cognigy;
|
|
24
|
+
api.addToContext("microsoftSsoPermissionRequest", "pending", "simple");
|
|
25
|
+
api.say("", {
|
|
26
|
+
_cognigy: {
|
|
27
|
+
_microsoftBotFramework: {
|
|
28
|
+
json: { requestMicrosoftSsoPermissions: true },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=getToken.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cognigyMicrosoftModule = void 0;
|
|
4
|
+
/** Cognigy Modules */
|
|
5
|
+
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
|
|
6
|
+
/** Nodes */
|
|
7
|
+
const tokenStatus_1 = require("./tokenStatus");
|
|
8
|
+
const getToken_1 = require("./getToken");
|
|
9
|
+
const invalidateToken_1 = require("./invalidateToken");
|
|
10
|
+
const tokenGranted_1 = require("./tokenStatus/tokenGranted");
|
|
11
|
+
const tokenNotGranted_1 = require("./tokenStatus/tokenNotGranted");
|
|
12
|
+
exports.cognigyMicrosoftModule = createNodeDescriptor_1.createExtension({
|
|
13
|
+
nodes: [
|
|
14
|
+
tokenStatus_1.microsoftTokenStatusNode,
|
|
15
|
+
invalidateToken_1.microsoftInvalidateTokenNode,
|
|
16
|
+
getToken_1.microsoftGetTokenNode,
|
|
17
|
+
tokenGranted_1.microsoftTokenGranted,
|
|
18
|
+
tokenNotGranted_1.microsoftTokenNotGranted
|
|
19
|
+
],
|
|
20
|
+
connections: []
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.microsoftInvalidateTokenNode = void 0;
|
|
4
|
+
/* Custom modules */
|
|
5
|
+
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
|
|
6
|
+
const design_1 = require("./utils/design");
|
|
7
|
+
/**
|
|
8
|
+
* Node name: 'microsoftInvalidateToken'
|
|
9
|
+
*
|
|
10
|
+
* Purpose:
|
|
11
|
+
* The SSO token gets removed
|
|
12
|
+
*/
|
|
13
|
+
exports.microsoftInvalidateTokenNode = createNodeDescriptor_1.createNodeDescriptor({
|
|
14
|
+
type: "microsoftInvalidateToken",
|
|
15
|
+
defaultLabel: "Invalidate Token",
|
|
16
|
+
summary: "Remove the SSO Token",
|
|
17
|
+
appearance: {
|
|
18
|
+
showIcon: true,
|
|
19
|
+
color: design_1.nodeColor
|
|
20
|
+
},
|
|
21
|
+
fields: [],
|
|
22
|
+
tags: ["microsoft"],
|
|
23
|
+
function: async ({ cognigy }) => {
|
|
24
|
+
const { api } = cognigy;
|
|
25
|
+
api.addToContext("microsoftSsoPermissionRequest", "declined", "simple");
|
|
26
|
+
api.say("", { _cognigy: { _microsoftBotFramework: { json: { revokeMicrosoftSsoPermissions: true } } } });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=invalidateToken.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.microsoftTokenStatusNode = void 0;
|
|
4
|
+
/* Custom modules */
|
|
5
|
+
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
|
|
6
|
+
const design_1 = require("../utils/design");
|
|
7
|
+
/**
|
|
8
|
+
* Node name: 'teamsPermissions'
|
|
9
|
+
*
|
|
10
|
+
* Purpose:
|
|
11
|
+
* divide the flow into granted and not granted requests
|
|
12
|
+
*/
|
|
13
|
+
exports.microsoftTokenStatusNode = createNodeDescriptor_1.createNodeDescriptor({
|
|
14
|
+
type: "microsoftTokenStatus",
|
|
15
|
+
defaultLabel: "Token Status",
|
|
16
|
+
summary: "Verify the token status for SSO",
|
|
17
|
+
appearance: {
|
|
18
|
+
showIcon: true,
|
|
19
|
+
color: design_1.nodeColor,
|
|
20
|
+
},
|
|
21
|
+
fields: [],
|
|
22
|
+
sections: [],
|
|
23
|
+
tags: ["microsoft"],
|
|
24
|
+
dependencies: {
|
|
25
|
+
children: ["microsoftTokenGranted", "microsoftTokenNotGranted"]
|
|
26
|
+
},
|
|
27
|
+
function: async ({ cognigy, childConfigs }) => {
|
|
28
|
+
const { api, input } = cognigy;
|
|
29
|
+
const tokenGrantedChild = childConfigs === null || childConfigs === void 0 ? void 0 : childConfigs.find((child) => child.type === "microsoftTokenGranted");
|
|
30
|
+
const tokenNotGrantedChild = childConfigs === null || childConfigs === void 0 ? void 0 : childConfigs.find((child) => child.type === "microsoftTokenNotGranted");
|
|
31
|
+
/** Permissions not requested */
|
|
32
|
+
if (!input.data.microsoftSsoPermissionRequest) {
|
|
33
|
+
api.setNextNode(tokenNotGrantedChild.id);
|
|
34
|
+
/** Permissions granted and token valid */
|
|
35
|
+
}
|
|
36
|
+
else if (input.data.microsoftSsoPermissionRequest === "completed" &&
|
|
37
|
+
input.data.microsoftSsoToken !== null) {
|
|
38
|
+
api.setNextNode(tokenGrantedChild.id);
|
|
39
|
+
/** Token expired or Logged out */
|
|
40
|
+
}
|
|
41
|
+
else if (input.data.microsoftSsoPermissionRequest === "completed" &&
|
|
42
|
+
input.data.microsoftSsoToken === null) {
|
|
43
|
+
api.setNextNode(tokenNotGrantedChild.id);
|
|
44
|
+
/** Permissions not yet accepted or declined */
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
api.setNextNode(tokenNotGrantedChild.id);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.microsoftTokenGranted = void 0;
|
|
4
|
+
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
|
|
5
|
+
const design_1 = require("../utils/design");
|
|
6
|
+
exports.microsoftTokenGranted = createNodeDescriptor_1.createNodeDescriptor({
|
|
7
|
+
type: "microsoftTokenGranted",
|
|
8
|
+
parentType: "microsoftTokenStatus",
|
|
9
|
+
defaultLabel: "Granted",
|
|
10
|
+
appearance: {
|
|
11
|
+
color: design_1.nodeColor,
|
|
12
|
+
textColor: "white",
|
|
13
|
+
contrastTextColor: "black",
|
|
14
|
+
variant: "mini",
|
|
15
|
+
},
|
|
16
|
+
constraints: {
|
|
17
|
+
deletable: false,
|
|
18
|
+
creatable: false,
|
|
19
|
+
collapsable: true,
|
|
20
|
+
childFlowCreatable: true,
|
|
21
|
+
placement: {}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=tokenGranted.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.microsoftTokenNotGranted = void 0;
|
|
4
|
+
const createNodeDescriptor_1 = require("../../../createNodeDescriptor");
|
|
5
|
+
const design_1 = require("../utils/design");
|
|
6
|
+
exports.microsoftTokenNotGranted = createNodeDescriptor_1.createNodeDescriptor({
|
|
7
|
+
type: "microsoftTokenNotGranted",
|
|
8
|
+
parentType: "microsoftTokenStatus",
|
|
9
|
+
defaultLabel: "Not Granted",
|
|
10
|
+
appearance: {
|
|
11
|
+
color: design_1.nodeColor,
|
|
12
|
+
textColor: "white",
|
|
13
|
+
contrastTextColor: "black",
|
|
14
|
+
variant: "mini",
|
|
15
|
+
},
|
|
16
|
+
constraints: {
|
|
17
|
+
deletable: false,
|
|
18
|
+
creatable: false,
|
|
19
|
+
collapsable: true,
|
|
20
|
+
childFlowCreatable: true,
|
|
21
|
+
placement: {}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=tokenNotGranted.js.map
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EXECUTE_COGNIGY_NLU = void 0;
|
|
4
4
|
/* Custom modules */
|
|
5
5
|
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
|
|
6
|
+
const errors_1 = require("../../../errors");
|
|
6
7
|
const logger_1 = require("../../../helper/logger");
|
|
7
8
|
/**
|
|
8
9
|
* Node name: 'executeCognigyNLU'
|
|
@@ -127,6 +128,10 @@ exports.EXECUTE_COGNIGY_NLU = createNodeDescriptor_1.createNodeDescriptor({
|
|
|
127
128
|
logger_1.default.log("error", { traceId: input.traceId, disableSensitiveLogging: false }, "No context key provided in addLexiconKeyphrse with context mode");
|
|
128
129
|
return;
|
|
129
130
|
}
|
|
131
|
+
if ((input === null || input === void 0 ? void 0 : input.channel) === "nonConversational") {
|
|
132
|
+
logger_1.default.log("error", { traceId: input.traceId, disableSensitiveLogging: false }, "Execute Cognigy NLU is not allowed with nonConversational endpoint");
|
|
133
|
+
throw new errors_1.InvalidArgumentError("Execute Cognigy NLU is not allowed with nonConversational endpoint", { traceId: input.traceId, disableSensitiveLogging: false });
|
|
134
|
+
}
|
|
130
135
|
const result = await api.executeCognigyNLU(text, data, input.inputId, { parseIntents, parseSlots, parseSystemSlots, findType });
|
|
131
136
|
if (result.tokens) {
|
|
132
137
|
delete result.tokens;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EXTRACT_ANSWER = void 0;
|
|
4
|
+
/* Custom modules */
|
|
5
|
+
const createNodeDescriptor_1 = require("../../createNodeDescriptor");
|
|
6
|
+
/**
|
|
7
|
+
* Node name: 'extractAnswer'
|
|
8
|
+
*
|
|
9
|
+
* Purpose:
|
|
10
|
+
* Answers a question based on a given context with the built-in question answering module
|
|
11
|
+
*/
|
|
12
|
+
exports.EXTRACT_ANSWER = createNodeDescriptor_1.createNodeDescriptor({
|
|
13
|
+
type: "extractAnswer",
|
|
14
|
+
defaultLabel: "Extract Answer",
|
|
15
|
+
summary: "Answers a question based on a given context with the built-in question answering module",
|
|
16
|
+
appearance: {
|
|
17
|
+
showIcon: false
|
|
18
|
+
},
|
|
19
|
+
fields: [
|
|
20
|
+
{
|
|
21
|
+
key: "text",
|
|
22
|
+
type: "cognigyText",
|
|
23
|
+
label: "Text",
|
|
24
|
+
defaultValue: ""
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: "question",
|
|
28
|
+
type: "cognigyText",
|
|
29
|
+
label: "Question",
|
|
30
|
+
params: {
|
|
31
|
+
required: true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: "storeLocation",
|
|
36
|
+
type: "select",
|
|
37
|
+
label: "Where to store the result",
|
|
38
|
+
params: {
|
|
39
|
+
options: [
|
|
40
|
+
{
|
|
41
|
+
label: "Input",
|
|
42
|
+
value: "input"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: "Context",
|
|
46
|
+
value: "context"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
required: true
|
|
50
|
+
},
|
|
51
|
+
defaultValue: "input"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
key: "inputKey",
|
|
55
|
+
type: "cognigyText",
|
|
56
|
+
label: "Input Key to store Result",
|
|
57
|
+
description: "Where to store the result in the Input object. E.g. input.extractAnswer",
|
|
58
|
+
defaultValue: "extractAnswer",
|
|
59
|
+
condition: {
|
|
60
|
+
key: "storeLocation",
|
|
61
|
+
value: "input"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
key: "contextKey",
|
|
66
|
+
type: "cognigyText",
|
|
67
|
+
label: "Context Key to store Result",
|
|
68
|
+
description: "Where to store the result in the Context object. E.g. context.extractAnswer",
|
|
69
|
+
defaultValue: "extractAnswer",
|
|
70
|
+
condition: {
|
|
71
|
+
key: "storeLocation",
|
|
72
|
+
value: "context"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
sections: [
|
|
77
|
+
{
|
|
78
|
+
key: "storage",
|
|
79
|
+
label: "Storage Options",
|
|
80
|
+
defaultCollapsed: true,
|
|
81
|
+
fields: [
|
|
82
|
+
"storeLocation",
|
|
83
|
+
"inputKey",
|
|
84
|
+
"contextKey",
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
form: [
|
|
89
|
+
{ type: "field", key: "text" },
|
|
90
|
+
{ type: "field", key: "question" },
|
|
91
|
+
{ type: "field", key: "maxTextLength" },
|
|
92
|
+
{ type: "section", key: "storage" },
|
|
93
|
+
],
|
|
94
|
+
preview: {
|
|
95
|
+
key: "text",
|
|
96
|
+
type: "text",
|
|
97
|
+
},
|
|
98
|
+
tags: ["nlu"],
|
|
99
|
+
function: async (extractAnswerParams) => {
|
|
100
|
+
const { cognigy, config } = extractAnswerParams;
|
|
101
|
+
const { api } = cognigy;
|
|
102
|
+
const { question, storeLocation, contextKey, inputKey } = config;
|
|
103
|
+
if (!question) {
|
|
104
|
+
throw new Error("Unable to answer question. Question is missing.");
|
|
105
|
+
}
|
|
106
|
+
if (storeLocation === "context" && !contextKey) {
|
|
107
|
+
throw new Error("Unable to answer question. Context Key is missing.");
|
|
108
|
+
}
|
|
109
|
+
if (storeLocation === "input" && !inputKey) {
|
|
110
|
+
throw new Error("Unable to answer question. Input Key is missing.");
|
|
111
|
+
}
|
|
112
|
+
return await api.extractAnswer(extractAnswerParams);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=extractAnswer.js.map
|