@botonic/plugin-flow-builder 0.25.0-alpha.1 → 0.25.0-alpha.3
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/lib/cjs/action/index.js +59 -60
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/intent.js +19 -20
- package/lib/cjs/action/intent.js.map +1 -1
- package/lib/cjs/action/keyword.js +14 -15
- package/lib/cjs/action/keyword.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.js +47 -48
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/action/tracking.js +12 -13
- package/lib/cjs/action/tracking.js.map +1 -1
- package/lib/cjs/action/user-input.js +15 -16
- package/lib/cjs/action/user-input.js.map +1 -1
- package/lib/cjs/api.js +30 -34
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/constants.js +3 -6
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/content-fields/content-fields-base.js +7 -9
- package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-button.js +18 -19
- package/lib/cjs/content-fields/flow-button.js.map +1 -1
- package/lib/cjs/content-fields/flow-carousel.js +12 -13
- package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
- package/lib/cjs/content-fields/flow-element.js +15 -16
- package/lib/cjs/content-fields/flow-element.js.map +1 -1
- package/lib/cjs/content-fields/flow-handoff.js +33 -37
- package/lib/cjs/content-fields/flow-handoff.js.map +1 -1
- package/lib/cjs/content-fields/flow-image.js +10 -11
- package/lib/cjs/content-fields/flow-image.js.map +1 -1
- package/lib/cjs/content-fields/flow-text.js +20 -20
- package/lib/cjs/content-fields/flow-text.js.map +1 -1
- package/lib/cjs/content-fields/flow-video.js +10 -11
- package/lib/cjs/content-fields/flow-video.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/bot-action.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/button.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/carousel.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/common.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/fallback.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/function.js +2 -5
- package/lib/cjs/content-fields/hubtype-fields/function.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/go-to-flow.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/handoff.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/image.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/index.js +18 -21
- package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/intent.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/keyword.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +6 -9
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/payload.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/text.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/url.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/video.js +1 -2
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js +1 -2
- package/lib/cjs/content-fields/index.js +10 -21
- package/lib/cjs/content-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +11 -12
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +9 -10
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +14 -15
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/cjs/functions/conditional-provider.js +1 -5
- package/lib/cjs/functions/conditional-provider.js.map +1 -1
- package/lib/cjs/functions/conditional-queue-status.js +20 -21
- package/lib/cjs/functions/conditional-queue-status.js.map +1 -1
- package/lib/cjs/functions/index.js +5 -8
- package/lib/cjs/functions/index.js.map +1 -1
- package/lib/cjs/helpers.js +1 -5
- package/lib/cjs/helpers.js.map +1 -1
- package/lib/cjs/index.js +96 -96
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.js +2 -5
- package/lib/cjs/types.js.map +1 -1
- package/lib/cjs/utils.js +4 -8
- package/lib/cjs/utils.js.map +1 -1
- package/lib/esm/action/index.js +59 -60
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/intent.js +19 -20
- package/lib/esm/action/intent.js.map +1 -1
- package/lib/esm/action/keyword.js +14 -15
- package/lib/esm/action/keyword.js.map +1 -1
- package/lib/esm/action/knowledge-bases.js +47 -48
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/action/tracking.js +12 -13
- package/lib/esm/action/tracking.js.map +1 -1
- package/lib/esm/action/user-input.js +15 -16
- package/lib/esm/action/user-input.js.map +1 -1
- package/lib/esm/api.js +30 -34
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/constants.js +3 -6
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/content-fields/content-fields-base.js +7 -9
- package/lib/esm/content-fields/content-fields-base.js.map +1 -1
- package/lib/esm/content-fields/flow-button.js +18 -19
- package/lib/esm/content-fields/flow-button.js.map +1 -1
- package/lib/esm/content-fields/flow-carousel.js +12 -13
- package/lib/esm/content-fields/flow-carousel.js.map +1 -1
- package/lib/esm/content-fields/flow-element.js +15 -16
- package/lib/esm/content-fields/flow-element.js.map +1 -1
- package/lib/esm/content-fields/flow-handoff.js +33 -37
- package/lib/esm/content-fields/flow-handoff.js.map +1 -1
- package/lib/esm/content-fields/flow-image.js +10 -11
- package/lib/esm/content-fields/flow-image.js.map +1 -1
- package/lib/esm/content-fields/flow-text.js +20 -20
- package/lib/esm/content-fields/flow-text.js.map +1 -1
- package/lib/esm/content-fields/flow-video.js +10 -11
- package/lib/esm/content-fields/flow-video.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/bot-action.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/button.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/carousel.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/common.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/fallback.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/function.js +2 -5
- package/lib/esm/content-fields/hubtype-fields/function.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/go-to-flow.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/handoff.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/image.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/index.js +18 -21
- package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/intent.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/keyword.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/node-types.js +6 -9
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/payload.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/text.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/url.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/video.js +1 -2
- package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js +1 -2
- package/lib/esm/content-fields/index.js +10 -21
- package/lib/esm/content-fields/index.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +11 -12
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +9 -10
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +14 -15
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/esm/functions/conditional-provider.js +1 -5
- package/lib/esm/functions/conditional-provider.js.map +1 -1
- package/lib/esm/functions/conditional-queue-status.js +20 -21
- package/lib/esm/functions/conditional-queue-status.js.map +1 -1
- package/lib/esm/functions/index.js +5 -8
- package/lib/esm/functions/index.js.map +1 -1
- package/lib/esm/helpers.js +1 -5
- package/lib/esm/helpers.js.map +1 -1
- package/lib/esm/index.js +96 -96
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.js +2 -5
- package/lib/esm/types.js.map +1 -1
- package/lib/esm/utils.js +4 -8
- package/lib/esm/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -3
package/lib/cjs/action/index.js
CHANGED
|
@@ -1,73 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
await handoffContent.doHandoff(request);
|
|
22
|
-
return { contents };
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Multichannel, RequestContext } from '@botonic/react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { FlowHandoff } from '../content-fields';
|
|
6
|
+
import { getFlowBuilderPlugin } from '../helpers';
|
|
7
|
+
import { createNodeFromKnowledgeBase } from './knowledge-bases';
|
|
8
|
+
import { EventName, trackEvent } from './tracking';
|
|
9
|
+
export class FlowBuilderAction extends React.Component {
|
|
10
|
+
static botonicInit(request) {
|
|
11
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
13
|
+
const locale = flowBuilderPlugin.getLocale(request.session);
|
|
14
|
+
const targetNode = yield getTargetNode(flowBuilderPlugin.cmsApi, request);
|
|
15
|
+
const contents = yield flowBuilderPlugin.getContentsByNode(targetNode, locale);
|
|
16
|
+
const handoffContent = contents.find(content => content instanceof FlowHandoff);
|
|
17
|
+
if (handoffContent)
|
|
18
|
+
yield handoffContent.doHandoff(request);
|
|
19
|
+
return { contents };
|
|
20
|
+
});
|
|
23
21
|
}
|
|
24
22
|
render() {
|
|
25
23
|
const { contents } = this.props;
|
|
26
24
|
return contents.map(content => content.toBotonic(content.id));
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
|
27
|
+
FlowBuilderAction.contextType = RequestContext;
|
|
28
|
+
export class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
|
31
29
|
render() {
|
|
32
30
|
const { contents } = this.props;
|
|
33
|
-
return ((
|
|
31
|
+
return (_jsx(Multichannel, Object.assign({ text: { buttonsAsText: false } }, { children: contents.map(content => content.toBotonic(content.id)) })));
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
34
|
+
function getTargetNode(cmsApi, request) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
if (request.session.is_first_interaction) {
|
|
37
|
+
const startNode = cmsApi.getStartNode();
|
|
38
|
+
yield trackEvent(request, EventName.botStart);
|
|
39
|
+
return startNode;
|
|
40
|
+
}
|
|
41
|
+
const contentId = request.input.payload;
|
|
42
|
+
const targetNode = contentId
|
|
43
|
+
? cmsApi.getNodeById(contentId)
|
|
44
|
+
: undefined;
|
|
45
|
+
if (targetNode) {
|
|
46
|
+
const eventArgs = {
|
|
47
|
+
faq_name: targetNode.code,
|
|
48
|
+
};
|
|
49
|
+
yield trackEvent(request, EventName.botFaq, eventArgs);
|
|
50
|
+
return targetNode;
|
|
51
|
+
}
|
|
52
|
+
return yield getFallbackNode(cmsApi, request);
|
|
53
|
+
});
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
isFirstFallbackOption: true
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
55
|
+
function getFallbackNode(cmsApi, request) {
|
|
56
|
+
var _a;
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
if (((_a = request.session.user.extra_data) === null || _a === void 0 ? void 0 : _a.isFirstFallbackOption) === undefined) {
|
|
59
|
+
request.session.user.extra_data = Object.assign(Object.assign({}, request.session.user.extra_data), { isFirstFallbackOption: true });
|
|
60
|
+
}
|
|
61
|
+
const knowledgeBaseNode = yield createNodeFromKnowledgeBase(cmsApi, request);
|
|
62
|
+
if (knowledgeBaseNode) {
|
|
63
|
+
return knowledgeBaseNode;
|
|
64
|
+
}
|
|
65
|
+
const isFirstFallbackOption = !!request.session.user.extra_data.isFirstFallbackOption;
|
|
66
|
+
const fallbackNode = cmsApi.getFallbackNode(isFirstFallbackOption);
|
|
67
|
+
request.session.user.extra_data.isFirstFallbackOption = !isFirstFallbackOption;
|
|
68
|
+
yield trackEvent(request, EventName.fallback);
|
|
69
|
+
return fallbackNode;
|
|
70
|
+
});
|
|
72
71
|
}
|
|
73
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/action/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/action/index.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAiB,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAMlD,MAAM,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAiC;IAG5E,MAAM,CAAO,WAAW,CACtB,OAAsB;;YAEtB,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YAC/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YAE3D,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YAEzE,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,CACxD,UAAU,EACV,MAAM,CACP,CAAA;YAED,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAClC,OAAO,CAAC,EAAE,CAAC,OAAO,YAAY,WAAW,CAC3B,CAAA;YAChB,IAAI,cAAc;gBAAE,MAAM,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;YAE3D,OAAO,EAAE,QAAQ,EAAE,CAAA;QACrB,CAAC;KAAA;IAED,MAAM;QACJ,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAC/B,OAAO,QAAQ,CAAC,GA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sB;;;QAC3E,IAAI,CAAA,MAAA,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,0CAAE,qBAAqB,MAAK,SAAS,EAAE;YACxE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,mCAC1B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,KAClC,qBAAqB,EAAE,IAAI,GAC5B,CAAA;SACF;QAED,MAAM,iBAAiB,GAAG,MAAM,2BAA2B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC5E,IAAI,iBAAiB,EAAE;YACrB,OAAO,iBAAiB,CAAA;SACzB;QAED,MAAM,qBAAqB,GACzB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAA;QACzD,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAA;QAClE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,GAAG,CAAC,qBAAqB,CAAA;QAE9E,MAAM,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;QAC7C,OAAO,YAAY,CAAA;;CACpB"}
|
package/lib/cjs/action/intent.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { EventName, trackEvent } from './tracking';
|
|
3
|
+
export function getIntentNodeByInput(cmsApi, locale, request) {
|
|
4
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5
|
+
const intentNode = cmsApi.getIntentNode(request.input, locale);
|
|
6
|
+
const eventArgs = {
|
|
7
|
+
intent: request.input.intent,
|
|
8
|
+
confidence: request.input.confidence,
|
|
9
|
+
confidence_successful: true,
|
|
10
|
+
};
|
|
11
|
+
if (request.input.confidence && request.input.intent && intentNode) {
|
|
12
|
+
if (isIntentValid(intentNode, request, cmsApi)) {
|
|
13
|
+
yield trackEvent(request, EventName.botAiModel, eventArgs);
|
|
14
|
+
return intentNode;
|
|
15
|
+
}
|
|
16
|
+
eventArgs.confidence_successful = false;
|
|
17
|
+
yield trackEvent(request, EventName.botAiModel, eventArgs);
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return undefined;
|
|
19
|
+
return undefined;
|
|
20
|
+
});
|
|
21
21
|
}
|
|
22
|
-
exports.getIntentNodeByInput = getIntentNodeByInput;
|
|
23
22
|
function isIntentValid(intentNode, request, cmsApi) {
|
|
24
23
|
return (request.input.confidence &&
|
|
25
24
|
cmsApi.hasMetConfidenceThreshold(intentNode, request.input.confidence));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent.js","sourceRoot":"","sources":["../../../src/action/intent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"intent.js","sourceRoot":"","sources":["../../../src/action/intent.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,UAAgB,oBAAoB,CACxC,MAAsB,EACtB,MAAc,EACd,OAAsB;;QAEtB,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC9D,MAAM,SAAS,GAAG;YAChB,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAgB;YACtC,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAoB;YAC9C,qBAAqB,EAAE,IAAI;SAC5B,CAAA;QACD,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,IAAI,UAAU,EAAE;YAClE,IAAI,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE;gBAC9C,MAAM,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;gBAC1D,OAAO,UAAU,CAAA;aAClB;YAED,SAAS,CAAC,qBAAqB,GAAG,KAAK,CAAA;YACvC,MAAM,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;SAC3D;QAED,OAAO,SAAS,CAAA;IAClB,CAAC;CAAA;AAED,SAAS,aAAa,CACpB,UAAwB,EACxB,OAAsB,EACtB,MAAsB;IAEtB,OAAO,CACL,OAAO,CAAC,KAAK,CAAC,UAAU;QACxB,MAAM,CAAC,yBAAyB,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CACvE,CAAA;AACH,CAAC"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { EventName, trackEvent } from './tracking';
|
|
3
|
+
export function getKeywordNodeByInput(cmsApi, locale, request, userInput) {
|
|
4
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5
|
+
const keywordNode = cmsApi.getNodeByKeyword(userInput, locale);
|
|
6
|
+
if (!keywordNode) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const eventArgs = {
|
|
10
|
+
confidence_successful: true,
|
|
11
|
+
};
|
|
12
|
+
yield trackEvent(request, EventName.botKeywordsModel, eventArgs);
|
|
13
|
+
return keywordNode;
|
|
14
|
+
});
|
|
15
15
|
}
|
|
16
|
-
exports.getKeywordNodeByInput = getKeywordNodeByInput;
|
|
17
16
|
//# sourceMappingURL=keyword.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/action/keyword.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/action/keyword.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,UAAgB,qBAAqB,CACzC,MAAsB,EACtB,MAAc,EACd,OAAsB,EACtB,SAAiB;;QAEjB,MAAM,WAAW,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC9D,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,SAAS,CAAA;SACjB;QACD,MAAM,SAAS,GAAG;YAChB,qBAAqB,EAAE,IAAI;SAC5B,CAAA;QACD,MAAM,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAA;QAChE,OAAO,WAAW,CAAA;IACpB,CAAC;CAAA"}
|
|
@@ -1,52 +1,51 @@
|
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { randomUUID } from 'crypto';
|
|
3
|
+
import { HtNodeWithContentType, } from '../content-fields/hubtype-fields';
|
|
4
|
+
import { getFlowBuilderPlugin } from '../helpers';
|
|
5
|
+
import { EventName, trackEvent } from './tracking';
|
|
6
|
+
export function createNodeFromKnowledgeBase(cmsApi, request) {
|
|
7
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
9
|
+
const locale = flowBuilderPlugin.getLocale(request.session);
|
|
10
|
+
const knowledgeBaseConfig = cmsApi.getKnowledgeBaseConfig();
|
|
11
|
+
if (flowBuilderPlugin.getKnowledgeBaseResponse &&
|
|
12
|
+
(knowledgeBaseConfig === null || knowledgeBaseConfig === void 0 ? void 0 : knowledgeBaseConfig.isActive)) {
|
|
13
|
+
try {
|
|
14
|
+
const knowledgeBaseResponse = yield flowBuilderPlugin.getKnowledgeBaseResponse(request);
|
|
15
|
+
if (knowledgeBaseResponse.hasKnowledge) {
|
|
16
|
+
yield trackEvent(request, EventName.botAiKnowledgeBase, {
|
|
17
|
+
answer: knowledgeBaseResponse.answer,
|
|
18
|
+
knowledge_source_ids: knowledgeBaseResponse.sources.map(source => source.knowledgeSourceId),
|
|
19
|
+
});
|
|
20
|
+
const knowledgeBaseNode = {
|
|
21
|
+
type: HtNodeWithContentType.TEXT,
|
|
22
|
+
content: {
|
|
23
|
+
text: [
|
|
24
|
+
{
|
|
25
|
+
message: knowledgeBaseResponse.answer,
|
|
26
|
+
locale,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
buttons_style: undefined,
|
|
30
|
+
buttons: [],
|
|
31
|
+
},
|
|
32
|
+
id: randomUUID(),
|
|
33
|
+
code: 'knowledge-response',
|
|
34
|
+
meta: {
|
|
35
|
+
x: 0,
|
|
36
|
+
y: 0,
|
|
37
|
+
},
|
|
38
|
+
follow_up: knowledgeBaseConfig.followup,
|
|
39
|
+
};
|
|
40
|
+
return knowledgeBaseNode;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.log('Hubtype knowledge base api error: ', { e });
|
|
45
|
+
return undefined;
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return undefined;
|
|
48
|
+
return undefined;
|
|
49
|
+
});
|
|
50
50
|
}
|
|
51
|
-
exports.createNodeFromKnowledgeBase = createNodeFromKnowledgeBase;
|
|
52
51
|
//# sourceMappingURL=knowledge-bases.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"knowledge-bases.js","sourceRoot":"","sources":["../../../src/action/knowledge-bases.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAGnC,OAAO,EAEL,qBAAqB,GAEtB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,UAAgB,2BAA2B,CAC/C,MAAsB,EACtB,OAAsB;;QAEtB,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC3D,MAAM,mBAAmB,GAAG,MAAM,CAAC,sBAAsB,EAAE,CAAA;QAE3D,IACE,iBAAiB,CAAC,wBAAwB;aAC1C,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,QAAQ,CAAA,EAC7B;YACA,IAAI;gBACF,MAAM,qBAAqB,GACzB,MAAM,iBAAiB,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAA;gBAE3D,IAAI,qBAAqB,CAAC,YAAY,EAAE;oBACtC,MAAM,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,kBAAkB,EAAE;wBACtD,MAAM,EAAE,qBAAqB,CAAC,MAAM;wBACpC,oBAAoB,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,CACrD,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,iBAAiB,CACnC;qBACF,CAAC,CAAA;oBAEF,MAAM,iBAAiB,GAAe;wBACpC,IAAI,EAAE,qBAAqB,CAAC,IAAI;wBAChC,OAAO,EAAE;4BACP,IAAI,EAAE;gCACJ;oCACE,OAAO,EAAE,qBAAqB,CAAC,MAAM;oCACrC,MAAM;iCACP;6BACF;4BACD,aAAa,EAAE,SAAS;4BACxB,OAAO,EAAE,EAAE;yBACZ;wBACD,EAAE,EAAE,UAAU,EAAE;wBAChB,IAAI,EAAE,oBAAoB;wBAC1B,IAAI,EAAE;4BACJ,CAAC,EAAE,CAAC;4BACJ,CAAC,EAAE,CAAC;yBACL;wBACD,SAAS,EAAE,mBAAmB,CAAC,QAAQ;qBACxC,CAAA;oBACD,OAAO,iBAAiB,CAAA;iBACzB;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;gBACxD,OAAO,SAAS,CAAA;aACjB;SACF;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CAAA"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { getFlowBuilderPlugin } from '../helpers';
|
|
3
|
+
export function trackEvent(request, eventName, args) {
|
|
4
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
|
|
6
|
+
if (flowBuilderPlugin.trackEvent) {
|
|
7
|
+
yield flowBuilderPlugin.trackEvent(request, eventName, args);
|
|
8
|
+
}
|
|
9
|
+
return;
|
|
10
|
+
});
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
var EventName;
|
|
12
|
+
export var EventName;
|
|
14
13
|
(function (EventName) {
|
|
15
14
|
EventName["botAgentRating"] = "bot_agent_rating";
|
|
16
15
|
EventName["botChannelRating"] = "bot_channel_rating";
|
|
@@ -26,5 +25,5 @@ var EventName;
|
|
|
26
25
|
EventName["handoffOption"] = "handoff_option";
|
|
27
26
|
EventName["handoffSuccess"] = "handoff_success";
|
|
28
27
|
EventName["handoffFail"] = "handoff_fail";
|
|
29
|
-
})(EventName
|
|
28
|
+
})(EventName || (EventName = {}));
|
|
30
29
|
//# sourceMappingURL=tracking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../../src/action/tracking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../../src/action/tracking.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEjD,MAAM,UAAgB,UAAU,CAC9B,OAAsB,EACtB,SAAoB,EACpB,IAA0B;;QAE1B,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/D,IAAI,iBAAiB,CAAC,UAAU,EAAE;YAChC,MAAM,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;SAC7D;QACD,OAAM;IACR,CAAC;CAAA;AAED,MAAM,CAAN,IAAY,SAeX;AAfD,WAAY,SAAS;IACnB,gDAAmC,CAAA;IACnC,oDAAuC,CAAA;IACvC,4CAA+B,CAAA;IAC/B,qCAAwB,CAAA;IACxB,+BAAkB,CAAA;IAClB,mCAAsB,CAAA;IACtB,iCAAoB,CAAA;IACpB,wCAA2B,CAAA;IAC3B,yDAA4C,CAAA;IAC5C,oDAAuC,CAAA;IACvC,kCAAqB,CAAA;IACrB,6CAAgC,CAAA;IAChC,+CAAkC,CAAA;IAClC,yCAA4B,CAAA;AAC9B,CAAC,EAfW,SAAS,KAAT,SAAS,QAepB"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { getIntentNodeByInput } from './intent';
|
|
3
|
+
import { getKeywordNodeByInput } from './keyword';
|
|
4
|
+
export function getNodeByUserInput(cmsApi, locale, request) {
|
|
5
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6
|
+
if (request.input.data) {
|
|
7
|
+
const intentNode = yield getIntentNodeByInput(cmsApi, locale, request);
|
|
8
|
+
if (intentNode)
|
|
9
|
+
return intentNode;
|
|
10
|
+
const keywordNode = yield getKeywordNodeByInput(cmsApi, locale, request, request.input.data);
|
|
11
|
+
if (keywordNode)
|
|
12
|
+
return keywordNode;
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
});
|
|
16
16
|
}
|
|
17
|
-
exports.getNodeByUserInput = getNodeByUserInput;
|
|
18
17
|
//# sourceMappingURL=user-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-input.js","sourceRoot":"","sources":["../../../src/action/user-input.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-input.js","sourceRoot":"","sources":["../../../src/action/user-input.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAEjD,MAAM,UAAgB,kBAAkB,CACtC,MAAsB,EACtB,MAAc,EACd,OAAsB;;QAEtB,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE;YACtB,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;YACtE,IAAI,UAAU;gBAAE,OAAO,UAAU,CAAA;YAEjC,MAAM,WAAW,GAAG,MAAM,qBAAqB,CAC7C,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAO,CAAC,KAAK,CAAC,IAAI,CACnB,CAAA;YACD,IAAI,WAAW;gBAAE,OAAO,WAAW,CAAA;SACpC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CAAA"}
|
package/lib/cjs/api.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const constants_1 = require("./constants");
|
|
7
|
-
const hubtype_fields_1 = require("./content-fields/hubtype-fields");
|
|
8
|
-
class FlowBuilderApi {
|
|
9
|
-
url;
|
|
10
|
-
flow;
|
|
11
|
-
request;
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { SEPARATOR } from './constants';
|
|
4
|
+
import { HtNodeWithContentType, HtNodeWithoutContentType, } from './content-fields/hubtype-fields';
|
|
5
|
+
export class FlowBuilderApi {
|
|
12
6
|
constructor() { }
|
|
13
|
-
static
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
static create(options) {
|
|
8
|
+
var _a;
|
|
9
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const newApi = new FlowBuilderApi();
|
|
11
|
+
newApi.url = options.url;
|
|
12
|
+
newApi.flow = (_a = options.flow) !== null && _a !== void 0 ? _a : (yield newApi.getFlow(options.accessToken));
|
|
13
|
+
newApi.request = options.request;
|
|
14
|
+
return newApi;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
getFlow(token) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { data } = yield axios.get(this.url, {
|
|
20
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
21
|
+
});
|
|
22
|
+
return data;
|
|
23
23
|
});
|
|
24
|
-
return data;
|
|
25
24
|
}
|
|
26
25
|
getNodeByFlowId(id) {
|
|
27
26
|
const subFlow = this.flow.flows.find(subFlow => subFlow.id === id);
|
|
@@ -33,7 +32,7 @@ class FlowBuilderApi {
|
|
|
33
32
|
const node = this.flow.nodes.find(node => node.id === id);
|
|
34
33
|
if (!node)
|
|
35
34
|
throw Error(`Node with id: '${id}' not found`);
|
|
36
|
-
if (node.type ===
|
|
35
|
+
if (node.type === HtNodeWithoutContentType.GO_TO_FLOW) {
|
|
37
36
|
return this.getNodeByFlowId(node.content.flow_id);
|
|
38
37
|
}
|
|
39
38
|
return node;
|
|
@@ -51,7 +50,7 @@ class FlowBuilderApi {
|
|
|
51
50
|
return this.getNodeById(startNodeId);
|
|
52
51
|
}
|
|
53
52
|
getFallbackNode(alternate) {
|
|
54
|
-
const fallbackNode = this.flow.nodes.find(node => node.type ===
|
|
53
|
+
const fallbackNode = this.flow.nodes.find(node => node.type === HtNodeWithContentType.FALLBACK);
|
|
55
54
|
if (!fallbackNode) {
|
|
56
55
|
throw new Error('Fallback node must be defined');
|
|
57
56
|
}
|
|
@@ -68,7 +67,7 @@ class FlowBuilderApi {
|
|
|
68
67
|
: this.getNodeById(fallbackSecondMessage.id);
|
|
69
68
|
}
|
|
70
69
|
getKnowledgeBaseConfig() {
|
|
71
|
-
const fallbackNode = this.flow.nodes.find(node => node.type ===
|
|
70
|
+
const fallbackNode = this.flow.nodes.find(node => node.type === HtNodeWithContentType.FALLBACK);
|
|
72
71
|
return fallbackNode
|
|
73
72
|
? {
|
|
74
73
|
followup: fallbackNode.content.knowledge_base_followup,
|
|
@@ -78,7 +77,7 @@ class FlowBuilderApi {
|
|
|
78
77
|
}
|
|
79
78
|
getIntentNode(input, locale) {
|
|
80
79
|
try {
|
|
81
|
-
const intentsNodes = this.flow.nodes.filter(node => node.type ===
|
|
80
|
+
const intentsNodes = this.flow.nodes.filter(node => node.type === HtNodeWithContentType.INTENT);
|
|
82
81
|
const inputIntent = input.intent;
|
|
83
82
|
if (inputIntent) {
|
|
84
83
|
return intentsNodes.find(node => inputIntent && this.nodeContainsIntent(node, inputIntent, locale));
|
|
@@ -98,7 +97,7 @@ class FlowBuilderApi {
|
|
|
98
97
|
}
|
|
99
98
|
getNodeByKeyword(userInput, locale) {
|
|
100
99
|
try {
|
|
101
|
-
const keywordNodes = this.flow.nodes.filter(node => node.type ===
|
|
100
|
+
const keywordNodes = this.flow.nodes.filter(node => node.type === HtNodeWithContentType.KEYWORD);
|
|
102
101
|
const matchedKeywordNodes = keywordNodes.filter(node => this.matchKeywords(node, userInput, locale));
|
|
103
102
|
if (matchedKeywordNodes.length > 0 && matchedKeywordNodes[0].target) {
|
|
104
103
|
return matchedKeywordNodes[0];
|
|
@@ -120,22 +119,19 @@ class FlowBuilderApi {
|
|
|
120
119
|
if (!target) {
|
|
121
120
|
return undefined;
|
|
122
121
|
}
|
|
123
|
-
if (target.type ===
|
|
122
|
+
if (target.type === HtNodeWithoutContentType.BOT_ACTION) {
|
|
124
123
|
const botActionNode = this.getNodeById(target.id);
|
|
125
124
|
return this.createPayloadWithParams(botActionNode);
|
|
126
125
|
}
|
|
127
126
|
return target.id;
|
|
128
127
|
}
|
|
129
128
|
createPayloadWithParams(botActionNode) {
|
|
129
|
+
var _a;
|
|
130
130
|
const payloadId = botActionNode.content.payload_id;
|
|
131
131
|
const payloadNode = this.getNodeById(payloadId);
|
|
132
132
|
const customParams = JSON.parse(botActionNode.content.payload_params || '{}');
|
|
133
|
-
const payloadJson = JSON.stringify({
|
|
134
|
-
|
|
135
|
-
followUpId: botActionNode.follow_up?.id,
|
|
136
|
-
});
|
|
137
|
-
return `${payloadNode.content.payload}${constants_1.SEPARATOR}${payloadJson}`;
|
|
133
|
+
const payloadJson = JSON.stringify(Object.assign(Object.assign({}, customParams), { followUpId: (_a = botActionNode.follow_up) === null || _a === void 0 ? void 0 : _a.id }));
|
|
134
|
+
return `${payloadNode.content.payload}${SEPARATOR}${payloadJson}`;
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
|
-
exports.FlowBuilderApi = FlowBuilderApi;
|
|
141
137
|
//# sourceMappingURL=api.js.map
|
package/lib/cjs/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EASL,qBAAqB,EACrB,wBAAwB,GAEzB,MAAM,iCAAiC,CAAA;AAGxC,MAAM,OAAO,cAAc;IAKzB,gBAAuB,CAAC;IAExB,MAAM,CAAO,MAAM,CAAC,OAA8B;;;YAChD,MAAM,MAAM,GAAG,IAAI,cAAc,EAAE,CAAA;YAEnC,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;YACxB,MAAM,CAAC,IAAI,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAA;YACzE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;YAEhC,OAAO,MAAM,CAAA;;KACd;IAEa,OAAO,CAAC,KAAa;;YACjC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,GA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AC,uBAAuB,CAAC,aAAa,CAAC,CAAA;SACnD;QAED,OAAO,MAAM,CAAC,EAAE,CAAA;IAClB,CAAC;IAEO,uBAAuB,CAAC,aAA8B;;QAC5D,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,UAAU,CAAA;QAClD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAgB,SAAS,CAAC,CAAA;QAC9D,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAC7B,aAAa,CAAC,OAAO,CAAC,cAAc,IAAI,IAAI,CAC7C,CAAA;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,iCAC7B,YAAY,KACf,UAAU,EAAE,MAAA,aAAa,CAAC,SAAS,0CAAE,EAAE,IACvC,CAAA;QACF,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,GAAG,SAAS,GAAG,WAAW,EAAE,CAAA;IACnE,CAAC;CACF"}
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.SEPARATOR = '|';
|
|
5
|
-
exports.SOURCE_INFO_SEPARATOR = `${exports.SEPARATOR}source_`;
|
|
6
|
-
exports.VARIABLE_REGEX = /{([^}]+)}/g;
|
|
1
|
+
export const SEPARATOR = '|';
|
|
2
|
+
export const SOURCE_INFO_SEPARATOR = `${SEPARATOR}source_`;
|
|
3
|
+
export const VARIABLE_REGEX = /{([^}]+)}/g;
|
|
7
4
|
//# sourceMappingURL=constants.js.map
|