@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAI9B,MAAM,4BAA4B,GAAG,GAA8B,EAAE,CAC1E,IAAA,qBAAa,EAAgC;IAC3C,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAA6B;CACxC,CAAC,CAAA;AANS,QAAA,4BAA4B,gCAMrC"}
|
package/lib/esm/webview/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWebviewContents = exports.createWebviewContentsContext = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
var contents_context_1 = require("./contents-context");
|
|
6
|
+
Object.defineProperty(exports, "createWebviewContentsContext", { enumerable: true, get: function () { return contents_context_1.createWebviewContentsContext; } });
|
|
7
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
8
|
+
var use_webview_contents_1 = require("./use-webview-contents");
|
|
9
|
+
Object.defineProperty(exports, "useWebviewContents", { enumerable: true, get: function () { return use_webview_contents_1.useWebviewContents; } });
|
|
4
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAiE;AAAxD,gIAAA,4BAA4B,OAAA;AACrC,kDAAuB;AACvB,+DAA2D;AAAlD,0HAAA,kBAAkB,OAAA"}
|
package/lib/esm/webview/types.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebviewContentType = void 0;
|
|
4
|
+
var WebviewContentType;
|
|
2
5
|
(function (WebviewContentType) {
|
|
3
6
|
WebviewContentType["TEXT"] = "webview-text";
|
|
4
7
|
WebviewContentType["IMAGE"] = "webview-image";
|
|
5
|
-
})(WebviewContentType || (WebviewContentType = {}));
|
|
8
|
+
})(WebviewContentType || (exports.WebviewContentType = WebviewContentType = {}));
|
|
6
9
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/webview/types.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/webview/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,2CAAqB,CAAA;IACrB,6CAAuB,CAAA;AACzB,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const [
|
|
12
|
-
const [
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWebviewContents = useWebviewContents;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
const types_2 = require("./types");
|
|
10
|
+
function useWebviewContents({ apiUrl = constants_1.FLOW_BUILDER_API_URL_PROD, version = types_1.FlowBuilderJSONVersion.LATEST, botId, webviewId, providerId, locale, mapContents, }) {
|
|
11
|
+
const [textContents, setTextContents] = (0, react_1.useState)();
|
|
12
|
+
const [imageContents, setImageContents] = (0, react_1.useState)();
|
|
13
|
+
const [contents, setContents] = (0, react_1.useState)({});
|
|
14
|
+
const [currentLocale, setCurrentLocale] = (0, react_1.useState)(locale);
|
|
15
|
+
const [error, setError] = (0, react_1.useState)(false);
|
|
13
16
|
const updateCurrentLocale = (textContents) => {
|
|
14
17
|
if (!textContents || textContents.length === 0) {
|
|
15
18
|
console.log('There is no text contents to check the locale');
|
|
@@ -28,16 +31,18 @@ export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version
|
|
|
28
31
|
console.error(`locale: ${currentLocale} cannot be resolved with: ${locales.join(', ')}`);
|
|
29
32
|
};
|
|
30
33
|
const getTextContent = (contentID) => {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
return (textContents
|
|
35
|
+
?.find(textContent => textContent.code === contentID)
|
|
36
|
+
?.content.text.find(text => text.locale === currentLocale)?.message ||
|
|
33
37
|
'');
|
|
34
38
|
};
|
|
35
39
|
const getImageSrc = (contentID) => {
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
return (imageContents
|
|
41
|
+
?.find(imageContent => imageContent.code === contentID)
|
|
42
|
+
?.content.image.find(image => image.locale === currentLocale)?.file ||
|
|
38
43
|
'');
|
|
39
44
|
};
|
|
40
|
-
useEffect(() => {
|
|
45
|
+
(0, react_1.useEffect)(() => {
|
|
41
46
|
if (textContents || imageContents) {
|
|
42
47
|
const contentsObject = {};
|
|
43
48
|
for (const [key, value] of Object.entries(mapContents)) {
|
|
@@ -46,14 +51,14 @@ export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version
|
|
|
46
51
|
setContents(contentsObject);
|
|
47
52
|
}
|
|
48
53
|
}, [textContents, imageContents, currentLocale]);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
const getResponseContents = () =>
|
|
54
|
+
(0, react_1.useEffect)(() => {
|
|
55
|
+
const getResponseContents = async () => {
|
|
51
56
|
const url = `${apiUrl}/v1/bot_flows/${botId}/versions/${version}/webviews/${webviewId}/?provider_id=${providerId}`;
|
|
52
57
|
try {
|
|
53
|
-
const response =
|
|
54
|
-
const textResponseContents = response.data.filter(webviewContent => webviewContent.type === WebviewContentType.TEXT);
|
|
58
|
+
const response = await axios_1.default.get(url);
|
|
59
|
+
const textResponseContents = response.data.filter(webviewContent => webviewContent.type === types_2.WebviewContentType.TEXT);
|
|
55
60
|
setTextContents(textResponseContents);
|
|
56
|
-
const imageResponseContents = response.data.filter(webviewContent => webviewContent.type === WebviewContentType.IMAGE);
|
|
61
|
+
const imageResponseContents = response.data.filter(webviewContent => webviewContent.type === types_2.WebviewContentType.IMAGE);
|
|
57
62
|
setImageContents(imageResponseContents);
|
|
58
63
|
updateCurrentLocale(textResponseContents);
|
|
59
64
|
}
|
|
@@ -61,7 +66,7 @@ export function useWebviewContents({ apiUrl = FLOW_BUILDER_API_URL_PROD, version
|
|
|
61
66
|
console.error('Error fetching webview contents:', error);
|
|
62
67
|
setError(true);
|
|
63
68
|
}
|
|
64
|
-
}
|
|
69
|
+
};
|
|
65
70
|
getResponseContents();
|
|
66
71
|
}, []);
|
|
67
72
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings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GED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-flow-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0-alpha.0",
|
|
4
4
|
"main": "./lib/cjs/index.js",
|
|
5
5
|
"module": "./lib/esm/index.js",
|
|
6
6
|
"description": "Use Flow Builder to show your contents",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet 'src/**/*.ts*'"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@botonic/react": "^0.
|
|
17
|
+
"@botonic/react": "^0.44.0-alpha.0",
|
|
18
18
|
"axios": "^1.13.2",
|
|
19
19
|
"uuid": "^10.0.0"
|
|
20
20
|
},
|
package/src/api.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from './constants'
|
|
10
10
|
import {
|
|
11
11
|
HtBotActionNode,
|
|
12
|
+
HtCaptureUserInputNode,
|
|
12
13
|
HtFallbackNode,
|
|
13
14
|
HtFlowBuilderData,
|
|
14
15
|
HtFlowWebview,
|
|
@@ -21,8 +22,8 @@ import {
|
|
|
21
22
|
HtPayloadNode,
|
|
22
23
|
HtRatingButton,
|
|
23
24
|
HtRatingNode,
|
|
25
|
+
HtSmartIntentNode,
|
|
24
26
|
} from './content-fields/hubtype-fields'
|
|
25
|
-
import { HtSmartIntentNode } from './content-fields/hubtype-fields/smart-intent'
|
|
26
27
|
import { FlowBuilderApiOptions, ProcessEnvNodeEnvs } from './types'
|
|
27
28
|
|
|
28
29
|
export class FlowBuilderApi {
|
|
@@ -265,6 +266,39 @@ export class FlowBuilderApi {
|
|
|
265
266
|
return this.flow.webviews.find(webview => webview.id === id)
|
|
266
267
|
}
|
|
267
268
|
|
|
269
|
+
shouldCaptureUserInput(): boolean {
|
|
270
|
+
return !!this.getCaptureUserInputId()
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
getCaptureUserInputId(): string | undefined {
|
|
274
|
+
return this.request.session.capture_user_input?.node_id
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
setCaptureUserInputId(id: string): void {
|
|
278
|
+
if (this.request.session.capture_user_input) {
|
|
279
|
+
this.request.session.capture_user_input.node_id = id
|
|
280
|
+
}
|
|
281
|
+
this.request.session.capture_user_input = { node_id: id }
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
removeCaptureUserInputId(): void {
|
|
285
|
+
this.request.session.capture_user_input = undefined
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
setUserExtraDataVariable(key: string, value: string): void {
|
|
289
|
+
if (this.request.session.user.extra_data) {
|
|
290
|
+
this.request.session.user.extra_data[key] = value
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
getCaptureUserInputNode(): HtCaptureUserInputNode | undefined {
|
|
295
|
+
const captureUserInputId = this.getCaptureUserInputId()
|
|
296
|
+
if (!captureUserInputId) {
|
|
297
|
+
return undefined
|
|
298
|
+
}
|
|
299
|
+
return this.getNodeById<HtCaptureUserInputNode>(captureUserInputId)
|
|
300
|
+
}
|
|
301
|
+
|
|
268
302
|
getResolvedLocale(): string {
|
|
269
303
|
const systemLocale = this.request.getSystemLocale()
|
|
270
304
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ActionRequest } from '@botonic/react'
|
|
2
|
+
|
|
3
|
+
import { getFlowBuilderPlugin } from '../helpers'
|
|
4
|
+
import { ContentFieldsBase } from './content-fields-base'
|
|
5
|
+
import {
|
|
6
|
+
HtAiValidationType,
|
|
7
|
+
HtCaptureUserInputNode,
|
|
8
|
+
} from './hubtype-fields/capture-user-input'
|
|
9
|
+
|
|
10
|
+
export class FlowCaptureUserInput extends ContentFieldsBase {
|
|
11
|
+
public fieldName = ''
|
|
12
|
+
public aiValidationType = HtAiValidationType.NONE
|
|
13
|
+
public aiValidationInstructions = ''
|
|
14
|
+
public captureSuccessId = ''
|
|
15
|
+
public captureFailId = ''
|
|
16
|
+
|
|
17
|
+
static fromHubtypeCMS(cmsText: HtCaptureUserInputNode): FlowCaptureUserInput {
|
|
18
|
+
const newCaptureUserInput = new FlowCaptureUserInput(cmsText.id)
|
|
19
|
+
newCaptureUserInput.code = cmsText.code
|
|
20
|
+
newCaptureUserInput.fieldName = cmsText.content.field_name
|
|
21
|
+
newCaptureUserInput.aiValidationType =
|
|
22
|
+
cmsText.content.ai_validation_type || HtAiValidationType.NONE
|
|
23
|
+
newCaptureUserInput.aiValidationInstructions =
|
|
24
|
+
cmsText.content.ai_validation_instructions || ''
|
|
25
|
+
newCaptureUserInput.captureSuccessId = cmsText.content.capture_success.id
|
|
26
|
+
newCaptureUserInput.captureFailId = cmsText.content.capture_fail.id
|
|
27
|
+
newCaptureUserInput.followUp = undefined
|
|
28
|
+
|
|
29
|
+
return newCaptureUserInput
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
async trackFlow(_request: ActionRequest): Promise<void> {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
|
+
toBotonic(_id: string, request: ActionRequest): JSX.Element {
|
|
39
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
|
|
40
|
+
const cmsApi = flowBuilderPlugin.cmsApi
|
|
41
|
+
cmsApi.setCaptureUserInputId(this.id)
|
|
42
|
+
|
|
43
|
+
return <></>
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HtBaseNode, HtNodeLink } from './common'
|
|
2
|
+
import { HtNodeWithContentType } from './node-types'
|
|
3
|
+
|
|
4
|
+
export enum HtAiValidationType {
|
|
5
|
+
NONE = 'None',
|
|
6
|
+
NAME = 'Name',
|
|
7
|
+
EMAIL = 'Email',
|
|
8
|
+
PHONE = 'Phone number',
|
|
9
|
+
CUSTOM = 'Custom',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface HtCaptureUserInputNode extends HtBaseNode {
|
|
13
|
+
type: HtNodeWithContentType.CAPTURE_USER_INPUT
|
|
14
|
+
content: {
|
|
15
|
+
field_name: string
|
|
16
|
+
ai_validation_type?: HtAiValidationType
|
|
17
|
+
ai_validation_instructions?: string
|
|
18
|
+
capture_success: HtNodeLink
|
|
19
|
+
capture_fail: HtNodeLink
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HtAiAgentNode } from './ai-agent'
|
|
2
2
|
import { HtBotActionNode } from './bot-action'
|
|
3
|
+
import { HtCaptureUserInputNode } from './capture-user-input'
|
|
3
4
|
import { HtCarouselNode } from './carousel'
|
|
4
5
|
// import { HtChannelConditionalNode } from './channel-conditional'
|
|
5
6
|
// import { HtCountryConditionalNode } from './country-conditional'
|
|
@@ -42,6 +43,7 @@ export type HtNodeWithContent =
|
|
|
42
43
|
| HtWebviewNode
|
|
43
44
|
| HtGoToFlow
|
|
44
45
|
| HtWhatsappTemplateNode
|
|
46
|
+
| HtCaptureUserInputNode
|
|
45
47
|
// | HtChannelConditionalNode
|
|
46
48
|
// | HtCountryConditionalNode
|
|
47
49
|
// | HtCustomConditionalNode
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FlowAiAgent } from './flow-ai-agent'
|
|
2
2
|
import { FlowBotAction } from './flow-bot-action'
|
|
3
|
+
import { FlowCaptureUserInput } from './flow-capture-user-input'
|
|
3
4
|
import { FlowCarousel } from './flow-carousel'
|
|
4
5
|
import { FlowChannelConditional } from './flow-channel-conditional'
|
|
5
6
|
import { FlowCountryConditional } from './flow-country-conditional'
|
|
@@ -25,6 +26,7 @@ export { FlowElement } from './flow-element'
|
|
|
25
26
|
export {
|
|
26
27
|
FlowAiAgent,
|
|
27
28
|
FlowBotAction,
|
|
29
|
+
FlowCaptureUserInput,
|
|
28
30
|
FlowCarousel,
|
|
29
31
|
FlowChannelConditional,
|
|
30
32
|
FlowCountryConditional,
|
|
@@ -60,5 +62,6 @@ export type FlowContent =
|
|
|
60
62
|
| FlowQueueStatusConditional
|
|
61
63
|
| FlowCustomConditional
|
|
62
64
|
| FlowGoToFlow
|
|
65
|
+
| FlowCaptureUserInput
|
|
63
66
|
|
|
64
67
|
export { DISABLED_MEMORY_LENGTH }
|
package/src/flow-factory.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
FlowWhatsappCtaUrlButtonNode,
|
|
22
22
|
FlowWhatsappTemplate,
|
|
23
23
|
} from './content-fields'
|
|
24
|
+
import { FlowCaptureUserInput } from './content-fields/flow-capture-user-input'
|
|
24
25
|
import {
|
|
25
26
|
HtFunctionNode,
|
|
26
27
|
HtNodeComponent,
|
|
@@ -94,6 +95,9 @@ export class FlowFactory {
|
|
|
94
95
|
case HtNodeWithContentType.WHATSAPP_TEMPLATE:
|
|
95
96
|
return FlowWhatsappTemplate.fromHubtypeCMS(hubtypeContent)
|
|
96
97
|
|
|
98
|
+
case HtNodeWithContentType.CAPTURE_USER_INPUT:
|
|
99
|
+
return FlowCaptureUserInput.fromHubtypeCMS(hubtypeContent)
|
|
100
|
+
|
|
97
101
|
default:
|
|
98
102
|
return undefined
|
|
99
103
|
}
|
package/src/index.ts
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
RatingSubmittedInfo,
|
|
37
37
|
TrackEventFunction,
|
|
38
38
|
} from './types'
|
|
39
|
-
import {
|
|
39
|
+
import { getNextPayloadByUserInput } from './user-input'
|
|
40
40
|
import { SmartIntentsInferenceConfig } from './user-input/smart-intent'
|
|
41
41
|
import { inputHasTextData, resolveGetAccessToken } from './utils'
|
|
42
42
|
|
|
@@ -109,13 +109,13 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
109
109
|
|
|
110
110
|
if (checkUserTextInput) {
|
|
111
111
|
const resolvedLocale = this.cmsApi.getResolvedLocale()
|
|
112
|
-
const
|
|
112
|
+
const nextPayload = await getNextPayloadByUserInput(
|
|
113
113
|
this.cmsApi,
|
|
114
114
|
resolvedLocale,
|
|
115
115
|
request as unknown as ActionRequest,
|
|
116
116
|
this.smartIntentsConfig
|
|
117
117
|
)
|
|
118
|
-
request.input.payload =
|
|
118
|
+
request.input.payload = nextPayload
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
this.updateRequestBeforeRoutes(request)
|
|
@@ -135,6 +135,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
private updateRequestBeforeRoutes(request: PluginPreRequest): void {
|
|
138
|
+
this.cmsApi.removeCaptureUserInputId()
|
|
138
139
|
if (request.input.payload) {
|
|
139
140
|
request.input.payload = this.removeSourceSuffix(request.input.payload)
|
|
140
141
|
|
package/src/tracking.ts
CHANGED
|
@@ -108,11 +108,11 @@ function getCommonFlowContentEventArgs(
|
|
|
108
108
|
|
|
109
109
|
export function getCommonFlowContentEventArgsForContentId(
|
|
110
110
|
request: ActionRequest,
|
|
111
|
-
|
|
111
|
+
id: string
|
|
112
112
|
): CommonFlowContentEventArgs {
|
|
113
113
|
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
|
|
114
114
|
const cmsApi = flowBuilderPlugin.cmsApi
|
|
115
|
-
const nodeContent = cmsApi.getNodeById<HtNodeWithContent>(
|
|
115
|
+
const nodeContent = cmsApi.getNodeById<HtNodeWithContent>(id)
|
|
116
116
|
|
|
117
117
|
return getCommonFlowContentEventArgs(request, nodeContent)
|
|
118
118
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { EventAction, EventCaptureUserInput } from '@botonic/core'
|
|
2
|
+
import { ActionRequest } from '@botonic/react'
|
|
3
|
+
import axios from 'axios'
|
|
4
|
+
|
|
5
|
+
import { FlowBuilderApi } from '../api'
|
|
6
|
+
import { FlowCaptureUserInput } from '../content-fields'
|
|
7
|
+
import {
|
|
8
|
+
HtAiValidationType,
|
|
9
|
+
HtCaptureUserInputNode,
|
|
10
|
+
} from '../content-fields/hubtype-fields'
|
|
11
|
+
import {
|
|
12
|
+
getCommonFlowContentEventArgsForContentId,
|
|
13
|
+
trackEvent,
|
|
14
|
+
} from '../tracking'
|
|
15
|
+
import { inputHasTextData } from '../utils'
|
|
16
|
+
|
|
17
|
+
interface AiCaptureResponseSuccess {
|
|
18
|
+
success: true
|
|
19
|
+
value: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface AiCaptureResponseFailure {
|
|
23
|
+
success: false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type AiCaptureResponse = AiCaptureResponseSuccess | AiCaptureResponseFailure
|
|
27
|
+
|
|
28
|
+
export class CaptureUserInputApi {
|
|
29
|
+
private cmsApi: FlowBuilderApi
|
|
30
|
+
private request: ActionRequest
|
|
31
|
+
|
|
32
|
+
constructor(cmsApi: FlowBuilderApi, request: ActionRequest) {
|
|
33
|
+
this.cmsApi = cmsApi
|
|
34
|
+
this.request = request
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getNextNodeId(): Promise<string | undefined> {
|
|
38
|
+
if (
|
|
39
|
+
inputHasTextData(this.request.input) &&
|
|
40
|
+
this.cmsApi.shouldCaptureUserInput()
|
|
41
|
+
) {
|
|
42
|
+
const captureUserInputNode = this.cmsApi.getCaptureUserInputNode()
|
|
43
|
+
if (!captureUserInputNode) {
|
|
44
|
+
return undefined
|
|
45
|
+
}
|
|
46
|
+
const captureUserInput =
|
|
47
|
+
FlowCaptureUserInput.fromHubtypeCMS(captureUserInputNode)
|
|
48
|
+
|
|
49
|
+
if (captureUserInput.aiValidationType === HtAiValidationType.NONE) {
|
|
50
|
+
this.cmsApi.setUserExtraDataVariable(
|
|
51
|
+
captureUserInputNode.content.field_name,
|
|
52
|
+
this.request.input.data as string
|
|
53
|
+
)
|
|
54
|
+
await this.trackUserInputCapture(captureUserInputNode, true)
|
|
55
|
+
return captureUserInput.captureSuccessId
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const aiCaptureResponse =
|
|
59
|
+
await this.getAiCaptureResponse(captureUserInputNode)
|
|
60
|
+
if (!aiCaptureResponse.success) {
|
|
61
|
+
await this.trackUserInputCapture(captureUserInputNode, false)
|
|
62
|
+
return captureUserInput.captureFailId
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.cmsApi.setUserExtraDataVariable(
|
|
66
|
+
captureUserInputNode.content.field_name,
|
|
67
|
+
aiCaptureResponse.value
|
|
68
|
+
)
|
|
69
|
+
await this.trackUserInputCapture(captureUserInputNode, true)
|
|
70
|
+
return captureUserInput.captureSuccessId
|
|
71
|
+
}
|
|
72
|
+
return undefined
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async getAiCaptureResponse(
|
|
76
|
+
captureUserInputNode: HtCaptureUserInputNode
|
|
77
|
+
): Promise<AiCaptureResponse> {
|
|
78
|
+
try {
|
|
79
|
+
const url = `${process.env.HUBTYPE_API_URL}/external/v1/capture_user_input/`
|
|
80
|
+
const data = {
|
|
81
|
+
field_name: captureUserInputNode.content.field_name,
|
|
82
|
+
validation_instructions:
|
|
83
|
+
captureUserInputNode.content.ai_validation_instructions,
|
|
84
|
+
user_input: this.request.input.data,
|
|
85
|
+
}
|
|
86
|
+
const config = {
|
|
87
|
+
headers: {
|
|
88
|
+
'Content-Type': 'application/json',
|
|
89
|
+
Authorization: `Bearer ${this.request.session._access_token}`,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const aiCaptureResponse = await axios.post<AiCaptureResponse>(
|
|
94
|
+
url,
|
|
95
|
+
data,
|
|
96
|
+
config
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
return aiCaptureResponse.data
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.warn('Error getting ai/capture_user_input', error)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async trackUserInputCapture(
|
|
110
|
+
captureUserInputNode: HtCaptureUserInputNode,
|
|
111
|
+
captureSuccess: boolean
|
|
112
|
+
): Promise<void> {
|
|
113
|
+
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
|
|
114
|
+
getCommonFlowContentEventArgsForContentId(
|
|
115
|
+
this.request,
|
|
116
|
+
captureUserInputNode.id
|
|
117
|
+
)
|
|
118
|
+
const event: EventCaptureUserInput = {
|
|
119
|
+
action: EventAction.CaptureUserInput,
|
|
120
|
+
flowThreadId,
|
|
121
|
+
flowId,
|
|
122
|
+
flowName,
|
|
123
|
+
flowNodeId,
|
|
124
|
+
flowNodeContentId,
|
|
125
|
+
flowNodeIsMeaningful: false,
|
|
126
|
+
fieldName: captureUserInputNode.content.field_name,
|
|
127
|
+
userInput: this.request.input.data as string,
|
|
128
|
+
captureSuccess,
|
|
129
|
+
messageId: this.request.input.message_id,
|
|
130
|
+
}
|
|
131
|
+
const { action, ...eventArgs } = event
|
|
132
|
+
await trackEvent(this.request, action, eventArgs)
|
|
133
|
+
}
|
|
134
|
+
}
|
package/src/user-input/index.ts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { ActionRequest } from '@botonic/react'
|
|
2
2
|
|
|
3
3
|
import { FlowBuilderApi } from '../api'
|
|
4
|
-
import {
|
|
5
|
-
HtKeywordNode,
|
|
6
|
-
HtSmartIntentNode,
|
|
7
|
-
} from '../content-fields/hubtype-fields'
|
|
8
4
|
import {
|
|
9
5
|
inputHasTextData,
|
|
10
6
|
isKeywordsAllowed,
|
|
11
7
|
isSmartIntentsAllowed,
|
|
12
8
|
} from '../utils'
|
|
9
|
+
import { CaptureUserInputApi } from './capture-user-input-api'
|
|
13
10
|
import { KeywordMatcher } from './keyword'
|
|
14
11
|
import { SmartIntentsApi, SmartIntentsInferenceConfig } from './smart-intent'
|
|
15
12
|
|
|
16
|
-
export async function
|
|
13
|
+
export async function getNextPayloadByUserInput(
|
|
17
14
|
cmsApi: FlowBuilderApi,
|
|
18
15
|
locale: string,
|
|
19
16
|
request: ActionRequest,
|
|
20
17
|
smartIntentsConfig: SmartIntentsInferenceConfig
|
|
21
|
-
): Promise<
|
|
18
|
+
): Promise<string | undefined> {
|
|
22
19
|
if (inputHasTextData(request.input)) {
|
|
20
|
+
if (cmsApi.shouldCaptureUserInput()) {
|
|
21
|
+
const captureUserInputApi = new CaptureUserInputApi(
|
|
22
|
+
cmsApi,
|
|
23
|
+
request as unknown as ActionRequest
|
|
24
|
+
)
|
|
25
|
+
return await captureUserInputApi.getNextNodeId()
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
if (isKeywordsAllowed(request)) {
|
|
24
29
|
const keywordMatcher = new KeywordMatcher({
|
|
25
30
|
cmsApi,
|
|
@@ -30,7 +35,7 @@ export async function getNodeByUserInput(
|
|
|
30
35
|
request.input.data!
|
|
31
36
|
)
|
|
32
37
|
if (keywordNode) {
|
|
33
|
-
return keywordNode
|
|
38
|
+
return cmsApi.getPayload(keywordNode.target)
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -42,7 +47,7 @@ export async function getNodeByUserInput(
|
|
|
42
47
|
)
|
|
43
48
|
const smartIntentNode = await smartIntentsApi.getNodeByInput()
|
|
44
49
|
if (smartIntentNode) {
|
|
45
|
-
return smartIntentNode
|
|
50
|
+
return cmsApi.getPayload(smartIntentNode.target)
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
}
|