@botonic/plugin-flow-builder 0.43.2 → 0.44.0-alpha.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/lib/cjs/action/ai-agent.js +55 -61
- package/lib/cjs/action/ai-agent.js.map +1 -1
- package/lib/cjs/action/fallback.js +28 -32
- package/lib/cjs/action/fallback.js.map +1 -1
- package/lib/cjs/action/first-interaction.js +61 -71
- package/lib/cjs/action/first-interaction.js.map +1 -1
- package/lib/cjs/action/index.js +66 -79
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.js +64 -72
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/action/payload.js +61 -70
- package/lib/cjs/action/payload.js.map +1 -1
- package/lib/cjs/api.d.ts +7 -2
- package/lib/cjs/api.js +58 -36
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/content-fields/content-fields-base.js +3 -6
- package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-ai-agent.d.ts +0 -1
- package/lib/cjs/content-fields/flow-ai-agent.js +4 -7
- package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/cjs/content-fields/flow-bot-action.d.ts +0 -1
- package/lib/cjs/content-fields/flow-bot-action.js +14 -17
- package/lib/cjs/content-fields/flow-bot-action.js.map +1 -1
- package/lib/cjs/content-fields/flow-button.d.ts +0 -1
- package/lib/cjs/content-fields/flow-button.js +10 -16
- package/lib/cjs/content-fields/flow-button.js.map +1 -1
- package/lib/cjs/content-fields/flow-capture-user-input.d.ts +13 -0
- package/lib/cjs/content-fields/flow-capture-user-input.js +43 -0
- package/lib/cjs/content-fields/flow-capture-user-input.js.map +1 -0
- package/lib/cjs/content-fields/flow-carousel.d.ts +0 -1
- package/lib/cjs/content-fields/flow-carousel.js +16 -23
- package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
- package/lib/cjs/content-fields/flow-channel-conditional.d.ts +0 -1
- package/lib/cjs/content-fields/flow-channel-conditional.js +14 -17
- package/lib/cjs/content-fields/flow-channel-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-country-conditional.d.ts +0 -1
- package/lib/cjs/content-fields/flow-country-conditional.js +17 -21
- package/lib/cjs/content-fields/flow-country-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-custom-conditional.js +18 -22
- package/lib/cjs/content-fields/flow-custom-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-element.d.ts +0 -1
- package/lib/cjs/content-fields/flow-element.js +5 -9
- package/lib/cjs/content-fields/flow-element.js.map +1 -1
- package/lib/cjs/content-fields/flow-go-to-flow.d.ts +0 -1
- package/lib/cjs/content-fields/flow-go-to-flow.js +15 -18
- package/lib/cjs/content-fields/flow-go-to-flow.js.map +1 -1
- package/lib/cjs/content-fields/flow-handoff.d.ts +0 -1
- package/lib/cjs/content-fields/flow-handoff.js +29 -35
- package/lib/cjs/content-fields/flow-handoff.js.map +1 -1
- package/lib/cjs/content-fields/flow-image.d.ts +0 -1
- package/lib/cjs/content-fields/flow-image.js +2 -5
- package/lib/cjs/content-fields/flow-image.js.map +1 -1
- package/lib/cjs/content-fields/flow-knowledge-base.d.ts +0 -1
- package/lib/cjs/content-fields/flow-knowledge-base.js +5 -8
- package/lib/cjs/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-queue-status-conditional.d.ts +0 -1
- package/lib/cjs/content-fields/flow-queue-status-conditional.js +55 -65
- package/lib/cjs/content-fields/flow-queue-status-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-rating.d.ts +0 -1
- package/lib/cjs/content-fields/flow-rating.js +2 -5
- package/lib/cjs/content-fields/flow-rating.js.map +1 -1
- package/lib/cjs/content-fields/flow-text.d.ts +0 -1
- package/lib/cjs/content-fields/flow-text.js +5 -8
- package/lib/cjs/content-fields/flow-text.js.map +1 -1
- package/lib/cjs/content-fields/flow-video.d.ts +0 -1
- package/lib/cjs/content-fields/flow-video.js +2 -5
- package/lib/cjs/content-fields/flow-video.js.map +1 -1
- package/lib/cjs/content-fields/flow-webview.js +15 -18
- package/lib/cjs/content-fields/flow-webview.js.map +1 -1
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.d.ts +0 -1
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js +3 -6
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
- package/lib/cjs/content-fields/flow-whatsapp-template.d.ts +0 -1
- package/lib/cjs/content-fields/flow-whatsapp-template.js +6 -12
- package/lib/cjs/content-fields/flow-whatsapp-template.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/capture-user-input.d.ts +19 -0
- package/lib/cjs/content-fields/hubtype-fields/capture-user-input.js +12 -0
- package/lib/cjs/content-fields/hubtype-fields/capture-user-input.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/function.js +1 -1
- package/lib/cjs/content-fields/hubtype-fields/function.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/index.d.ts +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +2 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +4 -3
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/cjs/content-fields/hubtype-fields/rating.js +1 -1
- package/lib/cjs/content-fields/hubtype-fields/rating.js.map +1 -1
- package/lib/cjs/content-fields/index.d.ts +3 -2
- package/lib/cjs/content-fields/index.js +3 -1
- package/lib/cjs/content-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +2 -5
- 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 +2 -5
- 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.d.ts +0 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +3 -6
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/cjs/filters/index.js +5 -8
- package/lib/cjs/filters/index.js.map +1 -1
- package/lib/cjs/flow-factory.js +49 -51
- package/lib/cjs/flow-factory.js.map +1 -1
- package/lib/cjs/functions/index.js +18 -21
- package/lib/cjs/functions/index.js.map +1 -1
- package/lib/cjs/helpers.js +1 -2
- package/lib/cjs/helpers.js.map +1 -1
- package/lib/cjs/index.js +68 -73
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/services/hubtype-queues-api.js +10 -12
- package/lib/cjs/services/hubtype-queues-api.js.map +1 -1
- package/lib/cjs/tracking.d.ts +1 -1
- package/lib/cjs/tracking.js +33 -43
- package/lib/cjs/tracking.js.map +1 -1
- package/lib/cjs/types.js +2 -2
- package/lib/cjs/types.js.map +1 -1
- package/lib/cjs/user-input/capture-user-input-api.d.ts +20 -0
- package/lib/cjs/user-input/capture-user-input-api.js +84 -0
- package/lib/cjs/user-input/capture-user-input-api.js.map +1 -0
- package/lib/cjs/user-input/index.d.ts +1 -2
- package/lib/cjs/user-input/index.js +25 -24
- package/lib/cjs/user-input/index.js.map +1 -1
- package/lib/cjs/user-input/keyword.js +31 -36
- package/lib/cjs/user-input/keyword.js.map +1 -1
- package/lib/cjs/user-input/smart-intent.js +55 -59
- package/lib/cjs/user-input/smart-intent.js.map +1 -1
- package/lib/cjs/utils.js +7 -9
- package/lib/cjs/utils.js.map +1 -1
- package/lib/cjs/webview/contents-context.d.ts +0 -1
- package/lib/cjs/webview/types.js +1 -1
- package/lib/cjs/webview/types.js.map +1 -1
- package/lib/cjs/webview/use-webview-contents.js +10 -9
- package/lib/cjs/webview/use-webview-contents.js.map +1 -1
- package/lib/esm/action/ai-agent.js +61 -63
- package/lib/esm/action/ai-agent.js.map +1 -1
- package/lib/esm/action/fallback.js +32 -32
- package/lib/esm/action/fallback.js.map +1 -1
- package/lib/esm/action/first-interaction.js +69 -75
- package/lib/esm/action/first-interaction.js.map +1 -1
- package/lib/esm/action/index.js +93 -101
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.js +71 -75
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/action/payload.js +67 -72
- package/lib/esm/action/payload.js.map +1 -1
- package/lib/esm/api.d.ts +7 -2
- package/lib/esm/api.js +77 -51
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +17 -14
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/content-fields/content-fields-base.js +13 -12
- package/lib/esm/content-fields/content-fields-base.js.map +1 -1
- package/lib/esm/content-fields/flow-ai-agent.d.ts +0 -1
- package/lib/esm/content-fields/flow-ai-agent.js +18 -17
- package/lib/esm/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/esm/content-fields/flow-bot-action.d.ts +0 -1
- package/lib/esm/content-fields/flow-bot-action.js +25 -24
- package/lib/esm/content-fields/flow-bot-action.js.map +1 -1
- package/lib/esm/content-fields/flow-button.d.ts +0 -1
- package/lib/esm/content-fields/flow-button.js +25 -27
- package/lib/esm/content-fields/flow-button.js.map +1 -1
- package/lib/esm/content-fields/flow-capture-user-input.d.ts +13 -0
- package/lib/esm/content-fields/flow-capture-user-input.js +43 -0
- package/lib/esm/content-fields/flow-capture-user-input.js.map +1 -0
- package/lib/esm/content-fields/flow-carousel.d.ts +0 -1
- package/lib/esm/content-fields/flow-carousel.js +39 -42
- package/lib/esm/content-fields/flow-carousel.js.map +1 -1
- package/lib/esm/content-fields/flow-channel-conditional.d.ts +0 -1
- package/lib/esm/content-fields/flow-channel-conditional.js +24 -23
- package/lib/esm/content-fields/flow-channel-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-country-conditional.d.ts +0 -1
- package/lib/esm/content-fields/flow-country-conditional.js +27 -27
- package/lib/esm/content-fields/flow-country-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-custom-conditional.js +30 -30
- package/lib/esm/content-fields/flow-custom-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-element.d.ts +0 -1
- package/lib/esm/content-fields/flow-element.js +16 -16
- package/lib/esm/content-fields/flow-element.js.map +1 -1
- package/lib/esm/content-fields/flow-go-to-flow.d.ts +0 -1
- package/lib/esm/content-fields/flow-go-to-flow.js +25 -24
- package/lib/esm/content-fields/flow-go-to-flow.js.map +1 -1
- package/lib/esm/content-fields/flow-handoff.d.ts +0 -1
- package/lib/esm/content-fields/flow-handoff.js +40 -42
- package/lib/esm/content-fields/flow-handoff.js.map +1 -1
- package/lib/esm/content-fields/flow-image.d.ts +0 -1
- package/lib/esm/content-fields/flow-image.js +12 -11
- package/lib/esm/content-fields/flow-image.js.map +1 -1
- package/lib/esm/content-fields/flow-knowledge-base.d.ts +0 -1
- package/lib/esm/content-fields/flow-knowledge-base.js +15 -14
- package/lib/esm/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/esm/content-fields/flow-queue-status-conditional.d.ts +0 -1
- package/lib/esm/content-fields/flow-queue-status-conditional.js +67 -73
- package/lib/esm/content-fields/flow-queue-status-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-rating.d.ts +0 -1
- package/lib/esm/content-fields/flow-rating.js +23 -22
- package/lib/esm/content-fields/flow-rating.js.map +1 -1
- package/lib/esm/content-fields/flow-text.d.ts +0 -1
- package/lib/esm/content-fields/flow-text.js +25 -24
- package/lib/esm/content-fields/flow-text.js.map +1 -1
- package/lib/esm/content-fields/flow-video.d.ts +0 -1
- package/lib/esm/content-fields/flow-video.js +12 -11
- package/lib/esm/content-fields/flow-video.js.map +1 -1
- package/lib/esm/content-fields/flow-webview.js +23 -22
- package/lib/esm/content-fields/flow-webview.js.map +1 -1
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.d.ts +0 -1
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js +31 -30
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
- package/lib/esm/content-fields/flow-whatsapp-template.d.ts +0 -1
- package/lib/esm/content-fields/flow-whatsapp-template.js +45 -47
- package/lib/esm/content-fields/flow-whatsapp-template.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/ai-agent.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/bot-action.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/button.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/capture-user-input.d.ts +19 -0
- package/lib/esm/content-fields/hubtype-fields/capture-user-input.js +12 -0
- package/lib/esm/content-fields/hubtype-fields/capture-user-input.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/carousel.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/channel-conditional.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/common.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/country-conditional.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/custom-conditional.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/fallback.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/function.js +5 -2
- package/lib/esm/content-fields/hubtype-fields/function.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/go-to-flow.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/handoff.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/image.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/index.d.ts +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.js +27 -23
- package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/keyword.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/knowledge-base.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +2 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.js +10 -6
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/payload.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/queue-status-conditional.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/rating.js +5 -2
- package/lib/esm/content-fields/hubtype-fields/rating.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/smart-intent.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/text.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/url.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/video.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/webview.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-cta-url-button.js +2 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-template.js +2 -1
- package/lib/esm/content-fields/index.d.ts +3 -2
- package/lib/esm/content-fields/index.js +46 -22
- package/lib/esm/content-fields/index.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +10 -9
- 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 +10 -9
- 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.d.ts +0 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +18 -17
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/esm/filters/index.js +10 -9
- package/lib/esm/filters/index.js.map +1 -1
- package/lib/esm/flow-factory.js +56 -54
- package/lib/esm/flow-factory.js.map +1 -1
- package/lib/esm/functions/index.js +24 -22
- package/lib/esm/functions/index.js.map +1 -1
- package/lib/esm/helpers.js +4 -1
- package/lib/esm/helpers.js.map +1 -1
- package/lib/esm/index.js +101 -99
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/services/hubtype-queues-api.js +17 -15
- package/lib/esm/services/hubtype-queues-api.js.map +1 -1
- package/lib/esm/tracking.d.ts +1 -1
- package/lib/esm/tracking.js +42 -45
- package/lib/esm/tracking.js.map +1 -1
- package/lib/esm/types.js +7 -4
- package/lib/esm/types.js.map +1 -1
- package/lib/esm/user-input/capture-user-input-api.d.ts +20 -0
- package/lib/esm/user-input/capture-user-input-api.js +84 -0
- package/lib/esm/user-input/capture-user-input-api.js.map +1 -0
- package/lib/esm/user-input/index.d.ts +1 -2
- package/lib/esm/user-input/index.js +30 -25
- package/lib/esm/user-input/index.js.map +1 -1
- package/lib/esm/user-input/keyword.js +40 -41
- package/lib/esm/user-input/keyword.js.map +1 -1
- package/lib/esm/user-input/smart-intent.js +65 -65
- package/lib/esm/user-input/smart-intent.js.map +1 -1
- package/lib/esm/utils.js +22 -15
- package/lib/esm/utils.js.map +1 -1
- package/lib/esm/webview/contents-context.d.ts +0 -1
- package/lib/esm/webview/contents-context.js +6 -2
- package/lib/esm/webview/contents-context.js.map +1 -1
- package/lib/esm/webview/index.js +9 -3
- package/lib/esm/webview/index.js.map +1 -1
- package/lib/esm/webview/types.js +5 -2
- package/lib/esm/webview/types.js.map +1 -1
- package/lib/esm/webview/use-webview-contents.js +28 -23
- package/lib/esm/webview/use-webview-contents.js.map +1 -1
- package/package.json +2 -2
- package/src/api.ts +35 -1
- package/src/content-fields/flow-capture-user-input.tsx +45 -0
- package/src/content-fields/hubtype-fields/capture-user-input.ts +21 -0
- package/src/content-fields/hubtype-fields/index.ts +1 -0
- package/src/content-fields/hubtype-fields/node-types.ts +1 -0
- package/src/content-fields/hubtype-fields/nodes.ts +2 -0
- package/src/content-fields/index.ts +3 -0
- package/src/flow-factory.ts +4 -0
- package/src/index.ts +4 -3
- package/src/tracking.ts +2 -2
- package/src/user-input/capture-user-input-api.ts +134 -0
- package/src/user-input/index.ts +13 -8
package/lib/cjs/tracking.js
CHANGED
|
@@ -1,52 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.trackEvent = trackEvent;
|
|
4
|
+
exports.trackFlowContent = trackFlowContent;
|
|
5
|
+
exports.trackOneContent = trackOneContent;
|
|
6
|
+
exports.getCommonFlowContentEventArgsForContentId = getCommonFlowContentEventArgsForContentId;
|
|
5
7
|
const core_1 = require("@botonic/core");
|
|
6
8
|
const uuid_1 = require("uuid");
|
|
7
9
|
const hubtype_fields_1 = require("./content-fields/hubtype-fields");
|
|
8
10
|
const helpers_1 = require("./helpers");
|
|
9
|
-
function trackEvent(request, eventAction, args) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return;
|
|
16
|
-
});
|
|
11
|
+
async function trackEvent(request, eventAction, args) {
|
|
12
|
+
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
13
|
+
if (flowBuilderPlugin.trackEvent) {
|
|
14
|
+
await flowBuilderPlugin.trackEvent(request, eventAction, args);
|
|
15
|
+
}
|
|
16
|
+
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
yield trackOneContent(request, content, cmsApi);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
18
|
+
async function trackFlowContent(request, contents) {
|
|
19
|
+
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
20
|
+
const cmsApi = flowBuilderPlugin.cmsApi;
|
|
21
|
+
for (const content of contents) {
|
|
22
|
+
await trackOneContent(request, content, cmsApi);
|
|
23
|
+
}
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
yield trackEvent(request, action, eventArgs);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
25
|
+
async function trackOneContent(request, content, cmsApi) {
|
|
26
|
+
if (!cmsApi) {
|
|
27
|
+
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
28
|
+
cmsApi = flowBuilderPlugin.cmsApi;
|
|
29
|
+
}
|
|
30
|
+
const nodeContent = cmsApi.getNodeById(content.id);
|
|
31
|
+
if (nodeContent.type !== hubtype_fields_1.HtNodeWithContentType.KNOWLEDGE_BASE &&
|
|
32
|
+
nodeContent.type !== hubtype_fields_1.HtNodeWithContentType.AI_AGENT) {
|
|
33
|
+
const event = getContentEventArgs(request, nodeContent);
|
|
34
|
+
const { action, ...eventArgs } = event;
|
|
35
|
+
await trackEvent(request, action, eventArgs);
|
|
36
|
+
}
|
|
43
37
|
}
|
|
44
|
-
exports.trackOneContent = trackOneContent;
|
|
45
38
|
function setSessionFlowThreadId(request, flowThreadId) {
|
|
46
39
|
request.session.flow_thread_id = flowThreadId;
|
|
47
40
|
}
|
|
48
41
|
function getContentEventArgs(request, nodeContent) {
|
|
49
|
-
var _a;
|
|
50
42
|
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } = getCommonFlowContentEventArgs(request, nodeContent);
|
|
51
43
|
setSessionFlowThreadId(request, flowThreadId);
|
|
52
44
|
return {
|
|
@@ -56,27 +48,25 @@ function getContentEventArgs(request, nodeContent) {
|
|
|
56
48
|
flowNodeId,
|
|
57
49
|
flowNodeContentId,
|
|
58
50
|
flowThreadId,
|
|
59
|
-
flowNodeIsMeaningful:
|
|
51
|
+
flowNodeIsMeaningful: nodeContent.is_meaningful ?? false,
|
|
60
52
|
};
|
|
61
53
|
}
|
|
62
54
|
function getCommonFlowContentEventArgs(request, nodeContent) {
|
|
63
|
-
var _a, _b;
|
|
64
55
|
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
65
56
|
const flowName = flowBuilderPlugin.getFlowName(nodeContent.flow_id);
|
|
66
|
-
const flowThreadId =
|
|
57
|
+
const flowThreadId = request.session.flow_thread_id ?? (0, uuid_1.v7)();
|
|
67
58
|
return {
|
|
68
59
|
flowThreadId,
|
|
69
60
|
flowId: nodeContent.flow_id,
|
|
70
61
|
flowName,
|
|
71
62
|
flowNodeId: nodeContent.id,
|
|
72
|
-
flowNodeContentId:
|
|
63
|
+
flowNodeContentId: nodeContent.code ?? '',
|
|
73
64
|
};
|
|
74
65
|
}
|
|
75
|
-
function getCommonFlowContentEventArgsForContentId(request,
|
|
66
|
+
function getCommonFlowContentEventArgsForContentId(request, id) {
|
|
76
67
|
const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
|
|
77
68
|
const cmsApi = flowBuilderPlugin.cmsApi;
|
|
78
|
-
const nodeContent = cmsApi.getNodeById(
|
|
69
|
+
const nodeContent = cmsApi.getNodeById(id);
|
|
79
70
|
return getCommonFlowContentEventArgs(request, nodeContent);
|
|
80
71
|
}
|
|
81
|
-
exports.getCommonFlowContentEventArgsForContentId = getCommonFlowContentEventArgsForContentId;
|
|
82
72
|
//# sourceMappingURL=tracking.js.map
|
package/lib/cjs/tracking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/tracking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tracking.js","sourceRoot":"","sources":["../../src/tracking.ts"],"names":[],"mappings":";;AAYA,gCAUC;AAED,4CASC;AAED,0CAmBC;AAsDD,8FASC;AArHD,wCAAsD;AAEtD,+BAAmC;AAIn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G,iBAAiB,CAAC,MAAM,CAAA;IACvC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAoB,EAAE,CAAC,CAAA;IAE7D,OAAO,6BAA6B,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;AAC5D,CAAC"}
|
package/lib/cjs/types.js
CHANGED
|
@@ -5,10 +5,10 @@ var ProcessEnvNodeEnvs;
|
|
|
5
5
|
(function (ProcessEnvNodeEnvs) {
|
|
6
6
|
ProcessEnvNodeEnvs["PRODUCTION"] = "production";
|
|
7
7
|
ProcessEnvNodeEnvs["DEVELOPMENT"] = "development";
|
|
8
|
-
})(ProcessEnvNodeEnvs
|
|
8
|
+
})(ProcessEnvNodeEnvs || (exports.ProcessEnvNodeEnvs = ProcessEnvNodeEnvs = {}));
|
|
9
9
|
var FlowBuilderJSONVersion;
|
|
10
10
|
(function (FlowBuilderJSONVersion) {
|
|
11
11
|
FlowBuilderJSONVersion["DRAFT"] = "draft";
|
|
12
12
|
FlowBuilderJSONVersion["LATEST"] = "latest";
|
|
13
|
-
})(FlowBuilderJSONVersion
|
|
13
|
+
})(FlowBuilderJSONVersion || (exports.FlowBuilderJSONVersion = FlowBuilderJSONVersion = {}));
|
|
14
14
|
//# sourceMappingURL=types.js.map
|
package/lib/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAoFA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAoFA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAED,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;AACnB,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ActionRequest } from '@botonic/react';
|
|
2
|
+
import { FlowBuilderApi } from '../api';
|
|
3
|
+
import { HtCaptureUserInputNode } from '../content-fields/hubtype-fields';
|
|
4
|
+
interface AiCaptureResponseSuccess {
|
|
5
|
+
success: true;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
interface AiCaptureResponseFailure {
|
|
9
|
+
success: false;
|
|
10
|
+
}
|
|
11
|
+
type AiCaptureResponse = AiCaptureResponseSuccess | AiCaptureResponseFailure;
|
|
12
|
+
export declare class CaptureUserInputApi {
|
|
13
|
+
private cmsApi;
|
|
14
|
+
private request;
|
|
15
|
+
constructor(cmsApi: FlowBuilderApi, request: ActionRequest);
|
|
16
|
+
getNextNodeId(): Promise<string | undefined>;
|
|
17
|
+
getAiCaptureResponse(captureUserInputNode: HtCaptureUserInputNode): Promise<AiCaptureResponse>;
|
|
18
|
+
trackUserInputCapture(captureUserInputNode: HtCaptureUserInputNode, captureSuccess: boolean): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CaptureUserInputApi = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@botonic/core");
|
|
6
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
7
|
+
const content_fields_1 = require("../content-fields");
|
|
8
|
+
const hubtype_fields_1 = require("../content-fields/hubtype-fields");
|
|
9
|
+
const tracking_1 = require("../tracking");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
class CaptureUserInputApi {
|
|
12
|
+
constructor(cmsApi, request) {
|
|
13
|
+
this.cmsApi = cmsApi;
|
|
14
|
+
this.request = request;
|
|
15
|
+
}
|
|
16
|
+
async getNextNodeId() {
|
|
17
|
+
if ((0, utils_1.inputHasTextData)(this.request.input) &&
|
|
18
|
+
this.cmsApi.shouldCaptureUserInput()) {
|
|
19
|
+
const captureUserInputNode = this.cmsApi.getCaptureUserInputNode();
|
|
20
|
+
if (!captureUserInputNode) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const captureUserInput = content_fields_1.FlowCaptureUserInput.fromHubtypeCMS(captureUserInputNode);
|
|
24
|
+
if (captureUserInput.aiValidationType === hubtype_fields_1.HtAiValidationType.NONE) {
|
|
25
|
+
this.cmsApi.setUserExtraDataVariable(captureUserInputNode.content.field_name, this.request.input.data);
|
|
26
|
+
await this.trackUserInputCapture(captureUserInputNode, true);
|
|
27
|
+
return captureUserInput.captureSuccessId;
|
|
28
|
+
}
|
|
29
|
+
const aiCaptureResponse = await this.getAiCaptureResponse(captureUserInputNode);
|
|
30
|
+
if (!aiCaptureResponse.success) {
|
|
31
|
+
await this.trackUserInputCapture(captureUserInputNode, false);
|
|
32
|
+
return captureUserInput.captureFailId;
|
|
33
|
+
}
|
|
34
|
+
this.cmsApi.setUserExtraDataVariable(captureUserInputNode.content.field_name, aiCaptureResponse.value);
|
|
35
|
+
await this.trackUserInputCapture(captureUserInputNode, true);
|
|
36
|
+
return captureUserInput.captureSuccessId;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
async getAiCaptureResponse(captureUserInputNode) {
|
|
41
|
+
try {
|
|
42
|
+
const url = `${process.env.HUBTYPE_API_URL}/external/v1/capture_user_input/`;
|
|
43
|
+
const data = {
|
|
44
|
+
field_name: captureUserInputNode.content.field_name,
|
|
45
|
+
validation_instructions: captureUserInputNode.content.ai_validation_instructions,
|
|
46
|
+
user_input: this.request.input.data,
|
|
47
|
+
};
|
|
48
|
+
const config = {
|
|
49
|
+
headers: {
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
Authorization: `Bearer ${this.request.session._access_token}`,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const aiCaptureResponse = await axios_1.default.post(url, data, config);
|
|
55
|
+
return aiCaptureResponse.data;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.warn('Error getting ai/capture_user_input', error);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
success: false,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async trackUserInputCapture(captureUserInputNode, captureSuccess) {
|
|
65
|
+
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } = (0, tracking_1.getCommonFlowContentEventArgsForContentId)(this.request, captureUserInputNode.id);
|
|
66
|
+
const event = {
|
|
67
|
+
action: core_1.EventAction.CaptureUserInput,
|
|
68
|
+
flowThreadId,
|
|
69
|
+
flowId,
|
|
70
|
+
flowName,
|
|
71
|
+
flowNodeId,
|
|
72
|
+
flowNodeContentId,
|
|
73
|
+
flowNodeIsMeaningful: false,
|
|
74
|
+
fieldName: captureUserInputNode.content.field_name,
|
|
75
|
+
userInput: this.request.input.data,
|
|
76
|
+
captureSuccess,
|
|
77
|
+
messageId: this.request.input.message_id,
|
|
78
|
+
};
|
|
79
|
+
const { action, ...eventArgs } = event;
|
|
80
|
+
await (0, tracking_1.trackEvent)(this.request, action, eventArgs);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.CaptureUserInputApi = CaptureUserInputApi;
|
|
84
|
+
//# sourceMappingURL=capture-user-input-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-user-input-api.js","sourceRoot":"","sources":["../../../src/user-input/capture-user-input-api.ts"],"names":[],"mappings":";;;;AAAA,wCAAkE;AAElE,0DAAyB;AAGzB,sDAAwD;AACxD,qEAGyC;AACzC,0CAGoB;AACpB,oCAA2C;AAa3C,MAAa,mBAAmB;IAI9B,YAAY,MAAsB,EAAE,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ACR,UAAU;YACV,iBAAiB;YACjB,oBAAoB,EAAE,KAAK;YAC3B,SAAS,EAAE,oBAAoB,CAAC,OAAO,CAAC,UAAU;YAClD,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAc;YAC5C,cAAc;YACd,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU;SACzC,CAAA;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAA;QACtC,MAAM,IAAA,qBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IACnD,CAAC;CACF;AA1GD,kDA0GC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ActionRequest } from '@botonic/react';
|
|
2
2
|
import { FlowBuilderApi } from '../api';
|
|
3
|
-
import { HtKeywordNode, HtSmartIntentNode } from '../content-fields/hubtype-fields';
|
|
4
3
|
import { SmartIntentsInferenceConfig } from './smart-intent';
|
|
5
|
-
export declare function
|
|
4
|
+
export declare function getNextPayloadByUserInput(cmsApi: FlowBuilderApi, locale: string, request: ActionRequest, smartIntentsConfig: SmartIntentsInferenceConfig): Promise<string | undefined>;
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
3
|
+
exports.getNextPayloadByUserInput = getNextPayloadByUserInput;
|
|
5
4
|
const utils_1 = require("../utils");
|
|
5
|
+
const capture_user_input_api_1 = require("./capture-user-input-api");
|
|
6
6
|
const keyword_1 = require("./keyword");
|
|
7
7
|
const smart_intent_1 = require("./smart-intent");
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
async function getNextPayloadByUserInput(cmsApi, locale, request, smartIntentsConfig) {
|
|
9
|
+
if ((0, utils_1.inputHasTextData)(request.input)) {
|
|
10
|
+
if (cmsApi.shouldCaptureUserInput()) {
|
|
11
|
+
const captureUserInputApi = new capture_user_input_api_1.CaptureUserInputApi(cmsApi, request);
|
|
12
|
+
return await captureUserInputApi.getNextNodeId();
|
|
13
|
+
}
|
|
14
|
+
if ((0, utils_1.isKeywordsAllowed)(request)) {
|
|
15
|
+
const keywordMatcher = new keyword_1.KeywordMatcher({
|
|
16
|
+
cmsApi,
|
|
17
|
+
locale,
|
|
18
|
+
request,
|
|
19
|
+
});
|
|
20
|
+
const keywordNode = await keywordMatcher.getNodeByInput(request.input.data);
|
|
21
|
+
if (keywordNode) {
|
|
22
|
+
return cmsApi.getPayload(keywordNode.target);
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
}
|
|
25
|
+
if ((0, utils_1.isSmartIntentsAllowed)(request)) {
|
|
26
|
+
const smartIntentsApi = new smart_intent_1.SmartIntentsApi(cmsApi, request, smartIntentsConfig);
|
|
27
|
+
const smartIntentNode = await smartIntentsApi.getNodeByInput();
|
|
28
|
+
if (smartIntentNode) {
|
|
29
|
+
return cmsApi.getPayload(smartIntentNode.target);
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
32
34
|
}
|
|
33
|
-
exports.getNodeByUserInput = getNodeByUserInput;
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/user-input/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/user-input/index.ts"],"names":[],"mappings":";;AAYA,8DA2CC;AApDD,o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.KeywordMatcher = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const core_1 = require("@botonic/core");
|
|
6
5
|
const constants_1 = require("../constants");
|
|
7
6
|
const tracking_1 = require("../tracking");
|
|
@@ -12,26 +11,24 @@ class KeywordMatcher {
|
|
|
12
11
|
this.request = request;
|
|
13
12
|
this.isRegExp = false;
|
|
14
13
|
}
|
|
15
|
-
getNodeByInput(userInput) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return keywordNode;
|
|
30
|
-
});
|
|
14
|
+
async getNodeByInput(userInput) {
|
|
15
|
+
const keywordNodes = this.cmsApi.getKeywordNodes();
|
|
16
|
+
const keywordNode = this.getNodeByKeyword(userInput, keywordNodes);
|
|
17
|
+
if (!keywordNode || !this.matchedKeyword) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const targetPayload = this.cmsApi.getPayload(keywordNode.target);
|
|
21
|
+
this.request.input.nluResolution = {
|
|
22
|
+
type: core_1.NluType.Keyword,
|
|
23
|
+
matchedValue: this.matchedKeyword,
|
|
24
|
+
payload: targetPayload,
|
|
25
|
+
};
|
|
26
|
+
await this.trackKeywordEvent();
|
|
27
|
+
return keywordNode;
|
|
31
28
|
}
|
|
32
29
|
getNodeByKeyword(userInput, keywordNodes) {
|
|
33
30
|
const matchedKeywordNode = keywordNodes.find(node => this.matchKeywords(userInput, node));
|
|
34
|
-
return
|
|
31
|
+
return matchedKeywordNode?.target ? matchedKeywordNode : undefined;
|
|
35
32
|
}
|
|
36
33
|
matchKeywords(userInput, node) {
|
|
37
34
|
const result = node.content.keywords.find(keywords => {
|
|
@@ -64,24 +61,22 @@ class KeywordMatcher {
|
|
|
64
61
|
const [, pattern, flags] = regExpMatchArray;
|
|
65
62
|
return new RegExp(pattern, flags);
|
|
66
63
|
}
|
|
67
|
-
trackKeywordEvent() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
yield (0, tracking_1.trackEvent)(this.request, action, eventArgs);
|
|
84
|
-
});
|
|
64
|
+
async trackKeywordEvent() {
|
|
65
|
+
const { flowId, flowName, flowNodeId, flowNodeContentId } = (0, tracking_1.getCommonFlowContentEventArgsForContentId)(this.request, this.keywordNodeId);
|
|
66
|
+
const event = {
|
|
67
|
+
action: core_1.EventAction.Keyword,
|
|
68
|
+
flowNodeId,
|
|
69
|
+
flowId,
|
|
70
|
+
flowName,
|
|
71
|
+
flowNodeContentId,
|
|
72
|
+
flowThreadId: this.request.session.flow_thread_id,
|
|
73
|
+
nluKeywordName: this.matchedKeyword,
|
|
74
|
+
nluKeywordIsRegex: this.isRegExp,
|
|
75
|
+
nluKeywordMessageId: this.request.input.message_id,
|
|
76
|
+
userInput: this.request.input.data,
|
|
77
|
+
};
|
|
78
|
+
const { action, ...eventArgs } = event;
|
|
79
|
+
await (0, tracking_1.trackEvent)(this.request, action, eventArgs);
|
|
85
80
|
}
|
|
86
81
|
}
|
|
87
82
|
exports.KeywordMatcher = KeywordMatcher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/user-input/keyword.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keyword.js","sourceRoot":"","sources":["../../../src/user-input/keyword.ts"],"names":[],"mappings":";;;AAAA,wCAAkE;AAIlE,4CAA8C;AAK9C,0CAGoB;AAOpB,MAAa,cAAc;IASzB,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAgB;QACnD,IAAI,CAAC,MAAM,GAAG,M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C,GAAG,gBAAgB,CAAA;QAC3C,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACnC,CAAC;IAEO,KAAK,CAAC,iBAAiB;QAC7B,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,EAAE,GACvD,IAAA,oDAAyC,EACvC,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,aAAuB,CAC7B,CAAA;QAEH,MAAM,KAAK,GAAiB;YAC1B,MAAM,EAAE,kBAAW,CAAC,OAAO;YAC3B,UAAU;YACV,MAAM;YACN,QAAQ;YACR,iBAAiB;YACjB,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,cAAwB;YAC3D,cAAc,EAAE,IAAI,CAAC,cAAwB;YAC7C,iBAAiB,EAAE,IAAI,CAAC,QAAQ;YAChC,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU;YAClD,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAc;SAC7C,CAAA;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAA;QACtC,MAAM,IAAA,qBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IACnD,CAAC;CACF;AA5GD,wCA4GC"}
|
|
@@ -13,72 +13,68 @@ class SmartIntentsApi {
|
|
|
13
13
|
this.smartIntentsConfig = smartIntentsConfig;
|
|
14
14
|
this.flowId = flowId;
|
|
15
15
|
}
|
|
16
|
-
getNodeByInput() {
|
|
17
|
-
|
|
18
|
-
if (!this.currentRequest.input.data)
|
|
19
|
-
return undefined;
|
|
20
|
-
const smartIntentNodes = this.cmsApi.getSmartIntentNodes();
|
|
21
|
-
if (!smartIntentNodes.length)
|
|
22
|
-
return undefined;
|
|
23
|
-
const params = {
|
|
24
|
-
bot_id: this.currentRequest.session.bot.id,
|
|
25
|
-
text: this.currentRequest.input.data,
|
|
26
|
-
num_smart_intents_to_use: this.smartIntentsConfig.numSmartIntentsToUse,
|
|
27
|
-
use_latest: this.resolveUseLatest(),
|
|
28
|
-
};
|
|
29
|
-
try {
|
|
30
|
-
const response = yield this.getInference(params);
|
|
31
|
-
const smartIntentNode = smartIntentNodes.find(smartIntentNode => smartIntentNode.content.title === response.data.smart_intent_title);
|
|
32
|
-
if (smartIntentNode) {
|
|
33
|
-
const targetPayload = this.cmsApi.getPayload(smartIntentNode.target);
|
|
34
|
-
this.currentRequest.input.nluResolution = {
|
|
35
|
-
type: core_1.NluType.SmartIntent,
|
|
36
|
-
matchedValue: smartIntentNode.content.title,
|
|
37
|
-
payload: targetPayload,
|
|
38
|
-
};
|
|
39
|
-
const { flowId, flowName, flowNodeId, flowNodeContentId } = (0, tracking_1.getCommonFlowContentEventArgsForContentId)(this.currentRequest, smartIntentNode.id);
|
|
40
|
-
const event = {
|
|
41
|
-
action: core_1.EventAction.IntentSmart,
|
|
42
|
-
nluIntentSmartTitle: response.data.smart_intent_title,
|
|
43
|
-
nluIntentSmartNumUsed: response.data.smart_intents_used.length,
|
|
44
|
-
nluIntentSmartMessageId: this.currentRequest.input.message_id,
|
|
45
|
-
userInput: this.currentRequest.input.data,
|
|
46
|
-
flowThreadId: this.currentRequest.session.flow_thread_id,
|
|
47
|
-
flowId,
|
|
48
|
-
flowName,
|
|
49
|
-
flowNodeContentId,
|
|
50
|
-
flowNodeId,
|
|
51
|
-
};
|
|
52
|
-
const { action } = event, eventArgs = tslib_1.__rest(event, ["action"]);
|
|
53
|
-
yield (0, tracking_1.trackEvent)(this.currentRequest, action, eventArgs);
|
|
54
|
-
return smartIntentNode;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
console.error(e);
|
|
59
|
-
}
|
|
16
|
+
async getNodeByInput() {
|
|
17
|
+
if (!this.currentRequest.input.data)
|
|
60
18
|
return undefined;
|
|
61
|
-
|
|
19
|
+
const smartIntentNodes = this.cmsApi.getSmartIntentNodes();
|
|
20
|
+
if (!smartIntentNodes.length)
|
|
21
|
+
return undefined;
|
|
22
|
+
const params = {
|
|
23
|
+
bot_id: this.currentRequest.session.bot.id,
|
|
24
|
+
text: this.currentRequest.input.data,
|
|
25
|
+
num_smart_intents_to_use: this.smartIntentsConfig.numSmartIntentsToUse,
|
|
26
|
+
use_latest: this.resolveUseLatest(),
|
|
27
|
+
};
|
|
28
|
+
try {
|
|
29
|
+
const response = await this.getInference(params);
|
|
30
|
+
const smartIntentNode = smartIntentNodes.find(smartIntentNode => smartIntentNode.content.title === response.data.smart_intent_title);
|
|
31
|
+
if (smartIntentNode) {
|
|
32
|
+
const targetPayload = this.cmsApi.getPayload(smartIntentNode.target);
|
|
33
|
+
this.currentRequest.input.nluResolution = {
|
|
34
|
+
type: core_1.NluType.SmartIntent,
|
|
35
|
+
matchedValue: smartIntentNode.content.title,
|
|
36
|
+
payload: targetPayload,
|
|
37
|
+
};
|
|
38
|
+
const { flowId, flowName, flowNodeId, flowNodeContentId } = (0, tracking_1.getCommonFlowContentEventArgsForContentId)(this.currentRequest, smartIntentNode.id);
|
|
39
|
+
const event = {
|
|
40
|
+
action: core_1.EventAction.IntentSmart,
|
|
41
|
+
nluIntentSmartTitle: response.data.smart_intent_title,
|
|
42
|
+
nluIntentSmartNumUsed: response.data.smart_intents_used.length,
|
|
43
|
+
nluIntentSmartMessageId: this.currentRequest.input.message_id,
|
|
44
|
+
userInput: this.currentRequest.input.data,
|
|
45
|
+
flowThreadId: this.currentRequest.session.flow_thread_id,
|
|
46
|
+
flowId,
|
|
47
|
+
flowName,
|
|
48
|
+
flowNodeContentId,
|
|
49
|
+
flowNodeId,
|
|
50
|
+
};
|
|
51
|
+
const { action, ...eventArgs } = event;
|
|
52
|
+
await (0, tracking_1.trackEvent)(this.currentRequest, action, eventArgs);
|
|
53
|
+
return smartIntentNode;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
console.error(e);
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
62
60
|
}
|
|
63
61
|
resolveUseLatest() {
|
|
64
62
|
if (this.currentRequest.session.is_test_integration)
|
|
65
63
|
return false;
|
|
66
64
|
return this.smartIntentsConfig.useLatest;
|
|
67
65
|
}
|
|
68
|
-
getInference(inferenceParams) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
timeout: 10000,
|
|
81
|
-
});
|
|
66
|
+
async getInference(inferenceParams) {
|
|
67
|
+
const pluginFlowBuilder = (0, helpers_1.getFlowBuilderPlugin)(this.currentRequest.plugins);
|
|
68
|
+
const token = pluginFlowBuilder.getAccessToken(this.currentRequest.session);
|
|
69
|
+
return await (0, axios_1.default)({
|
|
70
|
+
method: 'POST',
|
|
71
|
+
url: `${process.env.HUBTYPE_API_URL}/external/v2/ai/smart_intents/inference/`,
|
|
72
|
+
headers: {
|
|
73
|
+
Authorization: `Bearer ${token}`,
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
},
|
|
76
|
+
data: inferenceParams,
|
|
77
|
+
timeout: 10000,
|
|
82
78
|
});
|
|
83
79
|
}
|
|
84
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-intent.js","sourceRoot":"","sources":["../../../src/user-input/smart-intent.ts"],"names":[],"mappings":";;;;AAAA,wCAAsE;AAEtE,0DAAyB;AAIzB,wCAAiD;AACjD,0CAGoB;AAepB,MAAa,eAAe;IAC1B,YACS,MAAsB,EACtB,cAA6B,EAC7B,kBAA+C,EAC/C,MAAe;QAHf,WAAM,GAAN,MAAM,CAAgB;QACtB,mBAAc,GAAd,cAAc,CAAe;QAC7B,uBAAkB,GAAlB,kBAAkB,CAA6B;QAC/C,WAAM,GAAN,MAAM,CAAS;IACrB,CAAC;
|
|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