@botonic/plugin-flow-builder 0.46.1 → 0.47.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-from-user-input.d.ts +3 -0
- package/lib/cjs/action/ai-agent-from-user-input.js +23 -0
- package/lib/cjs/action/ai-agent-from-user-input.js.map +1 -0
- package/lib/cjs/action/context.d.ts +11 -0
- package/lib/cjs/action/context.js +17 -0
- package/lib/cjs/action/context.js.map +1 -0
- package/lib/cjs/action/fallback.d.ts +1 -1
- package/lib/cjs/action/first-interaction.d.ts +1 -1
- package/lib/cjs/action/first-interaction.js +4 -4
- package/lib/cjs/action/first-interaction.js.map +1 -1
- package/lib/cjs/action/get-contents.d.ts +3 -0
- package/lib/cjs/action/get-contents.js +44 -0
- package/lib/cjs/action/get-contents.js.map +1 -0
- package/lib/cjs/action/index.d.ts +6 -15
- package/lib/cjs/action/index.js +31 -94
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.d.ts +1 -1
- package/lib/cjs/action/knowledge-bases.js +3 -3
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/action/payload.d.ts +1 -1
- package/lib/cjs/api.d.ts +0 -1
- package/lib/cjs/api.js +0 -7
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/content-fields/content-fields-base.d.ts +5 -4
- package/lib/cjs/content-fields/content-fields-base.js +7 -7
- package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-ai-agent.d.ts +14 -5
- package/lib/cjs/content-fields/flow-ai-agent.js +100 -17
- package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/cjs/content-fields/flow-bot-action.d.ts +4 -2
- package/lib/cjs/content-fields/flow-bot-action.js +10 -5
- package/lib/cjs/content-fields/flow-bot-action.js.map +1 -1
- package/lib/cjs/content-fields/flow-button.d.ts +5 -2
- package/lib/cjs/content-fields/flow-button.js +6 -2
- package/lib/cjs/content-fields/flow-button.js.map +1 -1
- package/lib/cjs/content-fields/flow-capture-user-input.d.ts +4 -3
- package/lib/cjs/content-fields/flow-capture-user-input.js +7 -5
- package/lib/cjs/content-fields/flow-capture-user-input.js.map +1 -1
- package/lib/cjs/content-fields/flow-carousel.d.ts +4 -3
- package/lib/cjs/content-fields/flow-carousel.js +11 -7
- package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
- package/lib/cjs/content-fields/flow-channel-conditional.d.ts +5 -4
- package/lib/cjs/content-fields/flow-channel-conditional.js +10 -7
- package/lib/cjs/content-fields/flow-channel-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-country-conditional.d.ts +5 -4
- package/lib/cjs/content-fields/flow-country-conditional.js +11 -7
- package/lib/cjs/content-fields/flow-country-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-custom-conditional.d.ts +5 -4
- package/lib/cjs/content-fields/flow-custom-conditional.js +11 -7
- package/lib/cjs/content-fields/flow-custom-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-element.d.ts +4 -4
- package/lib/cjs/content-fields/flow-element.js +7 -3
- package/lib/cjs/content-fields/flow-element.js.map +1 -1
- package/lib/cjs/content-fields/flow-go-to-flow.d.ts +3 -3
- package/lib/cjs/content-fields/flow-go-to-flow.js +7 -15
- package/lib/cjs/content-fields/flow-go-to-flow.js.map +1 -1
- package/lib/cjs/content-fields/flow-handoff.d.ts +5 -4
- package/lib/cjs/content-fields/flow-handoff.js +11 -7
- package/lib/cjs/content-fields/flow-handoff.js.map +1 -1
- package/lib/cjs/content-fields/flow-image.d.ts +4 -3
- package/lib/cjs/content-fields/flow-image.js +8 -4
- package/lib/cjs/content-fields/flow-image.js.map +1 -1
- package/lib/cjs/content-fields/flow-knowledge-base.d.ts +4 -3
- package/lib/cjs/content-fields/flow-knowledge-base.js +7 -3
- package/lib/cjs/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-queue-status-conditional.d.ts +3 -2
- package/lib/cjs/content-fields/flow-queue-status-conditional.js +7 -3
- package/lib/cjs/content-fields/flow-queue-status-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-rating.d.ts +4 -3
- package/lib/cjs/content-fields/flow-rating.js +13 -9
- package/lib/cjs/content-fields/flow-rating.js.map +1 -1
- package/lib/cjs/content-fields/flow-text.d.ts +4 -4
- package/lib/cjs/content-fields/flow-text.js +11 -6
- package/lib/cjs/content-fields/flow-text.js.map +1 -1
- package/lib/cjs/content-fields/flow-video.d.ts +4 -3
- package/lib/cjs/content-fields/flow-video.js +8 -4
- package/lib/cjs/content-fields/flow-video.js.map +1 -1
- package/lib/cjs/content-fields/flow-webview.d.ts +3 -2
- package/lib/cjs/content-fields/flow-webview.js +6 -3
- package/lib/cjs/content-fields/flow-webview.js.map +1 -1
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.d.ts +5 -3
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js +14 -10
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
- package/lib/cjs/content-fields/flow-whatsapp-template.d.ts +5 -3
- package/lib/cjs/content-fields/flow-whatsapp-template.js +26 -22
- package/lib/cjs/content-fields/flow-whatsapp-template.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +4 -3
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +6 -4
- 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.d.ts +4 -3
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +7 -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 +4 -3
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +10 -6
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/index.d.ts +3 -0
- package/lib/cjs/content-fields/whatsapp-button-list/index.js +10 -0
- package/lib/cjs/content-fields/whatsapp-button-list/index.js.map +1 -0
- package/lib/cjs/filters/index.d.ts +1 -0
- package/lib/cjs/filters/index.js +15 -0
- package/lib/cjs/filters/index.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +4 -8
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/structured-output/flow-builder-content.d.ts +16 -0
- package/lib/cjs/structured-output/flow-builder-content.js +12 -0
- package/lib/cjs/structured-output/flow-builder-content.js.map +1 -0
- package/lib/cjs/tracking.js +6 -6
- package/lib/cjs/tracking.js.map +1 -1
- package/lib/cjs/types.d.ts +2 -1
- package/lib/cjs/user-input/capture-user-input-api.js +4 -4
- package/lib/cjs/user-input/capture-user-input-api.js.map +1 -1
- package/lib/cjs/user-input/index.js +4 -4
- package/lib/cjs/user-input/index.js.map +1 -1
- package/lib/cjs/user-input/smart-intent.js +2 -2
- package/lib/cjs/user-input/smart-intent.js.map +1 -1
- package/lib/cjs/utils/ai-agent.d.ts +18 -0
- package/lib/cjs/utils/ai-agent.js +177 -0
- package/lib/cjs/utils/ai-agent.js.map +1 -0
- package/lib/cjs/utils/authentication.d.ts +2 -0
- package/lib/cjs/utils/authentication.js +21 -0
- package/lib/cjs/utils/authentication.js.map +1 -0
- package/lib/{esm/helpers.d.ts → cjs/utils/get-flow-builder-plugin.d.ts} +1 -1
- package/lib/cjs/{helpers.js → utils/get-flow-builder-plugin.js} +1 -1
- package/lib/cjs/utils/get-flow-builder-plugin.js.map +1 -0
- package/lib/cjs/{utils.d.ts → utils/input.d.ts} +1 -2
- package/lib/cjs/{utils.js → utils/input.js} +3 -21
- package/lib/cjs/utils/input.js.map +1 -0
- package/lib/esm/action/ai-agent-from-user-input.d.ts +3 -0
- package/lib/esm/action/ai-agent-from-user-input.js +23 -0
- package/lib/esm/action/ai-agent-from-user-input.js.map +1 -0
- package/lib/esm/action/context.d.ts +11 -0
- package/lib/esm/action/context.js +17 -0
- package/lib/esm/action/context.js.map +1 -0
- package/lib/esm/action/fallback.d.ts +1 -1
- package/lib/esm/action/first-interaction.d.ts +1 -1
- package/lib/esm/action/first-interaction.js +4 -4
- package/lib/esm/action/first-interaction.js.map +1 -1
- package/lib/esm/action/get-contents.d.ts +3 -0
- package/lib/esm/action/get-contents.js +44 -0
- package/lib/esm/action/get-contents.js.map +1 -0
- package/lib/esm/action/index.d.ts +6 -15
- package/lib/esm/action/index.js +31 -94
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.d.ts +1 -1
- package/lib/esm/action/knowledge-bases.js +3 -3
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/action/payload.d.ts +1 -1
- package/lib/esm/api.d.ts +0 -1
- package/lib/esm/api.js +0 -7
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/content-fields/content-fields-base.d.ts +5 -4
- package/lib/esm/content-fields/content-fields-base.js +7 -7
- package/lib/esm/content-fields/content-fields-base.js.map +1 -1
- package/lib/esm/content-fields/flow-ai-agent.d.ts +14 -5
- package/lib/esm/content-fields/flow-ai-agent.js +100 -17
- package/lib/esm/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/esm/content-fields/flow-bot-action.d.ts +4 -2
- package/lib/esm/content-fields/flow-bot-action.js +10 -5
- package/lib/esm/content-fields/flow-bot-action.js.map +1 -1
- package/lib/esm/content-fields/flow-button.d.ts +5 -2
- package/lib/esm/content-fields/flow-button.js +6 -2
- package/lib/esm/content-fields/flow-button.js.map +1 -1
- package/lib/esm/content-fields/flow-capture-user-input.d.ts +4 -3
- package/lib/esm/content-fields/flow-capture-user-input.js +7 -5
- package/lib/esm/content-fields/flow-capture-user-input.js.map +1 -1
- package/lib/esm/content-fields/flow-carousel.d.ts +4 -3
- package/lib/esm/content-fields/flow-carousel.js +11 -7
- package/lib/esm/content-fields/flow-carousel.js.map +1 -1
- package/lib/esm/content-fields/flow-channel-conditional.d.ts +5 -4
- package/lib/esm/content-fields/flow-channel-conditional.js +10 -7
- package/lib/esm/content-fields/flow-channel-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-country-conditional.d.ts +5 -4
- package/lib/esm/content-fields/flow-country-conditional.js +11 -7
- package/lib/esm/content-fields/flow-country-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-custom-conditional.d.ts +5 -4
- package/lib/esm/content-fields/flow-custom-conditional.js +11 -7
- package/lib/esm/content-fields/flow-custom-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-element.d.ts +4 -4
- package/lib/esm/content-fields/flow-element.js +7 -3
- package/lib/esm/content-fields/flow-element.js.map +1 -1
- package/lib/esm/content-fields/flow-go-to-flow.d.ts +3 -3
- package/lib/esm/content-fields/flow-go-to-flow.js +7 -15
- package/lib/esm/content-fields/flow-go-to-flow.js.map +1 -1
- package/lib/esm/content-fields/flow-handoff.d.ts +5 -4
- package/lib/esm/content-fields/flow-handoff.js +11 -7
- package/lib/esm/content-fields/flow-handoff.js.map +1 -1
- package/lib/esm/content-fields/flow-image.d.ts +4 -3
- package/lib/esm/content-fields/flow-image.js +8 -4
- package/lib/esm/content-fields/flow-image.js.map +1 -1
- package/lib/esm/content-fields/flow-knowledge-base.d.ts +4 -3
- package/lib/esm/content-fields/flow-knowledge-base.js +7 -3
- package/lib/esm/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/esm/content-fields/flow-queue-status-conditional.d.ts +3 -2
- package/lib/esm/content-fields/flow-queue-status-conditional.js +7 -3
- package/lib/esm/content-fields/flow-queue-status-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-rating.d.ts +4 -3
- package/lib/esm/content-fields/flow-rating.js +13 -9
- package/lib/esm/content-fields/flow-rating.js.map +1 -1
- package/lib/esm/content-fields/flow-text.d.ts +4 -4
- package/lib/esm/content-fields/flow-text.js +11 -6
- package/lib/esm/content-fields/flow-text.js.map +1 -1
- package/lib/esm/content-fields/flow-video.d.ts +4 -3
- package/lib/esm/content-fields/flow-video.js +8 -4
- package/lib/esm/content-fields/flow-video.js.map +1 -1
- package/lib/esm/content-fields/flow-webview.d.ts +3 -2
- package/lib/esm/content-fields/flow-webview.js +6 -3
- package/lib/esm/content-fields/flow-webview.js.map +1 -1
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.d.ts +5 -3
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js +14 -10
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
- package/lib/esm/content-fields/flow-whatsapp-template.d.ts +5 -3
- package/lib/esm/content-fields/flow-whatsapp-template.js +26 -22
- package/lib/esm/content-fields/flow-whatsapp-template.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +4 -3
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +6 -4
- 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.d.ts +4 -3
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +7 -5
- 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 +4 -3
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +10 -6
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/index.d.ts +3 -0
- package/lib/esm/content-fields/whatsapp-button-list/index.js +10 -0
- package/lib/esm/content-fields/whatsapp-button-list/index.js.map +1 -0
- package/lib/esm/filters/index.d.ts +1 -0
- package/lib/esm/filters/index.js +15 -0
- package/lib/esm/filters/index.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +4 -8
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/structured-output/flow-builder-content.d.ts +16 -0
- package/lib/esm/structured-output/flow-builder-content.js +12 -0
- package/lib/esm/structured-output/flow-builder-content.js.map +1 -0
- package/lib/esm/tracking.js +6 -6
- package/lib/esm/tracking.js.map +1 -1
- package/lib/esm/types.d.ts +2 -1
- package/lib/esm/user-input/capture-user-input-api.js +4 -4
- package/lib/esm/user-input/capture-user-input-api.js.map +1 -1
- package/lib/esm/user-input/index.js +4 -4
- package/lib/esm/user-input/index.js.map +1 -1
- package/lib/esm/user-input/smart-intent.js +2 -2
- package/lib/esm/user-input/smart-intent.js.map +1 -1
- package/lib/esm/utils/ai-agent.d.ts +18 -0
- package/lib/esm/utils/ai-agent.js +177 -0
- package/lib/esm/utils/ai-agent.js.map +1 -0
- package/lib/esm/utils/authentication.d.ts +2 -0
- package/lib/esm/utils/authentication.js +21 -0
- package/lib/esm/utils/authentication.js.map +1 -0
- package/lib/{cjs/helpers.d.ts → esm/utils/get-flow-builder-plugin.d.ts} +1 -1
- package/lib/esm/{helpers.js → utils/get-flow-builder-plugin.js} +1 -1
- package/lib/esm/utils/get-flow-builder-plugin.js.map +1 -0
- package/lib/esm/{utils.d.ts → utils/input.d.ts} +1 -2
- package/lib/esm/{utils.js → utils/input.js} +3 -21
- package/lib/esm/utils/input.js.map +1 -0
- package/package.json +2 -2
- package/src/action/ai-agent-from-user-input.ts +35 -0
- package/src/action/context.ts +29 -0
- package/src/action/fallback.ts +1 -1
- package/src/action/first-interaction.ts +4 -4
- package/src/action/get-contents.ts +51 -0
- package/src/action/index.tsx +42 -136
- package/src/action/knowledge-bases.ts +5 -2
- package/src/action/payload.ts +1 -1
- package/src/api.ts +0 -8
- package/src/content-fields/content-fields-base.ts +11 -9
- package/src/content-fields/flow-ai-agent.tsx +166 -28
- package/src/content-fields/flow-bot-action.tsx +17 -6
- package/src/content-fields/flow-button.tsx +10 -3
- package/src/content-fields/flow-capture-user-input.tsx +9 -6
- package/src/content-fields/flow-carousel.tsx +21 -11
- package/src/content-fields/flow-channel-conditional.tsx +16 -9
- package/src/content-fields/flow-country-conditional.tsx +17 -9
- package/src/content-fields/flow-custom-conditional.tsx +17 -9
- package/src/content-fields/flow-element.tsx +10 -11
- package/src/content-fields/flow-go-to-flow.tsx +10 -24
- package/src/content-fields/flow-handoff.tsx +21 -10
- package/src/content-fields/flow-image.tsx +11 -5
- package/src/content-fields/flow-knowledge-base.tsx +11 -5
- package/src/content-fields/flow-queue-status-conditional.tsx +13 -5
- package/src/content-fields/flow-rating.tsx +16 -16
- package/src/content-fields/flow-text.tsx +14 -7
- package/src/content-fields/flow-video.tsx +11 -5
- package/src/content-fields/flow-webview.tsx +12 -5
- package/src/content-fields/flow-whatsapp-cta-url-button.tsx +16 -12
- package/src/content-fields/flow-whatsapp-template.tsx +28 -24
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx +8 -5
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx +8 -6
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +15 -15
- package/src/content-fields/whatsapp-button-list/index.ts +3 -0
- package/src/filters/index.ts +20 -0
- package/src/index.ts +3 -14
- package/src/structured-output/flow-builder-content.ts +17 -0
- package/src/tracking.ts +1 -1
- package/src/types.ts +2 -2
- package/src/user-input/capture-user-input-api.ts +2 -2
- package/src/user-input/index.ts +1 -1
- package/src/user-input/smart-intent.ts +1 -1
- package/src/utils/ai-agent.ts +233 -0
- package/src/utils/authentication.ts +23 -0
- package/src/{helpers.ts → utils/get-flow-builder-plugin.ts} +1 -1
- package/src/{utils.ts → utils/input.ts} +3 -23
- package/lib/cjs/action/ai-agent.d.ts +0 -3
- package/lib/cjs/action/ai-agent.js +0 -67
- package/lib/cjs/action/ai-agent.js.map +0 -1
- package/lib/cjs/helpers.js.map +0 -1
- package/lib/cjs/utils.js.map +0 -1
- package/lib/esm/action/ai-agent.d.ts +0 -3
- package/lib/esm/action/ai-agent.js +0 -67
- package/lib/esm/action/ai-agent.js.map +0 -1
- package/lib/esm/helpers.js.map +0 -1
- package/lib/esm/utils.js.map +0 -1
- package/src/action/ai-agent.ts +0 -102
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/utils/input.ts"],"names":[],"mappings":";;AAMA,4DAMC;AAED,kDAUC;AAWD,8CAEC;AAED,sDAEC;AAED,0DAEC;AA7CD,wCAAiD;AAIjD,uEAAgE;AAEhE,SAAgB,wBAAwB,CAAC,KAAY;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,YAAK,CAAC,IAAI,CAAA;IACpE,MAAM,gBAAgB,GACpB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,YAAK,CAAC,KAAK,CAAA;IAEzD,OAAO,WAAW,IAAI,gBAAgB,CAAA;AACxC,CAAC;AAED,SAAgB,mBAAmB,CAAC,KAAY;IAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,YAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC,IAAI,CAAA;IACnB,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,YAAK,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC,UAAU,CAAA;IACzB,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAA;IAC5D,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAS,YAAY,CACnB,OAAsB,EACtB,OAAgC;IAEhC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACrD,MAAM,iBAAiB,GAAG,IAAA,8CAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,OAAO,CAAC,SAAS,IAAI,CAAC,SAAS,IAAI,iBAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;AAC5E,CAAC;AAED,SAAgB,iBAAiB,CAAC,OAAsB;IACtD,OAAO,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;AAC/C,CAAC;AAED,SAAgB,qBAAqB,CAAC,OAAsB;IAC1D,OAAO,YAAY,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAA;AACnD,CAAC;AAED,SAAgB,uBAAuB,CAAC,OAAsB;IAC5D,OAAO,YAAY,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAA;AACrD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/plugin-flow-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.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",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"format": "biome format --write src/ tests/"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@botonic/react": "^0.
|
|
18
|
+
"@botonic/react": "^0.47.0",
|
|
19
19
|
"axios": "^1.13.6",
|
|
20
20
|
"uuid": "^10.0.0"
|
|
21
21
|
},
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { FlowContent } from '../content-fields/index'
|
|
2
|
+
import { splitAiAgentContents } from '../utils/ai-agent'
|
|
3
|
+
import type { FlowBuilderContext } from './context'
|
|
4
|
+
|
|
5
|
+
export async function getContentsByAiAgentFromUserInput({
|
|
6
|
+
cmsApi,
|
|
7
|
+
flowBuilderPlugin,
|
|
8
|
+
request,
|
|
9
|
+
}: FlowBuilderContext): Promise<FlowContent[]> {
|
|
10
|
+
const startNodeAiAgentFlow = cmsApi.getStartNodeAiAgentFlow()
|
|
11
|
+
const isAiAgentEnabled = cmsApi.isAiAgentEnabled()
|
|
12
|
+
if (!startNodeAiAgentFlow || !isAiAgentEnabled) {
|
|
13
|
+
return []
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const contents =
|
|
17
|
+
await flowBuilderPlugin.getContentsByNode(startNodeAiAgentFlow)
|
|
18
|
+
|
|
19
|
+
const splitContents = splitAiAgentContents(contents)
|
|
20
|
+
if (!splitContents) {
|
|
21
|
+
return []
|
|
22
|
+
}
|
|
23
|
+
const { aiAgentContent, contentsBeforeAiAgent } = splitContents
|
|
24
|
+
|
|
25
|
+
const aiAgentResponse = await aiAgentContent.resolveAIAgentResponse(
|
|
26
|
+
request,
|
|
27
|
+
contentsBeforeAiAgent
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if (!aiAgentResponse || aiAgentResponse.exit) {
|
|
31
|
+
return []
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return contents
|
|
35
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BotContext } from '@botonic/core'
|
|
2
|
+
|
|
3
|
+
import type { FlowBuilderApi } from '../api'
|
|
4
|
+
import type BotonicPluginFlowBuilder from '../index'
|
|
5
|
+
import { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'
|
|
6
|
+
|
|
7
|
+
export interface FlowBuilderContext {
|
|
8
|
+
cmsApi: FlowBuilderApi
|
|
9
|
+
flowBuilderPlugin: BotonicPluginFlowBuilder
|
|
10
|
+
request: BotContext
|
|
11
|
+
resolvedLocale: string
|
|
12
|
+
contentID?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getFlowBuilderActionContext(
|
|
16
|
+
request: BotContext,
|
|
17
|
+
contentID?: string
|
|
18
|
+
): FlowBuilderContext {
|
|
19
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
|
|
20
|
+
const cmsApi = flowBuilderPlugin.cmsApi
|
|
21
|
+
const resolvedLocale = flowBuilderPlugin.cmsApi.getResolvedLocale()
|
|
22
|
+
return {
|
|
23
|
+
cmsApi,
|
|
24
|
+
flowBuilderPlugin,
|
|
25
|
+
request,
|
|
26
|
+
resolvedLocale,
|
|
27
|
+
contentID,
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/action/fallback.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { FlowBuilderApi } from '../api'
|
|
|
2
2
|
import { MAIN_FLOW_NAME } from '../constants'
|
|
3
3
|
import { FlowBotAction, type FlowContent } from '../content-fields'
|
|
4
4
|
import type BotonicPluginFlowBuilder from '../index'
|
|
5
|
-
import { inputHasTextOrTranscript } from '../utils'
|
|
6
|
-
import {
|
|
7
|
-
import type { FlowBuilderContext } from './
|
|
5
|
+
import { inputHasTextOrTranscript } from '../utils/input'
|
|
6
|
+
import { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'
|
|
7
|
+
import type { FlowBuilderContext } from './context'
|
|
8
8
|
import { getContentsByKnowledgeBase } from './knowledge-bases'
|
|
9
9
|
import { getContentsByPayload } from './payload'
|
|
10
10
|
|
|
@@ -100,7 +100,7 @@ async function getContentsByUserInput(
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if (!flowBuilderPlugin.disableAIAgentInFirstInteraction) {
|
|
103
|
-
const contentsByAiAgent = await
|
|
103
|
+
const contentsByAiAgent = await getContentsByAiAgentFromUserInput(context)
|
|
104
104
|
return contentsByAiAgent
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type BotContext, INPUT } from '@botonic/core'
|
|
2
|
+
import { EMPTY_PAYLOAD } from '../constants'
|
|
3
|
+
import type { FlowContent } from '../content-fields'
|
|
4
|
+
import { inputHasTextOrTranscript } from '../utils/input'
|
|
5
|
+
import { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'
|
|
6
|
+
import { getFlowBuilderActionContext } from './context'
|
|
7
|
+
import { getContentsByFallback } from './fallback'
|
|
8
|
+
import { getContentsByFirstInteraction } from './first-interaction'
|
|
9
|
+
import { getContentsByKnowledgeBase } from './knowledge-bases'
|
|
10
|
+
import { getContentsByPayload } from './payload'
|
|
11
|
+
|
|
12
|
+
export async function getContents(
|
|
13
|
+
botContext: BotContext,
|
|
14
|
+
contentID?: string
|
|
15
|
+
): Promise<FlowContent[]> {
|
|
16
|
+
const context = getFlowBuilderActionContext(botContext, contentID)
|
|
17
|
+
|
|
18
|
+
if (botContext.session.is_first_interaction) {
|
|
19
|
+
return await getContentsByFirstInteraction(context)
|
|
20
|
+
}
|
|
21
|
+
// TODO: Add needed logic when we can define contents for multi locale queue position message
|
|
22
|
+
if (botContext.input.type === INPUT.EVENT_QUEUE_POSITION_CHANGED) {
|
|
23
|
+
return []
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (botContext.input.payload?.startsWith(EMPTY_PAYLOAD)) {
|
|
27
|
+
botContext.input.payload = undefined
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (botContext.input.payload || contentID) {
|
|
31
|
+
const contentsByPayload = await getContentsByPayload(context)
|
|
32
|
+
if (contentsByPayload.length > 0) {
|
|
33
|
+
return contentsByPayload
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return await getContentsByFallback(context)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (inputHasTextOrTranscript(botContext.input)) {
|
|
40
|
+
const aiAgentContents = await getContentsByAiAgentFromUserInput(context)
|
|
41
|
+
if (aiAgentContents.length > 0) {
|
|
42
|
+
return aiAgentContents
|
|
43
|
+
}
|
|
44
|
+
const knowledgeBaseContents = await getContentsByKnowledgeBase(context)
|
|
45
|
+
if (knowledgeBaseContents.length > 0) {
|
|
46
|
+
return knowledgeBaseContents
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return await getContentsByFallback(context)
|
|
51
|
+
}
|
package/src/action/index.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type BotContext,
|
|
1
|
+
import { type BotContext, isDev, isWebchat } from '@botonic/core'
|
|
2
2
|
import {
|
|
3
|
-
type ActionRequest,
|
|
4
3
|
Multichannel,
|
|
5
4
|
RequestContext,
|
|
6
5
|
WebchatSettings,
|
|
@@ -8,19 +7,12 @@ import {
|
|
|
8
7
|
} from '@botonic/react'
|
|
9
8
|
import React from 'react'
|
|
10
9
|
|
|
11
|
-
import type
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { ContentFilterExecutor } from '../filters'
|
|
16
|
-
import { getFlowBuilderPlugin } from '../helpers'
|
|
17
|
-
import type BotonicPluginFlowBuilder from '../index'
|
|
18
|
-
import { inputHasTextOrTranscript } from '../utils'
|
|
19
|
-
import { getContentsByAiAgent } from './ai-agent'
|
|
20
|
-
import { getContentsByFallback } from './fallback'
|
|
10
|
+
import { FlowAiAgent, type FlowContent } from '../content-fields'
|
|
11
|
+
import { filterContents } from '../filters'
|
|
12
|
+
import { splitAiAgentContents } from '../utils/ai-agent'
|
|
13
|
+
import { getFlowBuilderActionContext } from './context'
|
|
21
14
|
import { getContentsByFirstInteraction } from './first-interaction'
|
|
22
|
-
import {
|
|
23
|
-
import { getContentsByPayload } from './payload'
|
|
15
|
+
import { getContents } from './get-contents'
|
|
24
16
|
|
|
25
17
|
export type FlowBuilderActionProps = {
|
|
26
18
|
contents: FlowContent[]
|
|
@@ -32,62 +24,60 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
|
32
24
|
declare context: React.ContextType<typeof RequestContext>
|
|
33
25
|
|
|
34
26
|
static async executeConversationStart(
|
|
35
|
-
|
|
27
|
+
botContext: BotContext
|
|
36
28
|
): Promise<FlowBuilderActionProps> {
|
|
37
|
-
const context =
|
|
29
|
+
const context = getFlowBuilderActionContext(botContext)
|
|
38
30
|
const contents = await getContentsByFirstInteraction(context)
|
|
39
|
-
|
|
40
|
-
await FlowBuilderAction.
|
|
41
|
-
|
|
31
|
+
|
|
32
|
+
const filteredContents = await FlowBuilderAction.prepareContentsToRender(
|
|
33
|
+
botContext,
|
|
34
|
+
contents
|
|
35
|
+
)
|
|
42
36
|
|
|
43
37
|
return { contents: filteredContents }
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
static async botonicInit(
|
|
47
|
-
|
|
41
|
+
botContext: BotContext,
|
|
48
42
|
contentID?: string
|
|
49
43
|
): Promise<FlowBuilderActionProps> {
|
|
50
|
-
const contents = await getContents(
|
|
51
|
-
const filteredContents = await filterContents(request, contents)
|
|
52
|
-
await FlowBuilderAction.trackAllContents(request, filteredContents)
|
|
53
|
-
await FlowBuilderAction.doHandoffAndBotActions(request, filteredContents)
|
|
44
|
+
const contents = await getContents(botContext, contentID)
|
|
54
45
|
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
const contentsToRender = await FlowBuilderAction.prepareContentsToRender(
|
|
47
|
+
botContext,
|
|
48
|
+
contents
|
|
49
|
+
)
|
|
57
50
|
|
|
58
|
-
|
|
59
|
-
request: ActionRequest,
|
|
60
|
-
contents: FlowContent[]
|
|
61
|
-
) {
|
|
62
|
-
for (const content of contents) {
|
|
63
|
-
await content.trackFlow(request)
|
|
64
|
-
}
|
|
51
|
+
return { contents: contentsToRender }
|
|
65
52
|
}
|
|
66
53
|
|
|
67
|
-
static async
|
|
68
|
-
|
|
54
|
+
static async prepareContentsToRender(
|
|
55
|
+
botContext: BotContext,
|
|
69
56
|
contents: FlowContent[]
|
|
70
57
|
) {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
const filteredContents = await filterContents(botContext, contents)
|
|
59
|
+
|
|
60
|
+
for (const content of filteredContents) {
|
|
61
|
+
if (content instanceof FlowAiAgent) {
|
|
62
|
+
const splitContents = splitAiAgentContents(filteredContents)
|
|
63
|
+
if (!splitContents) {
|
|
64
|
+
continue
|
|
65
|
+
}
|
|
66
|
+
const { contentsBeforeAiAgent } = splitContents
|
|
67
|
+
await content.processContent(botContext, contentsBeforeAiAgent)
|
|
68
|
+
} else {
|
|
69
|
+
await content.processContent(botContext)
|
|
70
|
+
}
|
|
76
71
|
}
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
content => content instanceof FlowBotAction
|
|
80
|
-
) as FlowBotAction
|
|
81
|
-
if (botActionContent) {
|
|
82
|
-
botActionContent.doBotAction(request)
|
|
83
|
-
}
|
|
73
|
+
return filteredContents
|
|
84
74
|
}
|
|
85
75
|
|
|
86
76
|
render(): JSX.Element | JSX.Element[] {
|
|
87
77
|
const { contents, webchatSettingsParams } = this.props
|
|
88
|
-
const
|
|
78
|
+
const botContext = this.context as BotContext
|
|
89
79
|
const shouldSendWebchatSettings =
|
|
90
|
-
(isWebchat(
|
|
80
|
+
(isWebchat(botContext.session) || isDev(botContext.session)) &&
|
|
91
81
|
!!webchatSettingsParams
|
|
92
82
|
|
|
93
83
|
return (
|
|
@@ -95,7 +85,7 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
|
95
85
|
{shouldSendWebchatSettings && (
|
|
96
86
|
<WebchatSettings {...webchatSettingsParams} />
|
|
97
87
|
)}
|
|
98
|
-
{contents.map(content => content.toBotonic(
|
|
88
|
+
{contents.map(content => content.toBotonic(botContext))}
|
|
99
89
|
</>
|
|
100
90
|
)
|
|
101
91
|
}
|
|
@@ -104,9 +94,9 @@ export class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
|
|
|
104
94
|
export class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
|
105
95
|
render(): JSX.Element | JSX.Element[] {
|
|
106
96
|
const { contents, webchatSettingsParams } = this.props
|
|
107
|
-
const
|
|
97
|
+
const botContext = this.context as BotContext
|
|
108
98
|
const shouldSendWebchatSettings =
|
|
109
|
-
(isWebchat(
|
|
99
|
+
(isWebchat(botContext.session) || isDev(botContext.session)) &&
|
|
110
100
|
!!webchatSettingsParams
|
|
111
101
|
|
|
112
102
|
return (
|
|
@@ -114,92 +104,8 @@ export class FlowBuilderMultichannelAction extends FlowBuilderAction {
|
|
|
114
104
|
{shouldSendWebchatSettings && (
|
|
115
105
|
<WebchatSettings {...webchatSettingsParams} />
|
|
116
106
|
)}
|
|
117
|
-
{contents.map(content => content.toBotonic(
|
|
107
|
+
{contents.map(content => content.toBotonic(botContext))}
|
|
118
108
|
</Multichannel>
|
|
119
109
|
)
|
|
120
110
|
}
|
|
121
111
|
}
|
|
122
|
-
|
|
123
|
-
async function getContents(
|
|
124
|
-
request: ActionRequest,
|
|
125
|
-
contentID?: string
|
|
126
|
-
): Promise<FlowContent[]> {
|
|
127
|
-
const context = getContext(request, contentID)
|
|
128
|
-
|
|
129
|
-
if (request.session.is_first_interaction) {
|
|
130
|
-
return await getContentsByFirstInteraction(context)
|
|
131
|
-
}
|
|
132
|
-
// TODO: Add needed logic when we can define contents for multi locale queue position message
|
|
133
|
-
if (request.input.type === INPUT.EVENT_QUEUE_POSITION_CHANGED) {
|
|
134
|
-
return []
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (request.input.payload?.startsWith(EMPTY_PAYLOAD)) {
|
|
138
|
-
request.input.payload = undefined
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (request.input.payload || contentID) {
|
|
142
|
-
const contentsByPayload = await getContentsByPayload(context)
|
|
143
|
-
if (contentsByPayload.length > 0) {
|
|
144
|
-
return contentsByPayload
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return await getContentsByFallback(context)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (inputHasTextOrTranscript(request.input)) {
|
|
151
|
-
const aiAgentContents = await getContentsByAiAgent(context)
|
|
152
|
-
if (aiAgentContents.length > 0) {
|
|
153
|
-
return aiAgentContents
|
|
154
|
-
}
|
|
155
|
-
const knowledgeBaseContents = await getContentsByKnowledgeBase(context)
|
|
156
|
-
if (knowledgeBaseContents.length > 0) {
|
|
157
|
-
return knowledgeBaseContents
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return await getContentsByFallback(context)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
async function filterContents(
|
|
165
|
-
request: BotContext,
|
|
166
|
-
contents: FlowContent[]
|
|
167
|
-
): Promise<FlowContent[]> {
|
|
168
|
-
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
|
|
169
|
-
const contentFilters = flowBuilderPlugin.contentFilters
|
|
170
|
-
const contentFilterExecutor = new ContentFilterExecutor({
|
|
171
|
-
filters: contentFilters,
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
const filteredContents: FlowContent[] = []
|
|
175
|
-
for (const content of contents) {
|
|
176
|
-
const filteredContent = await contentFilterExecutor.filter(request, content)
|
|
177
|
-
filteredContents.push(filteredContent)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return filteredContents
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export interface FlowBuilderContext {
|
|
184
|
-
cmsApi: FlowBuilderApi
|
|
185
|
-
flowBuilderPlugin: BotonicPluginFlowBuilder
|
|
186
|
-
request: ActionRequest
|
|
187
|
-
resolvedLocale: string
|
|
188
|
-
contentID?: string
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function getContext(
|
|
192
|
-
request: ActionRequest,
|
|
193
|
-
contentID?: string
|
|
194
|
-
): FlowBuilderContext {
|
|
195
|
-
const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)
|
|
196
|
-
const cmsApi = flowBuilderPlugin.cmsApi
|
|
197
|
-
const resolvedLocale = flowBuilderPlugin.cmsApi.getResolvedLocale()
|
|
198
|
-
return {
|
|
199
|
-
cmsApi,
|
|
200
|
-
flowBuilderPlugin,
|
|
201
|
-
request,
|
|
202
|
-
resolvedLocale,
|
|
203
|
-
contentID,
|
|
204
|
-
}
|
|
205
|
-
}
|
|
@@ -17,8 +17,11 @@ import {
|
|
|
17
17
|
trackEvent,
|
|
18
18
|
} from '../tracking'
|
|
19
19
|
import type { KnowledgeBaseFunction } from '../types'
|
|
20
|
-
import {
|
|
21
|
-
|
|
20
|
+
import {
|
|
21
|
+
inputHasTextOrTranscript,
|
|
22
|
+
isKnowledgeBasesAllowed,
|
|
23
|
+
} from '../utils/input'
|
|
24
|
+
import type { FlowBuilderContext } from './context'
|
|
22
25
|
|
|
23
26
|
export async function getContentsByKnowledgeBase({
|
|
24
27
|
cmsApi,
|
package/src/action/payload.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import type { FlowContent } from '../content-fields'
|
|
10
10
|
import type { HtNodeWithContent } from '../content-fields/hubtype-fields'
|
|
11
11
|
import { trackEvent } from '../tracking'
|
|
12
|
-
import type { FlowBuilderContext } from './
|
|
12
|
+
import type { FlowBuilderContext } from './context'
|
|
13
13
|
|
|
14
14
|
export async function getContentsByPayload(
|
|
15
15
|
context: FlowBuilderContext
|
package/src/api.ts
CHANGED
|
@@ -204,14 +204,6 @@ export class FlowBuilderApi {
|
|
|
204
204
|
return UUID_REGEXP.test(str)
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
isGoToFlow(id: string): boolean {
|
|
208
|
-
if (!this.isUUID(id)) {
|
|
209
|
-
return false
|
|
210
|
-
}
|
|
211
|
-
const node = this.getNodeById(id)
|
|
212
|
-
return node?.type === HtNodeWithContentType.GO_TO_FLOW
|
|
213
|
-
}
|
|
214
|
-
|
|
215
207
|
createPayloadWithParams(botActionNode: HtBotActionNode): string {
|
|
216
208
|
const payloadId = botActionNode.content.payload_id
|
|
217
209
|
const payloadNode = this.getNodeById<HtPayloadNode>(payloadId)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BotContext } from '@botonic/core'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
ACCESS_TOKEN_VARIABLE_KEY,
|
|
@@ -18,7 +18,9 @@ export abstract class ContentFieldsBase {
|
|
|
18
18
|
|
|
19
19
|
constructor(public readonly id: string) {}
|
|
20
20
|
|
|
21
|
-
abstract trackFlow(
|
|
21
|
+
abstract trackFlow(botContext: BotContext): Promise<void>
|
|
22
|
+
|
|
23
|
+
abstract processContent(botContext: BotContext): Promise<void>
|
|
22
24
|
|
|
23
25
|
static getTextByLocale(locale: string, text: HtTextLocale[]): string {
|
|
24
26
|
const result = text.find(t => t.locale === locale)
|
|
@@ -42,17 +44,17 @@ export abstract class ContentFieldsBase {
|
|
|
42
44
|
return queues.find(queue => queue.locale === locale)
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
replaceVariables(text: string,
|
|
47
|
+
replaceVariables(text: string, botContext: BotContext): string {
|
|
46
48
|
const matches = text.match(VARIABLE_PATTERN_GLOBAL)
|
|
47
49
|
|
|
48
50
|
let replacedText = text
|
|
49
|
-
if (matches &&
|
|
51
|
+
if (matches && botContext) {
|
|
50
52
|
matches.forEach(match => {
|
|
51
53
|
// remove \\ ( escape for _ ) added by text node with markdown
|
|
52
54
|
const keyPath = match.slice(1, -1).replaceAll('\\', '')
|
|
53
55
|
const botVariable = keyPath.endsWith(ACCESS_TOKEN_VARIABLE_KEY)
|
|
54
56
|
? match
|
|
55
|
-
: this.getValueFromKeyPath(
|
|
57
|
+
: this.getValueFromKeyPath(botContext, keyPath)
|
|
56
58
|
// TODO In local if change variable and render multiple times the value is always the last update
|
|
57
59
|
replacedText = replacedText.replace(
|
|
58
60
|
match,
|
|
@@ -64,10 +66,10 @@ export abstract class ContentFieldsBase {
|
|
|
64
66
|
return replacedText
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
getValueFromKeyPath(
|
|
69
|
+
getValueFromKeyPath(botContext: BotContext, keyPath: string): any {
|
|
68
70
|
if (keyPath.startsWith('session.user.contact_info.')) {
|
|
69
71
|
const name = keyPath.split('.').at(-1)
|
|
70
|
-
return
|
|
72
|
+
return botContext.session.user.contact_info?.find(
|
|
71
73
|
contact => contact.name === name
|
|
72
74
|
)?.value
|
|
73
75
|
}
|
|
@@ -75,14 +77,14 @@ export abstract class ContentFieldsBase {
|
|
|
75
77
|
if (keyPath.startsWith('input.') || keyPath.startsWith('session.')) {
|
|
76
78
|
return keyPath
|
|
77
79
|
.split('.')
|
|
78
|
-
.reduce((object, key) => this.resolveObjectKey(object, key),
|
|
80
|
+
.reduce((object, key) => this.resolveObjectKey(object, key), botContext)
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
return keyPath
|
|
82
84
|
.split('.')
|
|
83
85
|
.reduce(
|
|
84
86
|
(object, key) => this.resolveObjectKey(object, key),
|
|
85
|
-
|
|
87
|
+
botContext.session.user.extra_data
|
|
86
88
|
)
|
|
87
89
|
}
|
|
88
90
|
|