@botonic/plugin-flow-builder 0.57.0-rslib-esm.0 → 0.57.0-rslib-esm.2
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/README.md +1 -1
- package/lib/action/ai-agent-from-user-input.js.map +1 -0
- package/lib/action/context.js.map +1 -0
- package/lib/action/fallback.js.map +1 -0
- package/lib/action/first-interaction.js.map +1 -0
- package/lib/action/get-contents.js.map +1 -0
- package/lib/action/index.js.map +1 -0
- package/lib/action/payload.js.map +1 -0
- package/lib/api.js.map +1 -0
- package/lib/constants.js.map +1 -0
- package/lib/content-fields/content-fields-base.js.map +1 -0
- package/lib/content-fields/custom-conditional/custom-conditional-v2-evaluators.js.map +1 -0
- package/lib/content-fields/custom-conditional/custom-conditional-v2-resolver.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/custom-conditional/flow-custom-condition-v2.d.ts +1 -1
- package/lib/content-fields/custom-conditional/flow-custom-condition-v2.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-ai-agent-base.js +6 -0
- package/lib/content-fields/flow-ai-agent-base.js.map +1 -0
- package/lib/content-fields/flow-ai-agent-router.js.map +1 -0
- package/lib/content-fields/flow-ai-agent.js.map +1 -0
- package/lib/content-fields/flow-bot-action.js.map +1 -0
- package/lib/content-fields/flow-button.js.map +1 -0
- package/lib/content-fields/flow-capture-user-input.js.map +1 -0
- package/lib/content-fields/flow-carousel.js.map +1 -0
- package/lib/content-fields/flow-channel-conditional.js.map +1 -0
- package/lib/content-fields/flow-country-conditional.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-custom-conditional.d.ts +1 -1
- package/lib/content-fields/flow-custom-conditional.js.map +1 -0
- package/lib/content-fields/flow-element.js.map +1 -0
- package/lib/content-fields/flow-go-to-flow.js.map +1 -0
- package/lib/content-fields/flow-handoff.js.map +1 -0
- package/lib/content-fields/flow-image.js.map +1 -0
- package/lib/content-fields/flow-queue-status-conditional.js.map +1 -0
- package/lib/content-fields/flow-rating.js.map +1 -0
- package/lib/content-fields/flow-text.js.map +1 -0
- package/lib/content-fields/flow-video.js.map +1 -0
- package/lib/content-fields/flow-webview.js.map +1 -0
- package/lib/content-fields/flow-whatsapp-cta-url-button.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-whatsapp-request-contact-info.d.ts +2 -1
- package/lib/{esm/content-fields → content-fields}/flow-whatsapp-request-contact-info.js +10 -0
- package/lib/content-fields/flow-whatsapp-request-contact-info.js.map +1 -0
- package/lib/content-fields/flow-whatsapp-template.js.map +1 -0
- package/lib/content-fields/hubtype-fields/ai-agent-router.js.map +1 -0
- package/lib/content-fields/hubtype-fields/ai-agent.js.map +1 -0
- package/lib/content-fields/hubtype-fields/bot-action.js.map +1 -0
- package/lib/content-fields/hubtype-fields/button.js.map +1 -0
- package/lib/content-fields/hubtype-fields/capture-user-input.js.map +1 -0
- package/lib/content-fields/hubtype-fields/carousel.js.map +1 -0
- package/lib/content-fields/hubtype-fields/channel-conditional.js.map +1 -0
- package/lib/content-fields/hubtype-fields/common.js.map +1 -0
- package/lib/content-fields/hubtype-fields/country-conditional.js.map +1 -0
- package/lib/content-fields/hubtype-fields/custom-conditional-v2.js.map +1 -0
- package/lib/content-fields/hubtype-fields/custom-conditional.js.map +1 -0
- package/lib/content-fields/hubtype-fields/fallback.js.map +1 -0
- package/lib/content-fields/hubtype-fields/function.js.map +1 -0
- package/lib/content-fields/hubtype-fields/go-to-flow.js.map +1 -0
- package/lib/content-fields/hubtype-fields/handoff.js.map +1 -0
- package/lib/content-fields/hubtype-fields/image.js.map +1 -0
- package/lib/content-fields/hubtype-fields/index.js.map +1 -0
- package/lib/content-fields/hubtype-fields/keyword.js.map +1 -0
- package/lib/content-fields/hubtype-fields/node-types.js.map +1 -0
- package/lib/content-fields/hubtype-fields/nodes.js.map +1 -0
- package/lib/content-fields/hubtype-fields/payload.js.map +1 -0
- package/lib/content-fields/hubtype-fields/queue-status-conditional.js.map +1 -0
- package/lib/content-fields/hubtype-fields/rating.js.map +1 -0
- package/lib/content-fields/hubtype-fields/smart-intent.js.map +1 -0
- package/lib/content-fields/hubtype-fields/text.js.map +1 -0
- package/lib/content-fields/hubtype-fields/url.js.map +1 -0
- package/lib/content-fields/hubtype-fields/video.js.map +1 -0
- package/lib/content-fields/hubtype-fields/webview.js.map +1 -0
- package/lib/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
- package/lib/content-fields/hubtype-fields/whatsapp-cta-url-button.js.map +1 -0
- package/lib/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +1 -0
- package/lib/content-fields/hubtype-fields/whatsapp-template.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/index.d.ts +1 -1
- package/lib/content-fields/index.js.map +1 -0
- package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
- package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
- package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
- package/lib/content-fields/whatsapp-button-list/index.js.map +1 -0
- package/lib/filters/index.js.map +1 -0
- package/lib/flow-factory.js.map +1 -0
- package/lib/functions/index.js.map +1 -0
- package/lib/index.js.map +1 -0
- package/lib/services/hubtype-queues-api.js.map +1 -0
- package/lib/structured-output/flow-builder-content.js.map +1 -0
- package/lib/tracking.js.map +1 -0
- package/lib/types.js.map +1 -0
- package/lib/user-input/capture-user-input-api.js.map +1 -0
- package/lib/user-input/index.js.map +1 -0
- package/lib/user-input/keyword.js.map +1 -0
- package/lib/user-input/smart-intent.js.map +1 -0
- package/lib/utils/ai-agent.js.map +1 -0
- package/lib/utils/authentication.js.map +1 -0
- package/lib/utils/flow-locale.js.map +1 -0
- package/lib/utils/get-flow-builder-plugin.js.map +1 -0
- package/lib/{esm/utils → utils}/hubtype-assistant-content.d.ts +1 -0
- package/lib/{esm/utils → utils}/hubtype-assistant-content.js +13 -0
- package/lib/utils/hubtype-assistant-content.js.map +1 -0
- package/lib/utils/input.js.map +1 -0
- package/lib/webview/contents-context.js.map +1 -0
- package/lib/webview/index.js.map +1 -0
- package/lib/webview/types.js.map +1 -0
- package/lib/webview/use-webview-contents.js.map +1 -0
- package/package.json +9 -8
- package/src/content-fields/flow-ai-agent-base.tsx +11 -0
- package/src/content-fields/flow-whatsapp-request-contact-info.tsx +17 -1
- package/src/content-fields/index.ts +2 -2
- package/src/utils/hubtype-assistant-content.ts +14 -0
- package/lib/esm/action/ai-agent-from-user-input.js.map +0 -1
- package/lib/esm/action/context.js.map +0 -1
- package/lib/esm/action/fallback.js.map +0 -1
- package/lib/esm/action/first-interaction.js.map +0 -1
- package/lib/esm/action/get-contents.js.map +0 -1
- package/lib/esm/action/index.js.map +0 -1
- package/lib/esm/action/payload.js.map +0 -1
- package/lib/esm/api.js.map +0 -1
- package/lib/esm/constants.js.map +0 -1
- package/lib/esm/content-fields/content-fields-base.js.map +0 -1
- package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-evaluators.js.map +0 -1
- package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-resolver.js.map +0 -1
- package/lib/esm/content-fields/custom-conditional/flow-custom-condition-v2.js.map +0 -1
- package/lib/esm/content-fields/flow-ai-agent-base.js.map +0 -1
- package/lib/esm/content-fields/flow-ai-agent-router.js.map +0 -1
- package/lib/esm/content-fields/flow-ai-agent.js.map +0 -1
- package/lib/esm/content-fields/flow-bot-action.js.map +0 -1
- package/lib/esm/content-fields/flow-button.js.map +0 -1
- package/lib/esm/content-fields/flow-capture-user-input.js.map +0 -1
- package/lib/esm/content-fields/flow-carousel.js.map +0 -1
- package/lib/esm/content-fields/flow-channel-conditional.js.map +0 -1
- package/lib/esm/content-fields/flow-country-conditional.js.map +0 -1
- package/lib/esm/content-fields/flow-custom-conditional.js.map +0 -1
- package/lib/esm/content-fields/flow-element.js.map +0 -1
- package/lib/esm/content-fields/flow-go-to-flow.js.map +0 -1
- package/lib/esm/content-fields/flow-handoff.js.map +0 -1
- package/lib/esm/content-fields/flow-image.js.map +0 -1
- package/lib/esm/content-fields/flow-queue-status-conditional.js.map +0 -1
- package/lib/esm/content-fields/flow-rating.js.map +0 -1
- package/lib/esm/content-fields/flow-text.js.map +0 -1
- package/lib/esm/content-fields/flow-video.js.map +0 -1
- package/lib/esm/content-fields/flow-webview.js.map +0 -1
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +0 -1
- package/lib/esm/content-fields/flow-whatsapp-request-contact-info.js.map +0 -1
- package/lib/esm/content-fields/flow-whatsapp-template.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/ai-agent-router.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/ai-agent.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/bot-action.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/button.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/capture-user-input.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/carousel.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/channel-conditional.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/common.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/country-conditional.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/custom-conditional-v2.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/custom-conditional.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/fallback.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/function.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/go-to-flow.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/handoff.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/image.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/index.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/keyword.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/payload.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/queue-status-conditional.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/rating.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/smart-intent.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/text.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/url.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/video.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/webview.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-cta-url-button.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-template.js.map +0 -1
- package/lib/esm/content-fields/index.js.map +0 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +0 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +0 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +0 -1
- package/lib/esm/content-fields/whatsapp-button-list/index.js.map +0 -1
- package/lib/esm/filters/index.js.map +0 -1
- package/lib/esm/flow-factory.js.map +0 -1
- package/lib/esm/functions/index.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/esm/services/hubtype-queues-api.js.map +0 -1
- package/lib/esm/structured-output/flow-builder-content.js.map +0 -1
- package/lib/esm/tracking.js.map +0 -1
- package/lib/esm/types.js.map +0 -1
- package/lib/esm/user-input/capture-user-input-api.js.map +0 -1
- package/lib/esm/user-input/index.js.map +0 -1
- package/lib/esm/user-input/keyword.js.map +0 -1
- package/lib/esm/user-input/smart-intent.js.map +0 -1
- package/lib/esm/utils/ai-agent.js.map +0 -1
- package/lib/esm/utils/authentication.js.map +0 -1
- package/lib/esm/utils/flow-locale.js.map +0 -1
- package/lib/esm/utils/get-flow-builder-plugin.js.map +0 -1
- package/lib/esm/utils/hubtype-assistant-content.js.map +0 -1
- package/lib/esm/utils/input.js.map +0 -1
- package/lib/esm/webview/contents-context.js.map +0 -1
- package/lib/esm/webview/index.js.map +0 -1
- package/lib/esm/webview/types.js.map +0 -1
- package/lib/esm/webview/use-webview-contents.js.map +0 -1
- /package/lib/{esm/action → action}/ai-agent-from-user-input.d.ts +0 -0
- /package/lib/{esm/action → action}/ai-agent-from-user-input.js +0 -0
- /package/lib/{esm/action → action}/context.d.ts +0 -0
- /package/lib/{esm/action → action}/context.js +0 -0
- /package/lib/{esm/action → action}/fallback.d.ts +0 -0
- /package/lib/{esm/action → action}/fallback.js +0 -0
- /package/lib/{esm/action → action}/first-interaction.d.ts +0 -0
- /package/lib/{esm/action → action}/first-interaction.js +0 -0
- /package/lib/{esm/action → action}/get-contents.d.ts +0 -0
- /package/lib/{esm/action → action}/get-contents.js +0 -0
- /package/lib/{esm/action → action}/index.d.ts +0 -0
- /package/lib/{esm/action → action}/index.js +0 -0
- /package/lib/{esm/action → action}/payload.d.ts +0 -0
- /package/lib/{esm/action → action}/payload.js +0 -0
- /package/lib/{esm/api.d.ts → api.d.ts} +0 -0
- /package/lib/{esm/api.js → api.js} +0 -0
- /package/lib/{esm/constants.d.ts → constants.d.ts} +0 -0
- /package/lib/{esm/constants.js → constants.js} +0 -0
- /package/lib/{esm/content-fields → content-fields}/content-fields-base.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/content-fields-base.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-evaluators.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-evaluators.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-resolver.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-resolver.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/custom-conditional/flow-custom-condition-v2.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-ai-agent-base.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-ai-agent-router.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-ai-agent-router.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-ai-agent.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-ai-agent.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-bot-action.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-bot-action.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-button.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-button.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-capture-user-input.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-capture-user-input.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-carousel.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-carousel.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-channel-conditional.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-channel-conditional.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-country-conditional.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-country-conditional.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-custom-conditional.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-element.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-element.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-go-to-flow.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-go-to-flow.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-handoff.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-handoff.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-image.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-image.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-queue-status-conditional.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-queue-status-conditional.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-rating.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-rating.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-text.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-text.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-video.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-video.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-webview.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-webview.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-cta-url-button.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-cta-url-button.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-template.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-template.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent-router.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent-router.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/bot-action.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/bot-action.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/button.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/button.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/capture-user-input.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/capture-user-input.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/carousel.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/carousel.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/channel-conditional.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/channel-conditional.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/common.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/common.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/country-conditional.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/country-conditional.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional-v2.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional-v2.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/fallback.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/fallback.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/function.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/function.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/go-to-flow.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/go-to-flow.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/handoff.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/handoff.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/image.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/image.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/index.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/index.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/keyword.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/keyword.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/node-types.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/node-types.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/nodes.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/nodes.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/payload.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/payload.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/queue-status-conditional.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/queue-status-conditional.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/rating.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/rating.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/smart-intent.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/smart-intent.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/text.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/text.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/url.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/url.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/video.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/video.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/webview.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/webview.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-button-list.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-button-list.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-cta-url-button.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-cta-url-button.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-request-contact-info.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-request-contact-info.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-template.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-template.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/index.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-row.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-section.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list.js +0 -0
- /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/index.d.ts +0 -0
- /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/index.js +0 -0
- /package/lib/{esm/filters → filters}/index.d.ts +0 -0
- /package/lib/{esm/filters → filters}/index.js +0 -0
- /package/lib/{esm/flow-factory.d.ts → flow-factory.d.ts} +0 -0
- /package/lib/{esm/flow-factory.js → flow-factory.js} +0 -0
- /package/lib/{esm/functions → functions}/index.d.ts +0 -0
- /package/lib/{esm/functions → functions}/index.js +0 -0
- /package/lib/{esm/index.d.ts → index.d.ts} +0 -0
- /package/lib/{esm/index.js → index.js} +0 -0
- /package/lib/{esm/services → services}/hubtype-queues-api.d.ts +0 -0
- /package/lib/{esm/services → services}/hubtype-queues-api.js +0 -0
- /package/lib/{esm/structured-output → structured-output}/flow-builder-content.d.ts +0 -0
- /package/lib/{esm/structured-output → structured-output}/flow-builder-content.js +0 -0
- /package/lib/{esm/tracking.d.ts → tracking.d.ts} +0 -0
- /package/lib/{esm/tracking.js → tracking.js} +0 -0
- /package/lib/{esm/types.d.ts → types.d.ts} +0 -0
- /package/lib/{esm/types.js → types.js} +0 -0
- /package/lib/{esm/user-input → user-input}/capture-user-input-api.d.ts +0 -0
- /package/lib/{esm/user-input → user-input}/capture-user-input-api.js +0 -0
- /package/lib/{esm/user-input → user-input}/index.d.ts +0 -0
- /package/lib/{esm/user-input → user-input}/index.js +0 -0
- /package/lib/{esm/user-input → user-input}/keyword.d.ts +0 -0
- /package/lib/{esm/user-input → user-input}/keyword.js +0 -0
- /package/lib/{esm/user-input → user-input}/smart-intent.d.ts +0 -0
- /package/lib/{esm/user-input → user-input}/smart-intent.js +0 -0
- /package/lib/{esm/utils → utils}/ai-agent.d.ts +0 -0
- /package/lib/{esm/utils → utils}/ai-agent.js +0 -0
- /package/lib/{esm/utils → utils}/authentication.d.ts +0 -0
- /package/lib/{esm/utils → utils}/authentication.js +0 -0
- /package/lib/{esm/utils → utils}/flow-locale.d.ts +0 -0
- /package/lib/{esm/utils → utils}/flow-locale.js +0 -0
- /package/lib/{esm/utils → utils}/get-flow-builder-plugin.d.ts +0 -0
- /package/lib/{esm/utils → utils}/get-flow-builder-plugin.js +0 -0
- /package/lib/{esm/utils → utils}/input.d.ts +0 -0
- /package/lib/{esm/utils → utils}/input.js +0 -0
- /package/lib/{esm/webview → webview}/contents-context.d.ts +0 -0
- /package/lib/{esm/webview → webview}/contents-context.js +0 -0
- /package/lib/{esm/webview → webview}/index.d.ts +0 -0
- /package/lib/{esm/webview → webview}/index.js +0 -0
- /package/lib/{esm/webview → webview}/types.d.ts +0 -0
- /package/lib/{esm/webview → webview}/types.js +0 -0
- /package/lib/{esm/webview → webview}/use-webview-contents.d.ts +0 -0
- /package/lib/{esm/webview → webview}/use-webview-contents.js +0 -0
package/README.md
CHANGED
|
@@ -164,7 +164,7 @@ e.g using @botonic/plugin-ai-agents
|
|
|
164
164
|
|
|
165
165
|
```ts
|
|
166
166
|
import { Input, Session } from '@botonic/core'
|
|
167
|
-
import FlowBuilderAction from '@botonic/plugin-flow-builder
|
|
167
|
+
import { FlowBuilderAction } from '@botonic/plugin-flow-builder'
|
|
168
168
|
|
|
169
169
|
type RouteRequest = { input: Input; session: Session }
|
|
170
170
|
export function routes(request: RouteRequest) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action/ai-agent-from-user-input.js","sources":["../../src/action/ai-agent-from-user-input.ts"],"sourcesContent":["import type { FlowContent } from '../content-fields/index'\nimport { splitAiAgentContents } from '../utils/ai-agent'\nimport type { FlowBuilderContext } from './context'\n\nexport async function getContentsByAiAgentFromUserInput({\n cmsApi,\n flowBuilderPlugin,\n request,\n}: FlowBuilderContext): Promise<FlowContent[]> {\n const startNodeAiAgentFlow = cmsApi.getStartNodeAiAgentFlow()\n const isAiAgentEnabled = cmsApi.isAiAgentEnabled()\n if (!startNodeAiAgentFlow || !isAiAgentEnabled) {\n return []\n }\n\n const contents =\n await flowBuilderPlugin.getContentsByNode(startNodeAiAgentFlow)\n\n const splitContents = splitAiAgentContents(contents)\n\n if (!splitContents) {\n return []\n }\n\n if ('aiAgentRouterContent' in splitContents) {\n const { aiAgentRouterContent, contentsBeforeAiAgentRouter } = splitContents\n const aiAgentResponse = await aiAgentRouterContent.resolveAIAgentResponse(\n request,\n contentsBeforeAiAgentRouter\n )\n\n if (!aiAgentResponse || aiAgentResponse.exit) {\n return []\n }\n }\n\n if ('aiAgentWorkerContent' in splitContents) {\n const { aiAgentWorkerContent, contentsBeforeAiAgentWorker } = splitContents\n const aiAgentResponse = await aiAgentWorkerContent.resolveAIAgentResponse(\n request,\n contentsBeforeAiAgentWorker\n )\n\n if (!aiAgentResponse || aiAgentResponse.exit) {\n return []\n }\n }\n\n return contents\n}\n"],"names":["splitAiAgentContents","getContentsByAiAgentFromUserInput","cmsApi","flowBuilderPlugin","request","startNodeAiAgentFlow","isAiAgentEnabled","contents","splitContents","aiAgentRouterContent","contentsBeforeAiAgentRouter","aiAgentResponse","aiAgentWorkerContent","contentsBeforeAiAgentWorker"],"mappings":";;;AACwD;AAGjD,eAAeC,iCAAiCA,CAAC,EACtDC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EACY;IACnB,MAAMC,uBAAuBH,OAAO,uBAAuB;IAC3D,MAAMI,mBAAmBJ,OAAO,gBAAgB;IAChD,IAAI,CAACG,wBAAwB,CAACC,kBAAkB;QAC9C,OAAO,EAAE;IACX;IAEA,MAAMC,WACJ,MAAMJ,kBAAkB,iBAAiB,CAACE;IAE5C,MAAMG,gBAAgBR,oBAAoBA,CAACO;IAE3C,IAAI,CAACC,eAAe;QAClB,OAAO,EAAE;IACX;IAEA,IAAI,0BAA0BA,eAAe;QAC3C,MAAM,EAAEC,oBAAoB,EAAEC,2BAA2B,EAAE,GAAGF;QAC9D,MAAMG,kBAAkB,MAAMF,qBAAqB,sBAAsB,CACvEL,SACAM;QAGF,IAAI,CAACC,mBAAmBA,gBAAgB,IAAI,EAAE;YAC5C,OAAO,EAAE;QACX;IACF;IAEA,IAAI,0BAA0BH,eAAe;QAC3C,MAAM,EAAEI,oBAAoB,EAAEC,2BAA2B,EAAE,GAAGL;QAC9D,MAAMG,kBAAkB,MAAMC,qBAAqB,sBAAsB,CACvER,SACAS;QAGF,IAAI,CAACF,mBAAmBA,gBAAgB,IAAI,EAAE;YAC5C,OAAO,EAAE;QACX;IACF;IAEA,OAAOJ;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action/context.js","sources":["../../src/action/context.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\n\nimport type { FlowBuilderApi } from '../api'\nimport type BotonicPluginFlowBuilder from '../index'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\n\nexport interface FlowBuilderContext {\n cmsApi: FlowBuilderApi\n flowBuilderPlugin: BotonicPluginFlowBuilder\n request: BotContext\n resolvedLocale: string\n contentID?: string\n}\n\nexport function getFlowBuilderActionContext(\n request: BotContext,\n contentID?: string\n): FlowBuilderContext {\n const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n const resolvedLocale = flowBuilderPlugin.cmsApi.getResolvedLocale()\n return {\n cmsApi,\n flowBuilderPlugin,\n request,\n resolvedLocale,\n contentID,\n }\n}\n"],"names":["getFlowBuilderPlugin","getFlowBuilderActionContext","request","contentID","flowBuilderPlugin","cmsApi","resolvedLocale"],"mappings":";;;AAIuE;AAUhE,SAASC,2BAA2BA,CACzCC,OAAmB,EACnBC,SAAkB;IAElB,MAAMC,oBAAoBJ,oBAAoBA,CAACE,QAAQ,OAAO;IAC9D,MAAMG,SAASD,kBAAkB,MAAM;IACvC,MAAME,iBAAiBF,kBAAkB,MAAM,CAAC,iBAAiB;IACjE,OAAO;QACLC;QACAD;QACAF;QACAI;QACAH;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action/fallback.js","sources":["../../src/action/fallback.ts"],"sourcesContent":["import { EventAction, type EventFallback } from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport type { FlowContent } from '../content-fields'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport type { FlowBuilderContext } from './context'\n\nexport async function getContentsByFallback({\n cmsApi,\n flowBuilderPlugin,\n request,\n}: FlowBuilderContext): Promise<FlowContent[]> {\n const fallbackNode = await getFallbackNode(cmsApi, request)\n const fallbackContents =\n await flowBuilderPlugin.getContentsByNode(fallbackNode)\n\n return fallbackContents\n}\n\nasync function getFallbackNode(cmsApi: FlowBuilderApi, request: ActionRequest) {\n if (request.session.user.extra_data?.isFirstFallbackOption === undefined) {\n request.session.user.extra_data = {\n ...request.session.user.extra_data,\n isFirstFallbackOption: true,\n }\n }\n\n const isFirstFallbackOption =\n !!request.session.user.extra_data.isFirstFallbackOption\n const fallbackNode = cmsApi.getFallbackNode(isFirstFallbackOption)\n request.session.user.extra_data.isFirstFallbackOption = !isFirstFallbackOption\n\n const { flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(request, fallbackNode.id)\n\n const event: EventFallback = {\n action: EventAction.Fallback,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n userInput: request.input.data as string,\n fallbackOut: isFirstFallbackOption ? 1 : 2,\n fallbackMessageId: request.input.message_id,\n }\n const { action, ...eventArgs } = event\n\n await trackEvent(request, action, eventArgs)\n\n return fallbackNode\n}\n"],"names":["EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","getContentsByFallback","cmsApi","flowBuilderPlugin","request","fallbackNode","getFallbackNode","fallbackContents","undefined","isFirstFallbackOption","flowId","flowName","flowNodeId","flowNodeContentId","event","action","eventArgs"],"mappings":";;;;;AAA+D;AAQ3C;AAGb,eAAeG,qBAAqBA,CAAC,EAC1CC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EACY;IACnB,MAAMC,eAAe,MAAMC,eAAeA,CAACJ,QAAQE;IACnD,MAAMG,mBACJ,MAAMJ,kBAAkB,iBAAiB,CAACE;IAE5C,OAAOE;AACT;AAEA,eAAeD,eAAeA,CAACJ,MAAsB,EAAEE,OAAsB;IAC3E,IAAIA,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,0BAA0BI,WAAW;QACxEJ,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU,GAAG;YAChC,GAAGA,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU;YAClC,uBAAuB;QACzB;IACF;IAEA,MAAMK,wBACJ,CAAC,CAACL,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB;IACzD,MAAMC,eAAeH,OAAO,eAAe,CAACO;IAC5CL,QAAQ,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,GAAG,CAACK;IAEzD,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GACvDd,yCAAyCA,CAACK,SAASC,aAAa,EAAE;IAEpE,MAAMS,QAAuB;QAC3B,QAAQhB,oBAAoB;QAC5BY;QACAC;QACAC;QACAC;QACA,WAAWT,QAAQ,KAAK,CAAC,IAAI;QAC7B,aAAaK,wBAAwB,IAAI;QACzC,mBAAmBL,QAAQ,KAAK,CAAC,UAAU;IAC7C;IACA,MAAM,EAAEW,MAAM,EAAE,GAAGC,WAAW,GAAGF;IAEjC,MAAMd,UAAUA,CAACI,SAASW,QAAQC;IAElC,OAAOX;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action/first-interaction.js","sources":["../../src/action/first-interaction.ts"],"sourcesContent":["import type { FlowBuilderApi } from '../api'\nimport { MAIN_FLOW_NAME } from '../constants'\nimport {\n FlowAiAgent,\n FlowAiAgentRouter,\n FlowBotAction,\n type FlowContent,\n} from '../content-fields'\nimport type BotonicPluginFlowBuilder from '../index'\nimport { inputHasTextOrTranscript } from '../utils/input'\nimport { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'\nimport type { FlowBuilderContext } from './context'\nimport { getContentsByPayload } from './payload'\n\nexport async function getContentsByFirstInteraction(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { contentID, flowBuilderPlugin, request } = context\n\n /*\n * If the contentID is provided, the firstInteractionContents are obtained even if they are not used\n * because when obtain this firstInteractionContents is when the session.flow_thread_id is updated.\n * This is needed for example when send a WhatsApp campaign is sent,\n * the bot not receives the message because this message is sent directly by the backend\n * we expect the bot to respond only with the contents of the contentID and not with the firstInteractionContents.\n */\n const firstInteractionContents = await flowBuilderPlugin.getStartContents()\n\n if (contentID) {\n try {\n const contentsByContentID =\n await flowBuilderPlugin.getContentsByContentID(contentID)\n\n if (contentsByContentID.length > 0) {\n return contentsByContentID\n }\n } catch (_error) {\n console.warn(\n `The contentID ${contentID} is not found. Returning the firstInteractionContents`\n )\n }\n }\n\n // Bot actions and AI agents already consume the user input. Matching\n // keywords/intents/KB/AI-agent-from-user-input on top would duplicate replies\n // (e.g. Main start → Go to flow → AI Agents).\n if (startContentsAlreadyHandleUserInput(firstInteractionContents)) {\n return firstInteractionContents\n }\n\n if (request.input.nluResolution || inputHasTextOrTranscript(request.input)) {\n const contentsByUserInput = await getContentsByUserInput(context)\n\n return [...firstInteractionContents, ...contentsByUserInput]\n }\n\n return firstInteractionContents\n}\n\nfunction startContentsAlreadyHandleUserInput(contents: FlowContent[]): boolean {\n if (contents.at(-1) instanceof FlowBotAction) {\n return true\n }\n\n // To avoid duplicated ai agent response, we check if there is an ai agent or ai agent router in the first interaction contents.\n return contents.some(\n content =>\n content instanceof FlowAiAgent || content instanceof FlowAiAgentRouter\n )\n}\n\nasync function getContentsByUserInput(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request, resolvedLocale } = context\n const payloadByNlu = request.input.nluResolution?.payload\n\n if (payloadByNlu) {\n request.input.payload = payloadByNlu\n const conversationStartId = getConversationStartId(cmsApi)\n\n if (request.input.payload === conversationStartId) {\n return []\n }\n\n const contentsByKeywordsOrIntents = await getContentsByPayload({\n cmsApi,\n flowBuilderPlugin,\n request,\n resolvedLocale,\n })\n\n const hasRepeatedContent = await checkRepeatedContents(\n flowBuilderPlugin,\n contentsByKeywordsOrIntents\n )\n\n if (hasRepeatedContent) {\n return []\n }\n\n if (contentsByKeywordsOrIntents.length > 0) {\n return contentsByKeywordsOrIntents\n }\n }\n\n if (!flowBuilderPlugin.disableAIAgentInFirstInteraction) {\n const contentsByAiAgent = await getContentsByAiAgentFromUserInput(context)\n return contentsByAiAgent\n }\n\n return []\n}\n\nfunction getConversationStartId(cmsApi: FlowBuilderApi) {\n const conversationStartId = cmsApi.flow.flows.find(\n flow => flow.name === MAIN_FLOW_NAME\n )?.start_node_id\n\n return conversationStartId\n}\n\nasync function checkRepeatedContents(\n flowBuilderPlugin: BotonicPluginFlowBuilder,\n contentsByKeywordsOrIntents: FlowContent[]\n) {\n const startContents = await flowBuilderPlugin.getStartContents()\n const contentIds = new Set(\n contentsByKeywordsOrIntents.map(content => content.id)\n )\n const hasRepeatedContent = startContents.some(content =>\n contentIds.has(content.id)\n )\n\n return hasRepeatedContent\n}\n"],"names":["MAIN_FLOW_NAME","FlowAiAgent","FlowAiAgentRouter","FlowBotAction","inputHasTextOrTranscript","getContentsByAiAgentFromUserInput","getContentsByPayload","getContentsByFirstInteraction","context","contentID","flowBuilderPlugin","request","firstInteractionContents","contentsByContentID","_error","console","startContentsAlreadyHandleUserInput","contentsByUserInput","getContentsByUserInput","contents","content","cmsApi","resolvedLocale","payloadByNlu","conversationStartId","getConversationStartId","contentsByKeywordsOrIntents","hasRepeatedContent","checkRepeatedContents","contentsByAiAgent","flow","startContents","contentIds","Set"],"mappings":";;;;;;;;;;;AAC6C;AAMnB;AAE+B;AACqB;AAE9B;AAEzC,eAAeO,6BAA6BA,CACjDC,OAA2B;IAE3B,MAAM,EAAEC,SAAS,EAAEC,iBAAiB,EAAEC,OAAO,EAAE,GAAGH;IAElD;;;;;;GAMC,GACD,MAAMI,2BAA2B,MAAMF,kBAAkB,gBAAgB;IAEzE,IAAID,WAAW;QACb,IAAI;YACF,MAAMI,sBACJ,MAAMH,kBAAkB,sBAAsB,CAACD;YAEjD,IAAII,oBAAoB,MAAM,GAAG,GAAG;gBAClC,OAAOA;YACT;QACF,EAAE,OAAOC,QAAQ;YACfC,QAAQ,IAAI,CACV,CAAC,cAAc,EAAEN,UAAU,qDAAqD,CAAC;QAErF;IACF;IAEA,qEAAqE;IACrE,8EAA8E;IAC9E,8CAA8C;IAC9C,IAAIO,mCAAmCA,CAACJ,2BAA2B;QACjE,OAAOA;IACT;IAEA,IAAID,QAAQ,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K,IAAI,KAAK9B,cAAcA,GACnC;IAEH,OAAOwB;AACT;AAEA,eAAeI,qBAAqBA,CAClClB,iBAA2C,EAC3CgB,2BAA0C;IAE1C,MAAMK,gBAAgB,MAAMrB,kBAAkB,gBAAgB;IAC9D,MAAMsB,aAAa,IAAIC,IACrBP,4BAA4B,GAAG,CAACN,CAAAA,UAAWA,QAAQ,EAAE;IAEvD,MAAMO,qBAAqBI,cAAc,IAAI,CAACX,CAAAA,UAC5CY,WAAW,GAAG,CAACZ,QAAQ,EAAE;IAG3B,OAAOO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action/get-contents.js","sources":["../../src/action/get-contents.ts"],"sourcesContent":["import { type BotContext, INPUT } from '@botonic/core'\nimport { EMPTY_PAYLOAD } from '../constants'\nimport type { FlowContent } from '../content-fields'\nimport { inputHasTextOrTranscript } from '../utils/input'\nimport { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'\nimport { getFlowBuilderActionContext } from './context'\nimport { getContentsByFallback } from './fallback'\nimport { getContentsByFirstInteraction } from './first-interaction'\nimport { getContentsByPayload } from './payload'\n\nexport async function getContents(\n botContext: BotContext,\n contentID?: string\n): Promise<FlowContent[]> {\n const context = getFlowBuilderActionContext(botContext, contentID)\n\n if (botContext.session.is_first_interaction) {\n return await getContentsByFirstInteraction(context)\n }\n // TODO: Add needed logic when we can define contents for multi locale queue position message\n if (botContext.input.type === INPUT.EVENT_QUEUE_POSITION_CHANGED) {\n return []\n }\n\n if (botContext.input.payload?.startsWith(EMPTY_PAYLOAD)) {\n botContext.input.payload = undefined\n }\n\n if (botContext.input.payload || contentID) {\n const contentsByPayload = await getContentsByPayload(context)\n if (contentsByPayload.length > 0) {\n return contentsByPayload\n }\n\n return await getContentsByFallback(context)\n }\n\n if (inputHasTextOrTranscript(botContext.input)) {\n const aiAgentContents = await getContentsByAiAgentFromUserInput(context)\n if (aiAgentContents.length > 0) {\n return aiAgentContents\n }\n }\n\n return await getContentsByFallback(context)\n}\n"],"names":["INPUT","EMPTY_PAYLOAD","inputHasTextOrTranscript","getContentsByAiAgentFromUserInput","getFlowBuilderActionContext","getContentsByFallback","getContentsByFirstInteraction","getContentsByPayload","getContents","botContext","contentID","context","undefined","contentsByPayload","aiAgentContents"],"mappings":";;;;;;;;;;;;;;;;;AAAsD;AACV;AAEa;AACqB;AACvB;AACL;AACiB;AACnB;AAEzC,eAAeQ,WAAWA,CAC/BC,UAAsB,EACtBC,SAAkB;IAElB,MAAMC,UAAUP,2BAA2BA,CAACK,YAAYC;IAExD,IAAID,WAAW,OAAO,CAAC,oBAAoB,EAAE;QAC3C,OAAO,MAAMH,6BAA6BA,CAACK;IAC7C;IACA,6FAA6F;IAC7F,IAAIF,WAAW,KAAK,CAAC,IAAI,KAAKT,kCAAkC,EAAE;QAChE,OAAO,EAAE;IACX;IAEA,IAAIS,WAAW,KAAK,CAAC,OAAO,EAAE,WAAWR,aAAaA,GAAG;QACvDQ,WAAW,KAAK,CAAC,OAAO,GAAGG;IAC7B;IAEA,IAAIH,WAAW,KAAK,CAAC,OAAO,IAAIC,WAAW;QACzC,MAAMG,oBAAoB,MAAMN,oBAAoBA,CAACI;QACrD,IAAIE,kBAAkB,MAAM,GAAG,GAAG;YAChC,OAAOA;QACT;QAEA,OAAO,MAAMR,qBAAqBA,CAACM;IACrC;IAEA,IAAIT,wBAAwBA,CAACO,WAAW,KAAK,GAAG;QAC9C,MAAMK,kBAAkB,MAAMX,iCAAiCA,CAACQ;QAChE,IAAIG,gBAAgB,MAAM,GAAG,GAAG;YAC9B,OAAOA;QACT;IACF;IAEA,OAAO,MAAMT,qBAAqBA,CAACM;AACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action/index.js","sources":["../../src/action/index.tsx"],"sourcesContent":["import { type BotContext, isDev, isWebchat } from '@botonic/core'\nimport {\n Multichannel,\n RequestContext,\n WebchatSettings,\n type WebchatSettingsProps,\n} from '@botonic/react'\nimport React from 'react'\n\nimport {\n FlowAiAgent,\n FlowAiAgentRouter,\n type FlowContent,\n} from '../content-fields'\nimport { splitAiAgentContents } from '../utils/ai-agent'\nimport { getFlowBuilderActionContext } from './context'\nimport { getContentsByFirstInteraction } from './first-interaction'\nimport { getContents } from './get-contents'\n\nexport type FlowBuilderActionProps = {\n contents: FlowContent[]\n webchatSettingsParams?: WebchatSettingsProps\n}\n\nexport class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {\n static contextType = RequestContext\n declare context: React.ContextType<typeof RequestContext>\n\n static async executeConversationStart(\n botContext: BotContext\n ): Promise<FlowBuilderActionProps> {\n const context = getFlowBuilderActionContext(botContext)\n const contents = await getContentsByFirstInteraction(context)\n\n const filteredContents = await FlowBuilderAction.prepareContentsToRender(\n botContext,\n contents\n )\n\n return { contents: filteredContents }\n }\n\n static async botonicInit(\n botContext: BotContext,\n contentID?: string\n ): Promise<FlowBuilderActionProps> {\n const contents = await getContents(botContext, contentID)\n\n const contentsToRender = await FlowBuilderAction.prepareContentsToRender(\n botContext,\n contents\n )\n\n return { contents: contentsToRender }\n }\n\n static async prepareContentsToRender(\n botContext: BotContext,\n contents: FlowContent[]\n ) {\n for (const content of contents) {\n if (FlowBuilderAction.isAiAgentContent(content)) {\n await FlowBuilderAction.processAiAgentContent(botContext, contents)\n continue\n }\n\n await content.processContent(botContext)\n }\n\n return contents\n }\n\n private static isAiAgentContent(content: FlowContent): boolean {\n return (\n content instanceof FlowAiAgent || content instanceof FlowAiAgentRouter\n )\n }\n\n // TODO: Refactor this to be more generic and reusable\n private static async processAiAgentContent(\n botContext: BotContext,\n contents: FlowContent[]\n ) {\n const splitContents = splitAiAgentContents(contents)\n if (!splitContents) {\n return\n }\n\n if ('aiAgentRouterContent' in splitContents) {\n const { aiAgentRouterContent, contentsBeforeAiAgentRouter } =\n splitContents\n await aiAgentRouterContent.processContent(\n botContext,\n contentsBeforeAiAgentRouter\n )\n }\n\n if ('aiAgentWorkerContent' in splitContents) {\n const { aiAgentWorkerContent, contentsBeforeAiAgentWorker } =\n splitContents\n await aiAgentWorkerContent.processContent(\n botContext,\n contentsBeforeAiAgentWorker\n )\n }\n }\n\n protected getWebchatSettingsParams(botContext: BotContext): {\n shouldSendWebchatSettings: boolean\n webchatSettingsParams?: WebchatSettingsProps\n } {\n let { webchatSettingsParams } = this.props\n if (botContext.session.user.system_locale_updated) {\n webchatSettingsParams = {\n ...webchatSettingsParams,\n user: {\n ...webchatSettingsParams?.user,\n system_locale: botContext.session.user.system_locale,\n },\n }\n }\n const shouldSendWebchatSettings =\n (isWebchat(botContext.session) || isDev(botContext.session)) &&\n !!webchatSettingsParams\n\n return {\n shouldSendWebchatSettings,\n webchatSettingsParams,\n }\n }\n\n render(): JSX.Element | JSX.Element[] {\n const { contents } = this.props\n const botContext = this.context as BotContext\n const { shouldSendWebchatSettings, webchatSettingsParams } =\n this.getWebchatSettingsParams(botContext)\n\n return (\n <>\n {shouldSendWebchatSettings && (\n <WebchatSettings {...webchatSettingsParams} />\n )}\n {contents.map(content => content.toBotonic(botContext))}\n </>\n )\n }\n}\n\nexport class FlowBuilderMultichannelAction extends FlowBuilderAction {\n render(): JSX.Element | JSX.Element[] {\n const { contents } = this.props\n const botContext = this.context as BotContext\n const { shouldSendWebchatSettings, webchatSettingsParams } =\n this.getWebchatSettingsParams(botContext)\n\n return (\n <Multichannel text={{ buttonsAsText: false }}>\n {shouldSendWebchatSettings && (\n <WebchatSettings {...webchatSettingsParams} />\n )}\n {contents.map(content => content.toBotonic(botContext))}\n </Multichannel>\n )\n }\n}\n"],"names":["isDev","isWebchat","Multichannel","RequestContext","WebchatSettings","React","FlowAiAgent","FlowAiAgentRouter","splitAiAgentContents","getFlowBuilderActionContext","getContentsByFirstInteraction","getContents","FlowBuilderAction","botContext","context","contents","filteredContents","contentID","contentsToRender","content","splitContents","aiAgentRouterContent","contentsBeforeAiAgentRouter","aiAgentWorkerContent","contentsBeforeAiAgentWorker","webchatSettingsParams","shouldSendWebchatSettings","Flow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BAE3CV,SAAS,GAAG,CAACI,CAAAA,UAAWA,QAAQ,SAAS,CAACN;;;IAGjD;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action/payload.js","sources":["../../src/action/payload.ts"],"sourcesContent":["import { EventAction, type EventFeedback, storeCaseRating } from '@botonic/core'\nimport { v7 as uuid } from 'uuid'\n\nimport {\n AGENT_RATING_PAYLOAD,\n PUSH_FLOW_PAYLOAD,\n SEPARATOR,\n} from '../constants'\nimport type { FlowContent } from '../content-fields'\nimport type { HtNodeWithContent } from '../content-fields/hubtype-fields'\nimport { trackEvent } from '../tracking'\nimport type { FlowBuilderContext } from './context'\n\nexport async function getContentsByPayload(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request, contentID } = context\n if (request.input.payload?.startsWith(AGENT_RATING_PAYLOAD)) {\n return await resolveRatingPayload(context)\n }\n if (request.input.payload?.startsWith(PUSH_FLOW_PAYLOAD)) {\n return await resolvePushFlowPayload(context)\n }\n\n const id = contentID\n ? cmsApi.getNodeByContentID(contentID)?.id\n : request.input.payload\n const targetNode = id ? cmsApi.getNodeById<HtNodeWithContent>(id) : undefined\n\n if (targetNode) {\n return await flowBuilderPlugin.getContentsByNode(targetNode)\n }\n\n return []\n}\n\nasync function resolveRatingPayload(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request } = context\n\n if (!request.input.payload) {\n return []\n }\n\n const { target, text, value, possibleOptions, possibleValues } =\n flowBuilderPlugin.getRatingSubmittedInfo(request.input.payload)\n\n if (request.session._hubtype_case_id) {\n const event: EventFeedback = {\n action: EventAction.FeedbackCase,\n feedbackTargetId: request.session._hubtype_case_id,\n feedbackGroupId: uuid().toString(),\n possibleOptions,\n possibleValues,\n option: text,\n value,\n }\n\n await storeCaseRating(request.session, value)\n await trackEvent(request, EventAction.FeedbackCase, event)\n }\n\n const targetNode = target\n ? cmsApi.getNodeById<HtNodeWithContent>(target.id)\n : undefined\n\n if (targetNode) {\n return await flowBuilderPlugin.getContentsByNode(targetNode)\n }\n\n return []\n}\n\nasync function resolvePushFlowPayload(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request } = context\n\n if (!request.input.payload) {\n return []\n }\n\n const parts = request.input.payload.split(SEPARATOR)\n const pushFlowId = parts.length > 1 ? parts[1] : ''\n\n if (!pushFlowId) {\n return []\n }\n\n try {\n const pushFlowNode =\n cmsApi.getNodeByCampaignId<HtNodeWithContent>(pushFlowId)\n\n if (!pushFlowNode) {\n return []\n }\n\n return await flowBuilderPlugin.getContentsByNode(pushFlowNode)\n } catch {\n // Campaign not found - return empty to trigger fallback\n return []\n }\n}\n"],"names":["EventAction","storeCaseRating","v7","uuid","AGENT_RATING_PAYLOAD","PUSH_FLOW_PAYLOAD","SEPARATOR","trackEvent","getContentsByPayload","context","cmsApi","flowBuilderPlugin","request","contentID","resolveRatingPayload","resolvePushFlowPayload","id","targetNode","undefined","target","text","value","possibleOptions","possibleValues","event","parts","pushFlowId","pushFlowNode"],"mappings":";;;;;;;;;AAAgF;AAC/C;AAMZ;AAGmB;AAGjC,eAAeQ,oBAAoBA,CACxCC,OAA2B;IAE3B,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGJ;IAC1D,IAAIG,QAAQ,KAAK,CAAC,OAAO,EAAE,WAAWR,oBAAoBA,GAAG;QAC3D,OAAO,MAAMU,oBAAoBA,CAACL;IACpC;IACA,IAAIG,QAAQ,KAAK,CAAC,OAAO,EAAE,WAAWP,iBAAiBA,GAAG;QACxD,OAAO,MAAMU,sBAAsBA,CAACN;IACtC;IAEA,MAAMO,KAAKH,YACPH,OAAO,kBAAkB,CAACG,YAAY,KACtCD,QAAQ,KAAK,CAAC,OAAO;IACzB,MAAMK,aAAaD,KAAKN,OAAO,WAAW,CAAoBM,MAAME;IAEpE,IAAID,YAAY;QACd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IAAI;QACF,MAAMC,eACJjB,OAAO,mBAAmB,CAAoBgB;QAEhD,IAAI,CAACC,cAAc;YACjB,OAAO,EAAE;QACX;QAEA,OAAO,MAAMhB,kBAAkB,iBAAiB,CAACgB;IACnD,EAAE,OAAM;QACN,wDAAwD;QACxD,OAAO,EAAE;IACX;AACF"}
|
package/lib/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sources":["../src/api.ts"],"sourcesContent":["import type { PluginPreRequest } from '@botonic/core'\nimport axios from 'axios'\n\nimport { AI_AGENTS_FLOW_NAME, SEPARATOR, UUID_REGEXP } from './constants'\nimport {\n type HtBotActionNode,\n type HtCaptureUserInputNode,\n type HtFallbackNode,\n type HtFlowBuilderData,\n type HtFlowWebview,\n type HtGoToFlow,\n type HtKeywordNode,\n type HtNodeComponent,\n type HtNodeLink,\n type HtNodeWithContent,\n HtNodeWithContentType,\n type HtPayloadNode,\n type HtRatingButton,\n type HtRatingNode,\n type HtSmartIntentNode,\n} from './content-fields/hubtype-fields'\nimport {\n type FlowBuilderApiOptions,\n type PayloadParamsBase,\n ProcessEnvNodeEnvs,\n} from './types'\nimport { FlowLocale } from './utils/flow-locale'\n\nexport class FlowBuilderApi {\n url: string\n flowUrl: string\n flow: HtFlowBuilderData\n request: PluginPreRequest\n\n private constructor() {}\n\n static async create(options: FlowBuilderApiOptions): Promise<FlowBuilderApi> {\n const newApi = new FlowBuilderApi()\n\n newApi.url = options.url\n newApi.request = options.request\n // TODO: Refactor later to combine logic from `FlowBuilderApi.create`, `resolveFlowUrl` and `getAccessToken` to be in one place\n if (process.env.NODE_ENV === ProcessEnvNodeEnvs.DEVELOPMENT) {\n await newApi.updateSessionWithUserInfo(options.accessToken)\n }\n const updatedRequest = newApi.request\n newApi.flowUrl = options.flowUrl.replace(\n '{bot_id}',\n updatedRequest.session.bot.id\n )\n newApi.flow = options.flow ?? (await newApi.getFlow(options.accessToken))\n return newApi\n }\n\n private async getFlow(token: string): Promise<HtFlowBuilderData> {\n const { data } = await axios.get(this.flowUrl, {\n headers: { Authorization: `Bearer ${token}` },\n })\n return data as HtFlowBuilderData\n }\n\n private async updateSessionWithUserInfo(token: string) {\n const url = `${this.url}/v1/flow_builder/user_info/`\n const response = await axios.get(url, {\n headers: { Authorization: `Bearer ${token}` },\n })\n this.request.session.organization_id = response.data.organization_id\n this.request.session.bot.id = response.data.bot_id\n }\n\n getNodeByFlowId(id: string): HtNodeWithContent {\n const subFlow = this.flow.flows.find(subFlow => subFlow.id === id)\n if (!subFlow) {\n throw Error(`SubFlow with id: '${id}' not found`)\n }\n return this.getNodeById<HtNodeWithContent>(subFlow.start_node_id)\n }\n\n getNodeByCampaignId<T extends HtNodeComponent>(id: string): T {\n const campaign = this.flow.campaigns.find(campaign => campaign.id === id)\n if (!campaign) {\n throw Error(`Campaign with id: '${id}' not found`)\n }\n return this.getNodeById<T>(campaign.start_node_id)\n }\n\n getNodeById<T extends HtNodeComponent>(id: string): T {\n const node = this.flow.nodes.find(node => node.id === id)\n if (!node) {\n console.error(`Node with id: '${id}' not found`)\n }\n\n return node as T\n }\n\n getRatingNodeByButtonId(id: string): HtRatingNode {\n const ratingNodes = this.flow.nodes.filter(\n node => node.type === HtNodeWithContentType.RATING\n ) as HtRatingNode[]\n const ratingNode = ratingNodes.find(node =>\n node.content.buttons.some(button => button.id === id)\n ) as HtRatingNode | undefined\n\n if (!ratingNode) {\n throw Error(`Rating node with button id: '${id}' not found`)\n }\n\n return ratingNode\n }\n\n getRatingButtonById(ratingNode: HtRatingNode, id: string): HtRatingButton {\n const ratingButton = ratingNode.content.buttons.find(\n button => button.id === id\n ) as HtRatingButton | undefined\n if (!ratingButton) {\n throw Error(`Rating button with id: '${id}' not found`)\n }\n\n return ratingButton\n }\n\n getNodeByContentID(contentID: string): HtNodeComponent {\n const content = this.flow.nodes.find(node =>\n 'code' in node ? node.code === contentID : false\n )\n if (!content) {\n throw Error(`Node with contentID: '${contentID}' not found`)\n }\n return content\n }\n\n getStartNode(): HtNodeWithContent {\n const startNodeId = this.flow.start_node_id\n if (!startNodeId) {\n throw new Error('Start node id must be defined')\n }\n return this.getNodeById(startNodeId)\n }\n\n getFallbackNode(alternate: boolean): HtNodeWithContent {\n const fallbackNode = this.flow.nodes.find(\n node => node.type === HtNodeWithContentType.FALLBACK\n ) as HtFallbackNode | undefined\n if (!fallbackNode) {\n throw new Error('Fallback node must be defined')\n }\n const fallbackFirstMessage = fallbackNode.content.first_message\n if (!fallbackFirstMessage) {\n throw new Error('Fallback 1st message must be defined')\n }\n const fallbackSecondMessage = fallbackNode.content.second_message\n if (!fallbackSecondMessage) {\n return this.getNodeById(fallbackFirstMessage.id)\n }\n return alternate\n ? this.getNodeById(fallbackFirstMessage.id)\n : this.getNodeById(fallbackSecondMessage.id)\n }\n\n getSmartIntentNodes(): HtSmartIntentNode[] {\n return this.flow.nodes.filter(\n node => node.type === HtNodeWithContentType.SMART_INTENT\n ) as HtSmartIntentNode[]\n }\n\n getKeywordNodes(): HtKeywordNode[] {\n return this.flow.nodes.filter(\n node => node.type === HtNodeWithContentType.KEYWORD\n ) as HtKeywordNode[]\n }\n\n getPayload(target?: HtNodeLink): string | undefined {\n if (!target) {\n return undefined\n }\n\n return target.id\n }\n\n isBotAction(id: string): boolean {\n if (!this.isUUID(id)) {\n return false\n }\n const node = this.getNodeById(id)\n return node?.type === HtNodeWithContentType.BOT_ACTION\n }\n\n private isUUID(str: string): boolean {\n return UUID_REGEXP.test(str)\n }\n\n createPayloadWithParams(botActionNode: HtBotActionNode): string {\n const payloadId = botActionNode.content.payload_id\n const payloadNode = this.getNodeById<HtPayloadNode>(payloadId)\n const customParams = JSON.parse(\n botActionNode.content.payload_params || '{}'\n )\n\n const contentID = botActionNode.code\n\n const followUpContentID = this.getFollowUpContentID(\n botActionNode.follow_up?.id\n )\n\n const payloadParams: PayloadParamsBase = {\n contentID,\n followUpContentID,\n }\n\n const payloadJson = JSON.stringify({\n ...customParams,\n ...payloadParams,\n })\n return `${payloadNode.content.payload}${SEPARATOR}${payloadJson}`\n }\n\n private getFollowUpContentID(id?: string): string | undefined {\n const followUpNode = id\n ? this.getNodeById<HtNodeWithContent | HtGoToFlow>(id)\n : undefined\n\n return followUpNode?.code\n }\n\n getFlowName(flowId: string): string {\n const flow = this.flow.flows.find(flow => flow.id === flowId)\n return flow ? flow.name : this.getCampaignFlowName(flowId)\n }\n\n getCampaignFlowName(campaignId: string): string {\n const campaign = this.flow.campaigns.find(\n campaign => campaign.id === campaignId\n )\n return campaign ? campaign.name : ''\n }\n\n getStartNodeAiAgentFlow(): HtNodeWithContent | undefined {\n const aiAgentFlow = this.flow.flows.find(\n flow => flow.name === AI_AGENTS_FLOW_NAME\n )\n\n if (!aiAgentFlow) {\n return undefined\n }\n\n return this.getNodeById<HtNodeWithContent>(aiAgentFlow.start_node_id)\n }\n\n isAiAgentEnabled(): boolean {\n return this.flow.is_ai_agent_active || false\n }\n\n getWebviewById(id: string): HtFlowWebview | undefined {\n return this.flow.webviews.find(webview => webview.id === id)\n }\n\n shouldCaptureUserInput(): boolean {\n return !!this.getCaptureUserInputId()\n }\n\n getCaptureUserInputId(): string | undefined {\n return this.request.session.capture_user_input?.node_id\n }\n\n setCaptureUserInputId(id: string): void {\n if (this.request.session.capture_user_input) {\n this.request.session.capture_user_input.node_id = id\n }\n this.request.session.capture_user_input = { node_id: id }\n }\n\n removeCaptureUserInputId(): void {\n this.request.session.capture_user_input = undefined\n }\n\n setUserExtraDataVariable(key: string, value: string): void {\n if (this.request.session.user.extra_data) {\n this.request.session.user.extra_data[key] = value\n }\n }\n\n getCaptureUserInputNode(): HtCaptureUserInputNode | undefined {\n const captureUserInputId = this.getCaptureUserInputId()\n if (!captureUserInputId) {\n return undefined\n }\n return this.getNodeById<HtCaptureUserInputNode>(captureUserInputId)\n }\n\n getResolvedLocale(): string {\n const flowLocales = this.flow.locales\n const defaultLocaleCode = this.flow.default_locale_code\n\n return new FlowLocale(\n this.request,\n flowLocales,\n defaultLocaleCode\n ).resolve()\n }\n}\n"],"names":["axios","AI_AGENTS_FLOW_NAME","SEPARATOR","UUID_REGEXP","HtNodeWithContentType","ProcessEnvNodeEnvs","FlowLocale","FlowBuilderApi","options","newApi","process","updatedRequest","token","data","url","response","id","subFlow","Error","campaign","node","console","ratingNodes","ratingNode","button","ratingButton","contentID","content","startNodeId","alternate","fallbackNode","fallbackFirstMessage","fallbackSecondMessage","target","undefined","str","botActionNode","payloadId","payloadNode","customParams","JSON","followUpContentID","payloadParams","payloadJson","followUpNode","flowId","flow","campaignId","aiAgentFlow","webview","key","value","captureUserInputId","flowLocales","defaultLocaleCode"],"mappings":";;;;;;;;;;;AACyB;AAEgD;AAiBjC;AAKxB;AACgC;AAEzC,MAAMO,cAAcA;IAQzB,aAAa,OAAOC,OAA8B,EAA2B;QAC3E,MAAMC,SAAS,IAAIF,cAAcA;QAEjCE,OAAO,GAAG,GAAGD,QAAQ,GAAG;QACxBC,OAAO,OAAO,GAAGD,QAAQ,OAAO;QAChC,+HAA+H;QAC/H,IAAIE,oBAAoB,KAAKL,8BAA8B,EAAE;YAC3D,MAAMI,OAAO,yBAAyB,CAACD,QAAQ,WAAW;QAC5D;QACA,MAAMG,iBAAiBF,OAAO,OAAO;QACrCA,OAAO,OAAO,GAAGD,QAAQ,OAAO,CAAC,OAAO,CACtC,YACAG,eAAe,OAAO,CAAC,GAAG,CAAC,EAAE;QAE/BF,OAAO,IAAI,GAAGD,QAAQ,IAAI,IAAK,MAAMC,OAAO,OAAO,CAACD,QAAQ,WAAW;QACvE,OAAOC;IACT;IAEA,MAAc,QAAQG,KAAa,EAA8B;QAC/D,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMb,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE;YAC7C,SAAS;gBAAE,eAAe,CAAC,OAAO,EAAEY,OAAO;YAAC;QAC9C;QACA,OAAOC;IACT;IAEA,MAAc,0BAA0BD,KAAa,EAAE;QACrD,MAAME,MAAM,GAAG,IAA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AI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,EAAE;YAC3C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,GAAGA;QACpD;QACA,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,GAAG;YAAE,SAASA;QAAG;IAC1D;IAEA,2BAAiC;QAC/B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,GAAGkB;IAC5C;IAEA,yBAAyBgB,GAAW,EAAEC,KAAa,EAAQ;QACzD,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE;YACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAACD,IAAI,GAAGC;QAC9C;IACF;IAEA,0BAA8D;QAC5D,MAAMC,qBAAqB,IAAI,CAAC,qBAAqB;QACrD,IAAI,CAACA,oBAAoB;YACvB,OAAOlB;QACT;QACA,OAAO,IAAI,CAAC,WAAW,CAAyBkB;IAClD;IAEA,oBAA4B;QAC1B,MAAMC,cAAc,IAAI,CAAC,IAAI,CAAC,OAAO;QACrC,MAAMC,oBAAoB,IAAI,CAAC,IAAI,CAAC,mBAAmB;QAEvD,OAAO,IAAIhD,UAAUA,CACnB,IAAI,CAAC,OAAO,EACZ+C,aACAC,mBACA,OAAO;IACX;IAxQA,aAAsB,CAAC;AAyQzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const FLOW_BUILDER_API_URL_PROD =\n process.env.HUBTYPE_API_URL || 'https://api.hubtype.com'\nexport const SEPARATOR = '|'\nexport const SOURCE_INFO_SEPARATOR = `${SEPARATOR}source_`\nexport const EMPTY_PAYLOAD = 'fb-empty-payload'\nexport const VARIABLE_PATTERN_GLOBAL = /{([^{}]+)}/g\nexport const ACCESS_TOKEN_VARIABLE_KEY = '_access_token'\nexport const REG_EXP_PATTERN = /^\\/(.*)\\/([gimyus]*)$/\nexport const UUID_REGEXP =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\n/* ********** PAYLOADS ********** */\nexport const AGENT_RATING_PAYLOAD = 'agent-rating'\nexport const PUSH_FLOW_PAYLOAD = 'push-flow'\n\n/* ********** FLOW NAMES ********** */\nexport const MAIN_FLOW_NAME = 'Main'\nexport const AI_AGENTS_FLOW_NAME = 'AI Agents'\nexport const FALLBACK_FLOW_NAME = 'Fallback'\n"],"names":["FLOW_BUILDER_API_URL_PROD","process","SEPARATOR","SOURCE_INFO_SEPARATOR","EMPTY_PAYLOAD","VARIABLE_PATTERN_GLOBAL","ACCESS_TOKEN_VARIABLE_KEY","REG_EXP_PATTERN","UUID_REGEXP","AGENT_RATING_PAYLOAD","PUSH_FLOW_PAYLOAD","MAIN_FLOW_NAME","AI_AGENTS_FLOW_NAME","FALLBACK_FLOW_NAME"],"mappings":"AAAO,MAAMA,yBAAyBA,GACpCC,QAAQ,GAAG,CAAC,eAAe,IAAI,0BAAyB;AACnD,MAAMC,SAASA,GAAG,IAAG;AACrB,MAAMC,qBAAqBA,GAAG,GAAGD,SAASA,CAAC,OAAO,CAAC;AACnD,MAAME,aAAaA,GAAG,mBAAkB;AACxC,MAAMC,uBAAuBA,GAAG,cAAa;AAC7C,MAAMC,yBAAyBA,GAAG,gBAAe;AACjD,MAAMC,eAAeA,GAAG,wBAAuB;AAC/C,MAAMC,WAAWA,GACtB,kEAAiE;AAEnE,kCAAkC,GAC3B,MAAMC,oBAAoBA,GAAG,eAAc;AAC3C,MAAMC,iBAAiBA,GAAG,YAAW;AAE5C,oCAAoC,GAC7B,MAAMC,cAAcA,GAAG,OAAM;AAC7B,MAAMC,mBAAmBA,GAAG,YAAW;AACvC,MAAMC,kBAAkBA,GAAG,WAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/content-fields-base.js","sources":["../../src/content-fields/content-fields-base.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\nimport {\n ACCESS_TOKEN_VARIABLE_KEY,\n VARIABLE_PATTERN_GLOBAL,\n} from '../constants'\nimport { ContentFilterExecutor } from '../filters'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport type {\n HtMediaFileLocale,\n HtNodeLink,\n HtQueueLocale,\n HtTextLocale,\n HtVideoLocale,\n} from './hubtype-fields'\nimport type { FlowContent } from './index'\n\nexport abstract class ContentFieldsBase {\n public code: string\n public followUp?: HtNodeLink\n\n constructor(public readonly id: string) {}\n\n abstract trackFlow(botContext: BotContext): Promise<void>\n\n abstract processContent(botContext: BotContext): Promise<void>\n\n async filterContent(\n botContext: BotContext,\n content: FlowContent\n ): Promise<FlowContent> {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const contentFilters = flowBuilderPlugin.contentFilters\n const contentFilterExecutor = new ContentFilterExecutor({\n filters: contentFilters,\n })\n const filteredContent = await contentFilterExecutor.filter(\n botContext,\n content\n )\n return filteredContent\n }\n\n static getTextByLocale(locale: string, text: HtTextLocale[]): string {\n const result = text.find(t => t.locale === locale)\n return result?.message ?? ''\n }\n\n static getAssetByLocale(locale: string, asset: HtMediaFileLocale[]): string {\n const result = asset.find(i => i.locale === locale)\n return result?.file ?? ''\n }\n\n static getVideoByLocale(locale: string, video: HtVideoLocale[]): string {\n const result = video.find(v => v.locale === locale)\n return result?.url ?? ''\n }\n\n static getQueueByLocale(\n locale: string,\n queues: HtQueueLocale[]\n ): HtQueueLocale | undefined {\n return queues.find(queue => queue.locale === locale)\n }\n\n replaceVariables(text: string, botContext: BotContext): string {\n if (!botContext) {\n return text\n }\n\n return text.replace(VARIABLE_PATTERN_GLOBAL, match => {\n // remove \\\\ ( escape for _ ) added by text node with markdown\n const keyPath = match.slice(1, -1).replaceAll('\\\\', '')\n\n const botVariable = keyPath.endsWith(ACCESS_TOKEN_VARIABLE_KEY)\n ? match\n : this.getValueFromKeyPath(botContext, keyPath)\n\n return this.isValidType(botVariable) ? String(botVariable) : match\n })\n }\n\n getValueFromKeyPath(botContext: BotContext, keyPath: string): any {\n if (keyPath.startsWith('session.user.contact_info.')) {\n const name = keyPath.split('.').at(-1)\n return botContext.session.user.contact_info?.find(\n contact => contact.name === name\n )?.value\n }\n\n if (keyPath.startsWith('input.') || keyPath.startsWith('session.')) {\n return keyPath\n .split('.')\n .reduce((object, key) => this.resolveObjectKey(object, key), botContext)\n }\n\n return keyPath\n .split('.')\n .reduce(\n (object, key) => this.resolveObjectKey(object, key),\n botContext.session.user.extra_data\n )\n }\n\n private resolveObjectKey(object: any, key: string): any {\n if (object && object[key] !== undefined) {\n return object[key]\n }\n return undefined\n }\n\n private isValidType(botVariable: any): boolean {\n const validTypes = ['boolean', 'string', 'number']\n return validTypes.includes(typeof botVariable)\n }\n}\n"],"names":["ACCESS_TOKEN_VARIABLE_KEY","VARIABLE_PATTERN_GLOBAL","ContentFilterExecutor","getFlowBuilderPlugin","ContentFieldsBase","botContext","content","flowBuilderPlugin","contentFilters","contentFilterExecutor","filteredContent","locale","text","result","t","asset","i","video","v","queues","queue","match","keyPath","botVariable","String","name","contact","object","key","undefined","validTypes","id"],"mappings":";;;;;;;AAIqB;AAC6B;AACqB;AAUhE,MAAeI,iBAAiBA;IAUrC,MAAM,cACJC,UAAsB,EACtBC,OAAoB,EACE;QACtB,MAAMC,oBAAoBJ,oBAAoBA,CAACE,WAAW,OAAO;QACjE,MAAMG,iBAAiBD,kBAAkB,cAAc;QACvD,MAAME,wBAAwB,IAAIP,qBAAqBA,CAAC;YACtD,SAASM;QACX;QACA,MAAME,kBAAkB,MAAMD,sBAAsB,MAAM,CACxDJ,YACAC;QAEF,OAAOI;IACT;IAEA,OAAO,gBAAgBC,MAAc,EAAEC,IAAoB,EAAU;QACnE,MAAMC,SAASD,KAAK,IAAI,CAACE,CAAAA,IAAKA,EAAE,MAAM,KAAKH;QAC3C,OAAOE,QAAQ,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,MAAQ,IAAI,CAAC,gBAAgB,CAACD,QAAQC,MAAMvB;QACjE;QAEA,OAAOiB,QACJ,KAAK,CAAC,KACN,MAAM,CACL,CAACK,QAAQC,MAAQ,IAAI,CAAC,gBAAgB,CAACD,QAAQC,MAC/CvB,WAAW,OAAO,CAAC,IAAI,CAAC,UAAU;IAExC;IAEQ,iBAAiBsB,MAAW,EAAEC,GAAW,EAAO;QACtD,IAAID,UAAUA,MAAM,CAACC,IAAI,KAAKC,WAAW;YACvC,OAAOF,MAAM,CAACC,IAAI;QACpB;QACA,OAAOC;IACT;IAEQ,YAAYN,WAAgB,EAAW;QAC7C,MAAMO,aAAa;YAAC;YAAW;YAAU;SAAS;QAClD,OAAOA,WAAW,QAAQ,CAAC,OAAOP;IACpC;IA7FA,YAA4BQ,EAAU,CAAE;aAAZA,KAAAA;IAAa;AA8F3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/custom-conditional/custom-conditional-v2-evaluators.js","sources":["../../../src/content-fields/custom-conditional/custom-conditional-v2-evaluators.ts"],"sourcesContent":["import {\n BooleanConditionOperator,\n type HtBooleanCondition,\n type HtNumberCondition,\n type HtStringCondition,\n NumberConditionOperator,\n StringConditionOperator,\n} from '../hubtype-fields'\n\ntype StringEvaluator = (variable: string, value: string) => boolean\n\ntype NumberEvaluator = (\n variable: number,\n value: number,\n condition: HtNumberCondition\n) => boolean\n\ntype BooleanEvaluator = (variable: boolean) => boolean\n\nexport function getMinAndMax(condition: HtNumberCondition): {\n min: number\n max: number\n} {\n if (condition.min !== undefined && condition.max !== undefined) {\n return { min: condition.min, max: condition.max }\n }\n throw new Error(\n `Min or max not found for number condition ${condition.operator}`\n )\n}\n\nexport const STRING_CONDITION_EVALUATORS: Record<\n StringConditionOperator,\n StringEvaluator\n> = {\n [StringConditionOperator.Contains]: (variable, value) =>\n variable.includes(value),\n [StringConditionOperator.NotContains]: (variable, value) =>\n !variable.includes(value),\n [StringConditionOperator.EqualsTo]: (variable, value) => variable === value,\n [StringConditionOperator.NotEqualsTo]: (variable, value) =>\n variable !== value,\n [StringConditionOperator.StartsWith]: (variable, value) =>\n variable.startsWith(value),\n [StringConditionOperator.NotStartsWith]: (variable, value) =>\n !variable.startsWith(value),\n [StringConditionOperator.EndsWith]: (variable, value) =>\n variable.endsWith(value),\n [StringConditionOperator.NotEndsWith]: (variable, value) =>\n !variable.endsWith(value),\n}\n\nexport const NUMBER_CONDITION_EVALUATORS: Record<\n NumberConditionOperator,\n NumberEvaluator\n> = {\n [NumberConditionOperator.EqualsTo]: (variable, value) => variable === value,\n [NumberConditionOperator.NotEqualsTo]: (variable, value) =>\n variable !== value,\n [NumberConditionOperator.GreaterThan]: (variable, value) => variable > value,\n [NumberConditionOperator.LessThan]: (variable, value) => variable < value,\n [NumberConditionOperator.GreaterThanOrEqualTo]: (variable, value) =>\n variable >= value,\n [NumberConditionOperator.LessThanOrEqualTo]: (variable, value) =>\n variable <= value,\n [NumberConditionOperator.Between]: (variable, _value, condition) => {\n const { min, max } = getMinAndMax(condition)\n return variable >= min && variable <= max\n },\n [NumberConditionOperator.NotBetween]: (variable, _value, condition) => {\n const { min, max } = getMinAndMax(condition)\n return variable < min || variable > max\n },\n}\n\nexport const BOOLEAN_CONDITION_EVALUATORS: Record<\n BooleanConditionOperator,\n BooleanEvaluator\n> = {\n [BooleanConditionOperator.IsTruthy]: variable => !!variable,\n}\n\nexport function evaluateStringCondition(\n variable: string,\n condition: HtStringCondition\n): boolean {\n if (condition.value === undefined) {\n throw new Error(\n `Value not found for string condition ${condition.operator}`\n )\n }\n const evaluator = STRING_CONDITION_EVALUATORS[condition.operator]\n if (!evaluator) {\n throw new Error(`Invalid string condition operator ${condition.operator}`)\n }\n return evaluator(variable, condition.value)\n}\n\nexport function evaluateNumberCondition(\n variable: number,\n condition: HtNumberCondition\n): boolean {\n if (condition.value === undefined) {\n throw new Error(\n `Value not found for number condition ${condition.operator}`\n )\n }\n const evaluator = NUMBER_CONDITION_EVALUATORS[condition.operator]\n if (!evaluator) {\n throw new Error(`Invalid number condition operator ${condition.operator}`)\n }\n return evaluator(variable, condition.value, condition)\n}\n\nexport function evaluateBooleanCondition(\n variable: boolean,\n condition: HtBooleanCondition\n): boolean {\n const evaluator = BOOLEAN_CONDITION_EVALUATORS[condition.operator]\n if (!evaluator) {\n throw new Error(`Invalid boolean condition operator ${condition.operator}`)\n }\n return evaluator(variable)\n}\n"],"names":["BooleanConditionOperator","NumberConditionOperator","StringConditionOperator","getMinAndMax","condition","undefined","Error","STRING_CONDITION_EVALUATORS","variable","value","NUMBER_CONDITION_EVALUATORS","_value","min","max","BOOLEAN_CONDITION_EVALUATORS","evaluateStringCondition","evaluator","evaluateNumberCondition","evaluateBooleanCondition"],"mappings":";;;AAO0B;AAYnB,SAASG,YAAYA,CAACC,SAA4B;IAIvD,IAAIA,UAAU,GAAG,KAAKC,aAAaD,UAAU,GAAG,KAAKC,WAAW;QAC9D,OAAO;YAAE,KAAKD,UAAU,GAAG;YAAE,KAAKA,UAAU,GAAG;QAAC;IAClD;IACA,MAAM,IAAIE,MACR,CAAC,0CAA0C,EAAEF,UAAU,QAAQ,EAAE;AAErE;AAEO,MAAMG,2BAA2BA,GAGpC;IACF,CAACL,gCAAgC,CAAC,EAAE,CAACM,UAAUC,QAC7CD,SAAS,QAAQ,CAACC;IACpB,CAACP,mCAAmC,CAAC,EAAE,CAACM,UAAUC,QAChD,CAACD,SAAS,QAAQ,CAACC;IACrB,CAACP,gCAAgC,CAAC,EAAE,CAACM,UAAUC,QAAUD,aAAaC;IACtE,CAACP,mCAAmC,CAAC,EAAE,CAACM,UAAUC,QAChDD,aAAaC;IACf,CAACP,kCAAkC,CAAC,EAAE,CAACM,UAAUC,QAC/CD,SAAS,UAAU,CAACC;IACtB,CAACP,qCAAqC,CAAC,EAAE,CAACM,UAAUC,QAClD,CAACD,SAAS,UAAU,CAACC;IACvB,CAACP,gCAAgC,CAAC,EAAE,CAACM,UAAUC,QAC7CD,SAA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AC3E;IACA,OAAOY,UAAUR,UAAUJ,UAAU,KAAK;AAC5C;AAEO,SAASa,uBAAuBA,CACrCT,QAAgB,EAChBJ,SAA4B;IAE5B,IAAIA,UAAU,KAAK,KAAKC,WAAW;QACjC,MAAM,IAAIC,MACR,CAAC,qCAAqC,EAAEF,UAAU,QAAQ,EAAE;IAEhE;IACA,MAAMY,YAAYN,2BAA2B,CAACN,UAAU,QAAQ,CAAC;IACjE,IAAI,CAACY,WAAW;QACd,MAAM,IAAIV,MAAM,CAAC,kCAAkC,EAAEF,UAAU,QAAQ,EAAE;IAC3E;IACA,OAAOY,UAAUR,UAAUJ,UAAU,KAAK,EAAEA;AAC9C;AAEO,SAASc,wBAAwBA,CACtCV,QAAiB,EACjBJ,SAA6B;IAE7B,MAAMY,YAAYF,4BAA4B,CAACV,UAAU,QAAQ,CAAC;IAClE,IAAI,CAACY,WAAW;QACd,MAAM,IAAIV,MAAM,CAAC,mCAAmC,EAAEF,UAAU,QAAQ,EAAE;IAC5E;IACA,OAAOY,UAAUR;AACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/custom-conditional/custom-conditional-v2-resolver.js","sources":["../../../src/content-fields/custom-conditional/custom-conditional-v2-resolver.ts"],"sourcesContent":["import {\n type HtCondition,\n type HtNodeLink,\n type HtNumberCondition,\n type HtStringCondition,\n NumberConditionOperator,\n VariableFormat,\n} from '../hubtype-fields'\n\nexport type ConditionMatch = {\n customResult: string\n target: HtNodeLink\n operator: string\n}\n\nexport function getConditionCustomResult(\n condition: HtCondition,\n variableFormat: VariableFormat\n): string {\n switch (variableFormat) {\n case VariableFormat.String:\n return String((condition as HtStringCondition).value)\n case VariableFormat.Number:\n return getNumberConditionCustomResult(condition as HtNumberCondition)\n case VariableFormat.Boolean:\n // Only reached after evaluateBooleanCondition succeeds; today that is isTruthy → 'true'\n return 'true'\n default:\n throw new Error(`Invalid variable format ${variableFormat}`)\n }\n}\n\nfunction getNumberConditionCustomResult(condition: HtNumberCondition): string {\n const numberCondition = condition as HtNumberCondition\n if (\n numberCondition.operator === NumberConditionOperator.Between ||\n numberCondition.operator === NumberConditionOperator.NotBetween\n ) {\n return `min: ${numberCondition.min} - max: ${numberCondition.max}`\n }\n return String(numberCondition.value)\n}\n\nexport function findLastMatchingCondition<T extends HtCondition>(\n conditions: T[],\n variable: unknown,\n variableFormat: VariableFormat,\n evaluate: (variable: unknown, condition: T) => boolean\n): ConditionMatch | undefined {\n let lastMatch: ConditionMatch | undefined\n\n for (const condition of conditions) {\n if (!evaluate(variable, condition)) {\n continue\n }\n\n if (!condition.target) {\n continue\n }\n\n lastMatch = {\n customResult: getConditionCustomResult(condition, variableFormat),\n target: condition.target,\n operator: condition.operator,\n }\n }\n\n return lastMatch\n}\n\nexport function resolveWithDefaultTarget(\n match: ConditionMatch | undefined,\n defaultTarget: HtNodeLink,\n nodeCode: string,\n defaultCustomResult: string = 'default'\n): ConditionMatch {\n if (match) {\n return match\n }\n\n if (!defaultTarget) {\n throw new Error(\n `Default target not found for custom condition node ${nodeCode}`\n )\n }\n\n return {\n customResult: defaultCustomResult,\n target: defaultTarget,\n operator: '',\n }\n}\n"],"names":["NumberConditionOperator","VariableFormat","getConditionCustomResult","condition","variableFormat","String","getNumberConditionCustomResult","Error","numberCondition","findLastMatchingCondition","conditions","variable","evaluate","lastMatch","resolveWithDefaultTarget","match","defaultTarget","nodeCode","defaultCustomResult"],"mappings":";;;AAO0B;AAQnB,SAASE,wBAAwBA,CACtCC,SAAsB,EACtBC,cAA8B;IAE9B,OAAQA;QACN,KAAKH,qBAAqB;YACxB,OAAOI,OAAQF,UAAgC,KAAK;QACtD,KAAKF,qBAAqB;YACxB,OAAOK,8BAA8BA,CAACH;QACxC,KAAKF,sBAAsB;YACzB,wFAAwF;YACxF,OAAO;QACT;YACE,MAAM,IAAIM,MAAM,CAAC,wBAAwB,EAAEH,gBAAgB;IAC/D;AACF;AAEA,SAASE,8BAA8BA,CAACH,SAA4B;IAClE,MAAMK,kBAAkBL;IACxB,IACEK,gBAAgB,QAAQ,KAAKR,+BAA+B,IAC5DQ,gBAAgB,QAAQ,KAAKR,kCAAkC,EAC/D;QACA,OAAO,CAAC,KAAK,EAAEQ,gBAAgB,GAAG,CAAC,QAAQ,EAAEA,gBAAgB,GAAG,EAAE;IACpE;IACA,OAAOH,OAAOG,gBAAgB,KAAK;AACrC;AAEO,SAASC,yBAAyBA,CACvCC,UAAe,EACfC,QAAiB,EACjBP,cAA8B,EAC9BQ,QAAsD;IAEtD,IAAIC;IAEJ,KAAK,MAAMV,aAAaO,WAAY;QAClC,IAAI,CAACE,SAASD,UAAUR,YAAY;YAClC;QACF;QAEA,IAAI,CAACA,UAAU,MAAM,EAAE;YACrB;QACF;QAEAU,YAAY;YACV,cAAcX,wBAAwBA,CAACC,WAAWC;YAClD,QAAQD,UAAU,MAAM;YACxB,UAAUA,UAAU,QAAQ;QAC9B;IACF;IAEA,OAAOU;AACT;AAEO,SAASC,wBAAwBA,CACtCC,KAAiC,EACjCC,aAAyB,EACzBC,QAAgB,EAChBC,sBAA8B,SAAS;IAEvC,IAAIH,OAAO;QACT,OAAOA;IACT;IAEA,IAAI,CAACC,eAAe;QAClB,MAAM,IAAIT,MACR,CAAC,mDAAmD,EAAEU,UAAU;IAEpE;IAEA,OAAO;QACL,cAAcC;QACd,QAAQF;QACR,UAAU;IACZ;AACF"}
|
package/lib/{esm/content-fields → content-fields}/custom-conditional/flow-custom-condition-v2.d.ts
RENAMED
|
@@ -13,5 +13,5 @@ export declare class FlowCustomConditionalV2 extends ContentFieldsBase {
|
|
|
13
13
|
private evaluateConditions;
|
|
14
14
|
trackFlow(botContext: BotContext): Promise<void>;
|
|
15
15
|
processContent(botContext: BotContext): Promise<void>;
|
|
16
|
-
toBotonic(): import("react
|
|
16
|
+
toBotonic(): import("react").JSX.Element;
|
|
17
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/custom-conditional/flow-custom-condition-v2.js","sources":["../../../src/content-fields/custom-conditional/flow-custom-condition-v2.tsx"],"sourcesContent":["import {\n type BotContext,\n EventAction,\n type EventConditionalCustom,\n} from '@botonic/core'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../../tracking'\nimport { ContentFieldsBase } from '../content-fields-base'\nimport {\n type HtBooleanCondition,\n type HtCondition,\n type HtCustomConditionalV2Node,\n type HtNodeLink,\n type HtNumberCondition,\n type HtStringCondition,\n VariableFormat,\n} from '../hubtype-fields'\nimport {\n evaluateBooleanCondition,\n evaluateNumberCondition,\n evaluateStringCondition,\n} from './custom-conditional-v2-evaluators'\nimport {\n type ConditionMatch,\n findLastMatchingCondition,\n resolveWithDefaultTarget,\n} from './custom-conditional-v2-resolver'\n\nexport class FlowCustomConditionalV2 extends ContentFieldsBase {\n public variableFormat: VariableFormat\n public keyPath: string\n public conditions: HtCondition[]\n public defaultTarget: HtNodeLink\n public customResult = ''\n public resolvedOperator = ''\n\n static fromHubtypeCMS(\n component: HtCustomConditionalV2Node,\n botContext: BotContext\n ): FlowCustomConditionalV2 {\n const newCustomConditionalV2 = new FlowCustomConditionalV2(component.id)\n newCustomConditionalV2.code = component.code\n newCustomConditionalV2.variableFormat = component.content.type\n newCustomConditionalV2.keyPath = component.content.key_path\n newCustomConditionalV2.conditions = component.content.conditions\n newCustomConditionalV2.defaultTarget = component.content.default_target\n newCustomConditionalV2.setFollowUp(botContext)\n\n return newCustomConditionalV2\n }\n\n private setFollowUp(botContext: BotContext): void {\n const botVariable = this.getValueFromKeyPath(botContext, this.keyPath)\n const resolved = this.evaluateConditions(botVariable)\n\n this.customResult = resolved.customResult\n this.resolvedOperator = resolved.operator\n this.followUp = resolved.target\n }\n\n private evaluateConditions(botVariable: unknown): ConditionMatch {\n switch (this.variableFormat) {\n case VariableFormat.String: {\n const match = findLastMatchingCondition(\n this.conditions as HtStringCondition[],\n botVariable,\n this.variableFormat,\n (variable, condition) =>\n evaluateStringCondition(variable as string, condition)\n )\n return resolveWithDefaultTarget(match, this.defaultTarget, this.code)\n }\n case VariableFormat.Number: {\n const match = findLastMatchingCondition(\n this.conditions as HtNumberCondition[],\n botVariable,\n this.variableFormat,\n (variable, condition) =>\n evaluateNumberCondition(variable as number, condition)\n )\n return resolveWithDefaultTarget(match, this.defaultTarget, this.code)\n }\n case VariableFormat.Boolean: {\n const match = findLastMatchingCondition(\n this.conditions as HtBooleanCondition[],\n botVariable,\n this.variableFormat,\n (variable, condition) =>\n evaluateBooleanCondition(variable as boolean, condition)\n )\n return resolveWithDefaultTarget(\n match,\n this.defaultTarget,\n this.code,\n 'false'\n )\n }\n default:\n throw new Error(\n `Invalid variable format ${this.variableFormat} for custom condition node ${this.code}`\n )\n }\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const eventCustomConditional: EventConditionalCustom = {\n action: EventAction.ConditionalCustom,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n conditionalVariable: this.customResult,\n variableFormat: this.variableFormat,\n operator: this.resolvedOperator,\n }\n const { action, ...eventArgs } = eventCustomConditional\n await trackEvent(botContext, action, eventArgs)\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic() {\n return <></>\n }\n}\n"],"names":["EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","ContentFieldsBase","VariableFormat","evaluateBooleanCondition","evaluateNumberCondition","evaluateStringCondition","findLastMatchingCondition","resolveWithDefaultTarget","FlowCustomConditionalV2","component","botContext","newCustomConditionalV2","botVariable","resolved","match","variable","condition","Error","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","eventCustomConditional","action","eventArgs"],"mappings":";;;;;;;;;;;;;;;;AAIsB;AAIC;AACmC;AAShC;AAKiB;AAKF;AAElC,M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ACO,OAAO,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI;gBACtE;YACA,KAAKZ,sBAAsB;gBAAE;oBAC3B,MAAMY,QAAQR,yBAAyBA,CACrC,IAAI,CAAC,UAAU,EACfM,aACA,IAAI,CAAC,cAAc,EACnB,CAACG,UAAUC,YACTb,wBAAwBA,CAACY,UAAqBC;oBAElD,OAAOT,wBAAwBA,CAC7BO,OACA,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,IAAI,EACT;gBAEJ;YACA;gBACE,MAAM,IAAIG,MACR,CAAC,wBAAwB,EAAE,IAAI,CAAC,cAAc,CAAC,2BAA2B,EAAE,IAAI,CAAC,IAAI,EAAE;QAE7F;IACF;IAEA,MAAM,UAAUP,UAAsB,EAAiB;QACrD,MAAM,EAAEQ,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GACrEvB,yCAAyCA,CAACW,YAAY,IAAI,CAAC,EAAE;QAE/D,MAAMa,yBAAiD;YACrD,QAAQzB,6BAA6B;YACrCoB;YACAC;YACAC;YACAC;YACAC;YACA,sBAAsB;YACtB,qBAAqB,IAAI,CAAC,YAAY;YACtC,gBAAgB,IAAI,CAAC,cAAc;YACnC,UAAU,IAAI,CAAC,gBAAgB;QACjC;QACA,MAAM,EAAEE,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMvB,UAAUA,CAACU,YAAYc,QAAQC;IACvC;IAEA,MAAM,eAAef,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAY;QACV,qBAAO;IACT;;QAxGK,qBAKE,eAAe,SACf,mBAAmB;;AAmG5B"}
|
|
@@ -6,6 +6,9 @@ import { HubtypeAssistantContent } from "../utils/hubtype-assistant-content.js";
|
|
|
6
6
|
import { ContentFieldsBase } from "./content-fields-base.js";
|
|
7
7
|
import { FlowCarousel } from "./flow-carousel.js";
|
|
8
8
|
import { FlowText } from "./flow-text.js";
|
|
9
|
+
import { FlowWhatsappRequestContactInfoNode } from "./flow-whatsapp-request-contact-info.js";
|
|
10
|
+
|
|
11
|
+
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -51,6 +54,9 @@ class FlowAiAgentBase extends ContentFieldsBase {
|
|
|
51
54
|
if (message.type === OutputMessageType.Carousel) {
|
|
52
55
|
this.jsxElements.push(FlowCarousel.fromAIAgent(this.id, message, botContext));
|
|
53
56
|
}
|
|
57
|
+
if (message.type === OutputMessageType.RequestContactInfo) {
|
|
58
|
+
this.jsxElements.push(FlowWhatsappRequestContactInfoNode.fromAIAgent(this.id, message, botContext));
|
|
59
|
+
}
|
|
54
60
|
if (message.type === FlowBuilderOutputMessageType.FlowBuilderContent) {
|
|
55
61
|
const flowContents = await this.getFlowContentsByContentId(botContext, message.contentId);
|
|
56
62
|
for (const content of flowContents){
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-ai-agent-base.js","sources":["../../src/content-fields/flow-ai-agent-base.tsx"],"sourcesContent":["import {\n type AgenticOutputMessage,\n type BotContext,\n type GuardrailRule,\n type HubtypeAssistantMessage,\n type InferenceResponse,\n OutputMessageType,\n VerbosityLevel,\n} from '@botonic/core'\nimport {\n type FlowBuilderContentMessage,\n FlowBuilderOutputMessageType,\n} from '../structured-output/flow-builder-content'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { HubtypeAssistantContent } from '../utils/hubtype-assistant-content'\nimport { ContentFieldsBase } from './content-fields-base'\nimport { FlowCarousel } from './flow-carousel'\nimport { FlowText } from './flow-text'\nimport { FlowWhatsappRequestContactInfoNode } from './flow-whatsapp-request-contact-info'\nimport type { HtInputGuardrailRule, HtNodeWithContent } from './hubtype-fields'\nimport type { FlowContent } from './index'\n\nexport abstract class FlowAiAgentBase extends ContentFieldsBase {\n public name: string = ''\n public instructions: string = ''\n public model: string = ''\n public verbosity: VerbosityLevel = VerbosityLevel.Medium\n public inputGuardrailRules: HtInputGuardrailRule[] = []\n\n public aiAgentResponse?: InferenceResponse<FlowBuilderContentMessage>\n public messages: AgenticOutputMessage<FlowBuilderContentMessage>[] = []\n public jsxElements: JSX.Element[] = []\n\n abstract getAIAgentResponse(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined>\n\n abstract trackAiAgentResponse(botContext: BotContext): Promise<void>\n\n async resolveAIAgentResponse(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {\n const aiAgentResponse = await this.getAIAgentResponse(\n botContext,\n previousContents\n )\n\n if (aiAgentResponse) {\n this.aiAgentResponse = aiAgentResponse\n await this.trackAiAgentResponse(botContext)\n this.messages = aiAgentResponse.messages\n }\n\n return aiAgentResponse\n }\n\n async trackFlow(_botContext: BotContext): Promise<void> {\n return\n }\n\n async getFlowContentsByContentId(\n botContext: BotContext,\n contentId: string\n ): Promise<FlowContent[]> {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n const node = cmsApi.getNodeByContentID(contentId)\n const flowContents = await flowBuilderPlugin.getContentsByNode(\n node as HtNodeWithContent\n )\n\n return flowContents\n }\n\n async messagesToBotonicJSXElements(botContext: BotContext): Promise<void> {\n for (const message of this.messages) {\n if (\n message.type === OutputMessageType.Text ||\n message.type === OutputMessageType.TextWithButtons ||\n message.type === OutputMessageType.BotExecutor\n ) {\n this.jsxElements.push(FlowText.fromAIAgent(this.id, message))\n }\n\n if (message.type === OutputMessageType.Carousel) {\n this.jsxElements.push(\n FlowCarousel.fromAIAgent(this.id, message, botContext)\n )\n }\n\n if (message.type === OutputMessageType.RequestContactInfo) {\n this.jsxElements.push(\n FlowWhatsappRequestContactInfoNode.fromAIAgent(\n this.id,\n message,\n botContext\n )\n )\n }\n\n if (message.type === FlowBuilderOutputMessageType.FlowBuilderContent) {\n const flowContents = await this.getFlowContentsByContentId(\n botContext,\n message.contentId\n )\n for (const content of flowContents) {\n await content.processContent(botContext)\n this.jsxElements.push(content.toBotonic(botContext))\n }\n }\n }\n return\n }\n\n async processContent(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<void> {\n if (this.messages.length === 0) {\n await this.resolveAIAgentResponse(botContext, previousContents)\n }\n if (this.jsxElements.length === 0) {\n await this.filterContent(botContext, this as unknown as FlowContent)\n await this.messagesToBotonicJSXElements(botContext)\n }\n return\n }\n\n toBotonic(): JSX.Element {\n return <>{this.jsxElements}</>\n }\n\n protected getPreviousHubtypeContents(\n previousContents?: FlowContent[]\n ): HubtypeAssistantMessage[] {\n return (\n previousContents?.map(content => {\n return {\n role: 'assistant',\n content: HubtypeAssistantContent.adapt(content),\n }\n }) || []\n )\n }\n\n protected getActiveInputGuardrailRules(\n inputGuardrailRules: HtInputGuardrailRule[]\n ): GuardrailRule[] {\n return (\n inputGuardrailRules\n ?.filter(rule => rule.is_active)\n ?.map(rule => ({\n name: rule.name,\n description: rule.description,\n })) || []\n )\n }\n}\n"],"names":["OutputMessageType","VerbosityLevel","FlowBuilderOutputMessageType","getFlowBuilderPlugin","HubtypeAssistantContent","ContentFieldsBase","FlowCarousel","FlowText","FlowWhatsappRequestContactInfoNode","FlowAiAgentBase","botContext","previousContents","aiAgentResponse","_botContext","contentId","flowBuilderPlugin","cmsApi","node","flowContents","message","content","inputGuardrailRules","rule"],"mappings":";;;;;;;;;;;;;;;;;;;;AAQsB;AAI4B;AACqB;AACK;AACnB;AACX;AACR;AACmD;AAIlF,MAAeS,eAAeA,SAASJ,iBAAiBA;IAkB7D,MAAM,uBACJK,UAAsB,EACtBC,gBAAgC,EACmC;QACnE,MAAMC,kBAAkB,MAAM,IAAI,CAAC,kBAAkB,CACnDF,YACAC;QAGF,IAAIC,iBAAiB;YACnB,IAAI,CAAC,eAAe,GAAGA;YACvB,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AS,CAACV;gBAC1C;YACF;QACF;QACA;IACF;IAEA,MAAM,eACJA,UAAsB,EACtBC,gBAAgC,EACjB;QACf,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG;YAC9B,MAAM,IAAI,CAAC,sBAAsB,CAACD,YAAYC;QAChD;QACA,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,GAAG;YACjC,MAAM,IAAI,CAAC,aAAa,CAACD,YAAY,IAAI;YACzC,MAAM,IAAI,CAAC,4BAA4B,CAACA;QAC1C;QACA;IACF;IAEA,YAAyB;QACvB,qBAAO;sBAAG,IAAI,CAAC,WAAW;;IAC5B;IAEU,2BACRC,gBAAgC,EACL;QAC3B,OACEA,kBAAkB,IAAIS,CAAAA;YACpB,OAAO;gBACL,MAAM;gBACN,SAAShB,6BAA6B,CAACgB;YACzC;QACF,MAAM,EAAE;IAEZ;IAEU,6BACRC,mBAA2C,EAC1B;QACjB,OACEA,qBACI,OAAOC,CAAAA,OAAQA,KAAK,SAAS,GAC7B,IAAIA,CAAAA,OAAS;gBACb,MAAMA,KAAK,IAAI;gBACf,aAAaA,KAAK,WAAW;YAC/B,OAAO,EAAE;IAEf;;QAxIK,qBACE,OAAe,SACf,eAAuB,SACvB,QAAgB,SAChB,YAA4BrB,qBAAqB,OACjD,sBAA8C,EAAE,OAGhD,WAA8D,EAAE,OAChE,cAA6B,EAAE;;AAgIxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-ai-agent-router.js","sources":["../../src/content-fields/flow-ai-agent-router.tsx"],"sourcesContent":["import {\n AiAgentType,\n type BotContext,\n EventAction,\n type EventAiAgent,\n type EventAiAgentRouter,\n type InferenceResponse,\n} from '@botonic/core'\nimport {\n type FlowBuilderContentMessage,\n FlowBuilderContentSchema,\n} from '../structured-output/flow-builder-content'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { FlowAiAgent } from './flow-ai-agent'\nimport { FlowAiAgentBase } from './flow-ai-agent-base'\nimport type { HtAiAgentNode, HtAiAgentRouterNode } from './hubtype-fields'\nimport type { FlowContent } from './index'\n\nexport interface AvailableSpecialists {\n agent: FlowAiAgent\n description: string\n name: string\n}\n\nexport class FlowAiAgentRouter extends FlowAiAgentBase {\n public availableSpecialists: AvailableSpecialists[] = []\n\n static fromHubtypeCMS(\n component: HtAiAgentRouterNode,\n botContext: BotContext\n ): FlowAiAgentRouter {\n const newAiAgentRouter = new FlowAiAgentRouter(component.id)\n newAiAgentRouter.code = component.code\n newAiAgentRouter.name = component.content.name\n newAiAgentRouter.instructions = newAiAgentRouter.replaceVariables(\n component.content.instructions,\n botContext\n )\n newAiAgentRouter.model = component.content.model\n newAiAgentRouter.verbosity = component.content.verbosity\n newAiAgentRouter.availableSpecialists =\n FlowAiAgentRouter.getAvailableSpecialistsFromHubtypeCMS(\n component,\n botContext\n )\n newAiAgentRouter.inputGuardrailRules =\n component.content.input_guardrail_rules || []\n return newAiAgentRouter\n }\n\n private static getAvailableSpecialistsFromHubtypeCMS(\n component: HtAiAgentRouterNode,\n botContext: BotContext\n ): AvailableSpecialists[] {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n\n return component.content.available_specialists.map((agentSlot, index) => {\n const aiAgentSpecialistNode = cmsApi.getNodeById<HtAiAgentNode>(\n agentSlot.target.id\n )\n const specialist = FlowAiAgent.fromHubtypeCMS(\n aiAgentSpecialistNode,\n botContext\n )\n const specialistName = FlowAiAgentRouter.specialistAgentBaseName(\n agentSlot.name,\n index\n )\n const specialistDescription = specialist.replaceVariables(\n agentSlot.description || `Transfer to ${specialistName}`,\n botContext\n )\n\n return {\n agent: specialist,\n description: specialistDescription,\n name: `transfer_to_${specialistName}`,\n }\n })\n }\n\n private static specialistAgentBaseName(\n name: string | undefined,\n index: number\n ): string {\n return name?.trim().toLowerCase().replace(/ /g, '_') || `ai_agent_${index}`\n }\n\n async getAIAgentResponse(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const aiAgentResponse = await flowBuilderPlugin.getAiAgentResponse?.(\n botContext,\n {\n type: AiAgentType.Router,\n name: this.name,\n instructions: this.instructions,\n model: this.model,\n verbosity: this.verbosity,\n specialists: this.availableSpecialists.map(\n ({ agent, description, name }) => ({\n type: AiAgentType.Specialist,\n name,\n description,\n instructions: agent.instructions,\n model: agent.model,\n verbosity: agent.verbosity,\n activeTools: agent.activeTools ?? [],\n inputGuardrailRules: this.getActiveInputGuardrailRules(\n agent.inputGuardrailRules\n ),\n sourceIds: agent.sources?.map(s => s.id) ?? [],\n })\n ),\n inputGuardrailRules: this.getActiveInputGuardrailRules(\n this.inputGuardrailRules\n ),\n outputMessagesSchemas: [FlowBuilderContentSchema],\n previousHubtypeMessages:\n this.getPreviousHubtypeContents(previousContents),\n }\n )\n\n return aiAgentResponse\n }\n\n async trackAiAgentResponse(botContext: BotContext) {\n const isTransferredToSpecialist =\n this.aiAgentResponse?.isTransferredToSpecialist ?? false\n\n await this.trackAIAgentRouterEvent(botContext, isTransferredToSpecialist)\n\n if (isTransferredToSpecialist) {\n await this.trackAIAgentSpecialistEvent(botContext)\n }\n }\n\n private async trackAIAgentRouterEvent(\n botContext: BotContext,\n isTransferredToSpecialist: boolean\n ) {\n const { flowThreadId, flowId, flowName, flowNodeId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const routerEvent: EventAiAgentRouter = {\n action: EventAction.AiAgentRouter,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId: this.name,\n flowNodeIsMeaningful: true,\n memoryLength: this.aiAgentResponse?.memoryLength ?? 0,\n inputMessageId: botContext.input.message_id!,\n exit: this.aiAgentResponse?.exit ?? true,\n error: this.aiAgentResponse?.error ?? false,\n inputGuardrailsTriggered:\n this.aiAgentResponse?.inputGuardrailsTriggered ?? [],\n outputGuardrailsTriggered:\n this.aiAgentResponse?.outputGuardrailsTriggered ?? [],\n startingAgentName: this.aiAgentResponse?.startingAgentName || this.name,\n lastAgentName: this.aiAgentResponse?.lastAgentName || this.name,\n availableSpecialists: this.aiAgentResponse?.availableSpecialists ?? [],\n isTransferredToSpecialist,\n }\n const { action, ...routerEventArgs } = routerEvent\n await trackEvent(botContext, action, routerEventArgs)\n }\n\n private async trackAIAgentSpecialistEvent(botContext: BotContext) {\n const { flowThreadId, flowId, flowName, flowNodeId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const specialistEvent: EventAiAgent = {\n action: EventAction.AiAgent,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId: this.aiAgentResponse?.lastAgentName ?? '',\n flowNodeIsMeaningful: true,\n toolsExecuted: this.aiAgentResponse?.toolsExecuted ?? [],\n memoryLength: this.aiAgentResponse?.memoryLength ?? 0,\n inputMessageId: botContext.input.message_id!,\n exit: this.aiAgentResponse?.exit ?? true,\n error: this.aiAgentResponse?.error ?? false,\n inputGuardrailsTriggered: [],\n outputGuardrailsTriggered:\n this.aiAgentResponse?.outputGuardrailsTriggered ?? [],\n }\n const { action, ...specialistEventArgs } = specialistEvent\n await trackEvent(botContext, action, specialistEventArgs)\n }\n}\n"],"names":["AiAgentType","EventAction","FlowBuilderContentSchema","getCommonFlowContentEventArgsForContentId","trackEvent","getFlowBuilderPlugin","FlowAiAgent","FlowAiAgentBase","FlowAiAgentRouter","component","botContext","newAiAgentRouter","flowBuilderPlugin","cmsApi","agentSlot","index","aiAgentSpecialistNode","specialist","specialistName","specialistDescription","name","previousContents","aiAgentResponse","agent","description","s","isTransferredToSpecialist","flowThreadId","flowId","flowName","flowNodeId","routerEvent","action","routerEventArgs","specialistEvent","specialistEventArgs"],"mappings":";;;;;;;;;;;;;AAOsB;AAI4B;AAI9B;AAC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,MAAM,IAAI,CAAC,eAAe,EAAE,QAAQ;YACpC,OAAO,IAAI,CAAC,eAAe,EAAE,SAAS;YACtC,0BAA0B,EAAE;YAC5B,2BACE,IAAI,CAAC,eAAe,EAAE,6BAA6B,EAAE;QACzD;QACA,MAAM,EAAEsB,MAAM,EAAE,GAAGG,qBAAqB,GAAGD;QAC3C,MAAM9B,UAAUA,CAACM,YAAYsB,QAAQG;IACvC;;QA3KK,qBACE,uBAA+C,EAAE;;AA2K1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-ai-agent.js","sources":["../../src/content-fields/flow-ai-agent.tsx"],"sourcesContent":["import {\n AiAgentType,\n type BotContext,\n EventAction,\n type EventAiAgent,\n type InferenceResponse,\n} from '@botonic/core'\nimport {\n type FlowBuilderContentMessage,\n FlowBuilderContentSchema,\n} from '../structured-output/flow-builder-content'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { FlowAiAgentBase } from './flow-ai-agent-base'\nimport type { HtAiAgentNode } from './hubtype-fields/ai-agent'\nimport type { FlowContent } from './index'\n\nexport class FlowAiAgent extends FlowAiAgentBase {\n public activeTools?: { name: string }[]\n public sources?: { id: string; name: string }[]\n\n static fromHubtypeCMS(\n component: HtAiAgentNode,\n botContext: BotContext\n ): FlowAiAgent {\n const newAiAgent = new FlowAiAgent(component.id)\n newAiAgent.code = component.code\n newAiAgent.name = component.content.name\n newAiAgent.instructions = newAiAgent.replaceVariables(\n component.content.instructions,\n botContext\n )\n newAiAgent.model = component.content.model\n newAiAgent.verbosity = component.content.verbosity\n newAiAgent.activeTools = component.content.active_tools\n newAiAgent.inputGuardrailRules =\n component.content.input_guardrail_rules || []\n newAiAgent.sources = component.content.sources\n newAiAgent.followUp = component.follow_up\n\n return newAiAgent\n }\n\n async getAIAgentResponse(\n botContext: BotContext,\n previousContents?: FlowContent[]\n ): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {\n const activeInputGuardrailRules = this.getActiveInputGuardrailRules(\n this.inputGuardrailRules\n )\n\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n\n const aiAgentResponse = await flowBuilderPlugin.getAiAgentResponse?.(\n botContext,\n {\n type: AiAgentType.Specialist,\n name: this.name,\n instructions: this.instructions,\n model: this.model,\n verbosity: this.verbosity,\n activeTools: this.activeTools ?? [],\n inputGuardrailRules: activeInputGuardrailRules,\n sourceIds: this.sources?.map(source => source.id) ?? [],\n outputMessagesSchemas: [FlowBuilderContentSchema],\n previousHubtypeMessages:\n this.getPreviousHubtypeContents(previousContents),\n }\n )\n\n return aiAgentResponse\n }\n\n async trackAiAgentResponse(botContext: BotContext) {\n const { flowThreadId, flowId, flowName, flowNodeId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const event: EventAiAgent = {\n action: EventAction.AiAgent,\n flowThreadId: flowThreadId,\n flowId: flowId,\n flowName: flowName,\n flowNodeId: flowNodeId,\n flowNodeContentId: this.name,\n flowNodeIsMeaningful: true,\n toolsExecuted: this.aiAgentResponse?.toolsExecuted ?? [],\n memoryLength: this.aiAgentResponse?.memoryLength ?? 0,\n inputMessageId: botContext.input.message_id!,\n exit: this.aiAgentResponse?.exit ?? true,\n inputGuardrailsTriggered:\n this.aiAgentResponse?.inputGuardrailsTriggered ?? [],\n outputGuardrailsTriggered: [], //aiAgentResponse.outputGuardrailsTriggered,\n error: this.aiAgentResponse?.error ?? false,\n }\n const { action, ...eventArgs } = event\n\n await trackEvent(botContext, action, eventArgs)\n }\n}\n"],"names":["AiAgentType","EventAction","FlowBuilderContentSchema","getCommonFlowContentEventArgsForContentId","trackEvent","getFlowBuilderPlugin","FlowAiAgentBase","FlowAiAgent","component","botContext","newAiAgent","previousContents","activeInputGuardrailRules","flowBuilderPlugin","aiAgentResponse","source","flowThreadId","flowId","flowName","flowNodeId","event","action","eventArgs"],"mappings":";;;;;;;;;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AAI,CAAC,0BAA0B,CAACS;QACpC;QAGF,OAAOG;IACT;IAEA,MAAM,qBAAqBL,UAAsB,EAAE;QACjD,MAAM,EAAEO,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAE,GAClDhB,yCAAyCA,CAACM,YAAY,IAAI,CAAC,EAAE;QAE/D,MAAMW,QAAsB;YAC1B,QAAQnB,mBAAmB;YAC3B,cAAce;YACd,QAAQC;YACR,UAAUC;YACV,YAAYC;YACZ,mBAAmB,IAAI,CAAC,IAAI;YAC5B,sBAAsB;YACtB,eAAe,IAAI,CAAC,eAAe,EAAE,iBAAiB,EAAE;YACxD,cAAc,IAAI,CAAC,eAAe,EAAE,gBAAgB;YACpD,gBAAgBV,WAAW,KAAK,CAAC,UAAU;YAC3C,MAAM,IAAI,CAAC,eAAe,EAAE,QAAQ;YACpC,0BACE,IAAI,CAAC,eAAe,EAAE,4BAA4B,EAAE;YACtD,2BAA2B,EAAE;YAC7B,OAAO,IAAI,CAAC,eAAe,EAAE,SAAS;QACxC;QACA,MAAM,EAAEY,MAAM,EAAE,GAAGC,WAAW,GAAGF;QAEjC,MAAMhB,UAAUA,CAACK,YAAYY,QAAQC;IACvC;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-bot-action.js","sources":["../../src/content-fields/flow-bot-action.tsx"],"sourcesContent":["import {\n type BotContext,\n BotonicAction,\n EventAction,\n type EventBotAction,\n} from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type { HtBotActionNode } from './hubtype-fields'\n\nexport class FlowBotAction extends ContentFieldsBase {\n public code: string\n public payload: string\n\n static fromHubtypeCMS(\n cmsBotAction: HtBotActionNode,\n cmsApi: FlowBuilderApi\n ): FlowBotAction {\n const newBotAction = new FlowBotAction(cmsBotAction.id)\n newBotAction.code = cmsBotAction.code\n newBotAction.payload = cmsApi.createPayloadWithParams(cmsBotAction)\n newBotAction.followUp = cmsBotAction.follow_up\n\n return newBotAction\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n const eventBotAction: EventBotAction = {\n action: EventAction.BotAction,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n payload: this.payload,\n }\n const { action, ...eventArgs } = eventBotAction\n await trackEvent(botContext, action, eventArgs)\n }\n\n doBotAction(botContext: ActionRequest): void {\n botContext.session._botonic_action = `${BotonicAction.Redirect}:${this.payload}`\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n this.doBotAction(botContext)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(): JSX.Element {\n return <></>\n }\n}\n"],"names":["BotonicAction","EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","ContentFieldsBase","FlowBotAction","cmsBotAction","cmsApi","newBotAction","botContext","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","eventBotAction","action","eventArgs"],"mappings":";;;;;;;;;;AAKsB;AAOF;AACqC;AAGlD,MAAMK,aAAaA,SAASD,iBAAiBA;IAIlD,OAAO,eACLE,YAA6B,EAC7BC,MAAsB,EACP;QACf,MAAMC,eAAe,IAAIH,aAAaA,CAACC,aAAa,EAAE;QACtDE,aAAa,IAAI,GAAGF,aAAa,IAAI;QACrCE,aAAa,OAAO,GAAGD,OAAO,uBAAuB,CAACD;QACtDE,aAAa,QAAQ,GAAGF,aAAa,SAAS;QAE9C,OAAOE;IACT;IAEA,MAAM,UAAUC,UAAsB,EAAiB;QACrD,MAAM,EAAEC,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GACrEZ,yCAAyCA,CAACO,YAAY,IAAI,CAAC,EAAE;QAC/D,MAAMM,iBAAiC;YACrC,QAAQd,qBAAqB;YAC7BS;YACAC;YACAC;YACAC;YACAC;YACA,sBAAsB;YACtB,SAAS,IAAI,CAAC,OAAO;QACvB;QACA,MAAM,EAAEE,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMZ,UAAUA,CAACM,YAAYO,QAAQC;IACvC;IAEA,YAAYR,UAAyB,EAAQ;QAC3CA,WAAW,OAAO,CAAC,eAAe,GAAG,GAAGT,sBAAsB,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE;IAClF;IAEA,MAAM,eAAeS,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,IAAI,CAAC,WAAW,CAACA;QACjB,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAyB;QACvB,qBAAO;IACT;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-button.js","sources":["../../src/content-fields/flow-button.tsx"],"sourcesContent":["import type { BotContext } from '@botonic/core'\nimport { Button, Reply, type Webview } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport { SOURCE_INFO_SEPARATOR } from '../constants'\nimport { ContentFieldsBase } from './content-fields-base'\nimport { FlowWebview } from './flow-webview'\nimport {\n type HtButton,\n HtButtonStyle,\n HtNodeWithContentType,\n type HtUrlNode,\n} from './hubtype-fields'\nimport type { HtRatingButton } from './hubtype-fields/rating'\n\nexport class FlowButton extends ContentFieldsBase {\n public text = ''\n public url?: string\n public payload?: string\n public target?: string\n public webview?: Webview\n public flowWebview?: FlowWebview // Used for tracking\n public params?: Record<string, string>\n\n static fromHubtypeCMS(\n cmsButton: HtButton,\n locale: string,\n cmsApi: FlowBuilderApi,\n botContext: BotContext\n ): FlowButton {\n const urlId = FlowButton.getUrlId(cmsButton, locale)\n\n const newButton = new FlowButton(cmsButton.id)\n newButton.text = FlowButton.getTextByLocale(locale, cmsButton.text)\n if (cmsButton.target) {\n const webview = FlowButton.getTargetWebview(cmsApi, cmsButton.target.id)\n if (webview) {\n newButton.flowWebview = webview\n newButton.webview = { name: webview.webviewComponentName }\n newButton.params = webview.getParams(botContext)\n } else {\n newButton.payload = cmsApi.getPayload(cmsButton.target)\n }\n }\n\n if (cmsButton.url && urlId) {\n const urlNode = cmsApi.getNodeById<HtUrlNode>(urlId)\n newButton.url = urlNode.content.url\n }\n\n return newButton\n }\n\n static fromAIAgent(button: {\n id: string\n text: string\n payload?: string\n url?: string\n target?: string\n }): FlowButton {\n const newButton = new FlowButton(button.id)\n newButton.text = button.text\n if (button.url) {\n newButton.url = button.url\n newButton.target = button.target\n } else {\n newButton.payload = button.payload\n }\n return newButton\n }\n\n static fromRating(button: HtRatingButton): FlowButton {\n const newButton = new FlowButton(button.id)\n newButton.text = button.text\n newButton.payload = button.payload\n newButton.target = button.target?.id\n return newButton\n }\n\n static getUrlId(cmsButton: HtButton, locale: string): string | undefined {\n return cmsButton.url.find(url => url.locale === locale)?.id\n }\n\n static getTargetWebview(\n cmsApi: FlowBuilderApi,\n targetId: string\n ): FlowWebview | undefined {\n const targetNode = cmsApi.getNodeById(targetId)\n if (targetNode.type !== HtNodeWithContentType.WEBVIEW) {\n return undefined\n }\n return FlowWebview.fromHubtypeCMS(targetNode)\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n if (this.flowWebview) {\n await this.flowWebview.trackFlow(botContext)\n }\n }\n\n async processContent(): Promise<void> {\n return\n }\n\n renderButton(buttonIndex: number, buttonStyle?: HtButtonStyle): JSX.Element {\n if (buttonStyle === HtButtonStyle.QUICK_REPLY) {\n return (\n <Reply key={this.id} payload={this.getButtonPayload(buttonIndex)}>\n {this.text}\n </Reply>\n )\n }\n\n return (\n <Button\n key={this.id}\n url={this.url}\n payload={this.getButtonPayload(buttonIndex)}\n target={this.target}\n webview={this.webview}\n params={this.params}\n >\n {this.text}\n </Button>\n )\n }\n\n private getButtonPayload(buttonIndex: number): string | undefined {\n return this.payload\n ? `${this.payload}${SOURCE_INFO_SEPARATOR}${buttonIndex}`\n : undefined\n }\n}\n"],"names":["Button","Reply","SOURCE_INFO_SEPARATOR","ContentFieldsBase","FlowWebview","HtButtonStyle","HtNodeWithContentType","FlowButton","cmsButton","locale","cmsApi","botContext","urlId","newButton","webview","urlNode","button","url","targetId","targetNode","undefined","buttonIndex","buttonStyle"],"mappings":";;;;;;;;;;;;;;AAC4D;AAGR;AACK;AACb;AAMnB;AAGlB,MAAMO,UAAUA,SAASJ,iBAAiBA;IAS/C,OAAO,eACLK,SAAmB,EACnBC,MAAc,EACdC,MAAsB,EACtBC,UAAsB,EACV;QACZ,MAAMC,QAAQL,UAAUA,CAAC,QAAQ,CAACC,WAAWC;QAE7C,MAAMI,YAAY,IAAIN,UAAUA,CAACC,UAAU,EAAE;QAC7CK,UAAU,IAAI,GAAGN,UAAUA,CAAC,eAAe,CAACE,QAAQD,UAAU,IAAI;QAClE,IAAIA,UAAU,MAAM,EAAE;YACpB,MAAMM,UAAUP,UAAUA,CAAC,gBAAgB,CAACG,QAAQF,UAAU,MAAM,CAAC,EAAE;YACvE,IAAIM,SAAS;gBACXD,UAAU,WAAW,GAAGC;gBACxBD,UAAU,OAAO,GAAG;oBAAE,MAAMC,QAAQ,oBAAoB;gBAAC;gBACzDD,UAAU,MAAM,GAAGC,QAAQ,SAAS,CAACH;YACvC,OAAO;gBACLE,UAAU,OAAO,GAAGH,OAAO,UAAU,CAACF,UAAU,MAAM;YACxD;QACF;QAEA,IAAIA,UAAU,GAAG,IAAII,OAAO;YAC1B,MAAMG,UAAUL,OAAO,WAAW,CAAYE;YAC9CC,UAAU,GAAG,GAAGE,QAAQ,OAAO,CAAC,GAAG;QACrC;QAEA,OAAOF;IACT;IAEA,OAAO,YAAYG,MAMlB,EAAc;QACb,MAAMH,YAAY,IAAIN,UAAUA,CAACS,OAAO,EAAE;QAC1CH,UAAU,IAAI,GAAGG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M;YACnB,SAAS,IAAI,CAAC,OAAO;YACrB,QAAQ,IAAI,CAAC,MAAM;sBAElB,IAAI,CAAC,IAAI;WAPL,IAAI,CAAC,EAAE;IAUlB;IAEQ,iBAAiBA,WAAmB,EAAsB;QAChE,OAAO,IAAI,CAAC,OAAO,GACf,GAAG,IAAI,CAAC,OAAO,GAAGnB,qBAAqBA,GAAGmB,aAAa,GACvDD;IACN;;QApHK,qBACE,OAAO;;AAoHhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-capture-user-input.js","sources":["../../src/content-fields/flow-capture-user-input.tsx"],"sourcesContent":["import type { BotContext } from '@botonic/core'\n\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { ContentFieldsBase } from './content-fields-base'\nimport {\n HtAiValidationType,\n type HtCaptureUserInputNode,\n} from './hubtype-fields/capture-user-input'\n\nexport class FlowCaptureUserInput extends ContentFieldsBase {\n public fieldName = ''\n public aiValidationType = HtAiValidationType.NONE\n public aiValidationInstructions = ''\n public captureSuccessId = ''\n public captureFailId = ''\n\n static fromHubtypeCMS(cmsText: HtCaptureUserInputNode): FlowCaptureUserInput {\n const newCaptureUserInput = new FlowCaptureUserInput(cmsText.id)\n newCaptureUserInput.code = cmsText.code\n newCaptureUserInput.fieldName = cmsText.content.field_name\n newCaptureUserInput.aiValidationType =\n cmsText.content.ai_validation_type || HtAiValidationType.NONE\n newCaptureUserInput.aiValidationInstructions =\n cmsText.content.ai_validation_instructions || ''\n newCaptureUserInput.captureSuccessId = cmsText.content.capture_success.id\n newCaptureUserInput.captureFailId = cmsText.content.capture_fail.id\n newCaptureUserInput.followUp = undefined\n\n return newCaptureUserInput\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async trackFlow(_botContext: BotContext): Promise<void> {\n return\n }\n\n async processContent(): Promise<void> {\n return\n }\n\n toBotonic(botContext: BotContext): JSX.Element {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n cmsApi.setCaptureUserInputId(this.id)\n\n return <></>\n }\n}\n"],"names":["getFlowBuilderPlugin","ContentFieldsBase","HtAiValidationType","FlowCaptureUserInput","cmsText","newCaptureUserInput","undefined","_botContext","botContext","flowBuilderPlugin","cmsApi"],"mappings":";;;;;;;;;;AAEuE;AACd;AAIb;AAErC,MAAMG,oBAAoBA,SAASF,iBAAiBA;IAOzD,OAAO,eAAeG,OAA+B,EAAwB;QAC3E,MAAMC,sBAAsB,IAAIF,oBAAoBA,CAACC,QAAQ,EAAE;QAC/DC,oBAAoB,IAAI,GAAGD,QAAQ,IAAI;QACvCC,oBAAoB,SAAS,GAAGD,QAAQ,OAAO,CAAC,UAAU;QAC1DC,oBAAoB,gBAAgB,GAClCD,QAAQ,OAAO,CAAC,kBAAkB,IAAIF,uBAAuB;QAC/DG,oBAAoB,wBAAwB,GAC1CD,QAAQ,OAAO,CAAC,0BAA0B,IAAI;QAChDC,oBAAoB,gBAAgB,GAAGD,QAAQ,OAAO,CAAC,eAAe,CAAC,EAAE;QACzEC,oBAAoB,aAAa,GAAGD,QAAQ,OAAO,CAAC,YAAY,CAAC,EAAE;QACnEC,oBAAoB,QAAQ,GAAGC;QAE/B,OAAOD;IACT;IAEA,6DAA6D;IAC7D,MAAM,UAAUE,WAAuB,EAAiB;QACtD;IACF;IAEA,MAAM,iBAAgC;QACpC;IACF;IAEA,UAAUC,UAAsB,EAAe;QAC7C,MAAMC,oBAAoBT,oBAAoBA,CAACQ,WAAW,OAAO;QACjE,MAAME,SAASD,kBAAkB,MAAM;QACvCC,OAAO,qBAAqB,CAAC,IAAI,CAAC,EAAE;QAEpC,qBAAO;IACT;;QArCK,qBACE,YAAY,SACZ,mBAAmBR,uBAAuB,OAC1C,2BAA2B,SAC3B,mBAAmB,SACnB,gBAAgB;;AAiCzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-carousel.js","sources":["../../src/content-fields/flow-carousel.tsx"],"sourcesContent":["import {\n type BotContext,\n type CarouselMessage,\n isWhatsapp,\n OutputMessageType,\n} from '@botonic/core'\nimport {\n type ActionRequest,\n Button,\n CardType,\n Carousel,\n Text,\n WhatsappCTAUrlButton,\n WhatsappCTAUrlHeaderType,\n type WhatsappInteractiveMediaCard,\n WhatsappInteractiveMediaCarousel,\n} from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport { trackOneContent } from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport { FlowElement } from './flow-element'\nimport type { HtCarouselNode } from './hubtype-fields'\n\nconst DEFAULT_TEXT_MESSAGE = 'These are the options'\nexport class FlowCarousel extends ContentFieldsBase {\n public whatsappText: string = ''\n public elements: FlowElement[] = []\n\n static fromHubtypeCMS(\n component: HtCarouselNode,\n locale: string,\n cmsApi: FlowBuilderApi,\n botContext: BotContext\n ): FlowCarousel {\n const newCarousel = new FlowCarousel(component.id)\n newCarousel.code = component.code\n newCarousel.elements = component.content.elements.map(element =>\n FlowElement.fromHubtypeCMS(element, locale, cmsApi, botContext)\n )\n newCarousel.whatsappText = FlowCarousel.getTextByLocale(\n locale,\n component.content.whatsapp_text\n )\n newCarousel.followUp = component.follow_up\n\n return newCarousel\n }\n\n async trackFlow(request: ActionRequest): Promise<void> {\n await trackOneContent(request, this)\n for (const element of this.elements) {\n await element.trackFlow(request)\n }\n }\n\n static areElementsValidForWhatsapp = (carouselMessage: CarouselMessage) => {\n const isValid =\n carouselMessage.content.elements.every(element => element.button.url) ||\n carouselMessage.content.elements.every(element => element.button.payload)\n\n if (!isValid) {\n console.warn(\n 'Cannot use WhatsappInteractiveMediaCarousel for Whatsapp created by AIAgent, all elements must have either url or payload.',\n carouselMessage.content\n )\n }\n return isValid\n }\n\n static generateWhatsappElementText(element: {\n title: string\n subtitle?: string\n }): string {\n if (element.subtitle) {\n return `*${element.title}*\\n${element.subtitle}`\n }\n return element.title\n }\n\n private static createCardsFromElements(\n elements: FlowElement[]\n ): WhatsappInteractiveMediaCard[] {\n return elements.map(element => {\n const text = FlowCarousel.generateWhatsappElementText(element)\n\n if (element.button?.url) {\n return {\n imageLink: element.image,\n text,\n type: CardType.CTA_URL as const,\n action: {\n buttonText: element.button.text,\n buttonUrl: element.button.url,\n },\n }\n }\n if (element.button?.payload) {\n return {\n imageLink: element.image,\n text,\n type: CardType.QUICK_REPLY as const,\n action: {\n buttons: [\n {\n text: element.button.text,\n payload: element.button.payload,\n },\n ],\n },\n }\n }\n throw new Error('Element must have a url or a payload')\n })\n }\n\n static fromAIAgent(\n id: string,\n carouselMessage: CarouselMessage,\n botContext: ActionRequest\n ): JSX.Element {\n if (\n isWhatsapp(botContext.session) &&\n FlowCarousel.areElementsValidForWhatsapp(carouselMessage)\n ) {\n if (\n carouselMessage.content.elements.length === 1 &&\n carouselMessage.content.elements[0].button?.url\n ) {\n const element = carouselMessage.content.elements[0]\n const buttonText = element.button.text\n const url = carouselMessage.content.elements[0].button.url\n // TODO: Add a new fromAIAgent method in FlowWhatsappCtaUrlButtonNode to create a WhatsappCTAUrlButton from an AIAgent message\n return (\n <WhatsappCTAUrlButton\n key={id}\n body={element.title}\n headerType={WhatsappCTAUrlHeaderType.Image}\n headerImage={element.image}\n footer={element.subtitle}\n displayText={buttonText}\n url={url}\n />\n )\n }\n\n if (\n carouselMessage.content.elements.length === 1 &&\n carouselMessage.content.elements[0].button?.payload\n ) {\n const element = carouselMessage.content.elements[0]\n const text = FlowCarousel.generateWhatsappElementText(element)\n const buttonPayload = carouselMessage.content.elements[0].button.payload\n const buttonText = carouselMessage.content.elements[0].button.text\n\n return (\n <Text>\n {text}\n <Button payload={buttonPayload}>{buttonText}</Button>\n </Text>\n )\n }\n\n const elements = carouselMessage.content.elements.map((element, index) =>\n FlowElement.fromAIAgent(`${id}-element-${index}`, element)\n )\n return (\n <WhatsappInteractiveMediaCarousel\n cards={FlowCarousel.createCardsFromElements(elements)}\n textMessage={carouselMessage.content.text || DEFAULT_TEXT_MESSAGE}\n />\n )\n }\n return (\n <Carousel key={id}>\n {carouselMessage.content.elements.map((element, index) =>\n FlowElement.fromAIAgent(\n `${id}-element-${index}`,\n element\n ).renderElement(id)\n )}\n </Carousel>\n )\n }\n\n private toCarouselMessage(elements: FlowElement[]): CarouselMessage {\n return {\n type: OutputMessageType.Carousel,\n content: {\n elements: elements.map(element => {\n return {\n button: {\n text: element.button?.text || '',\n payload: element.button?.payload,\n url: element.button?.url,\n },\n title: element.title,\n subtitle: element.subtitle,\n image: element.image,\n }\n }),\n },\n }\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(botContext: BotContext): JSX.Element {\n const carouselMessage = this.toCarouselMessage(this.elements)\n if (\n isWhatsapp(botContext.session) &&\n FlowCarousel.areElementsValidForWhatsapp(carouselMessage)\n ) {\n if (this.elements.length === 1 && this.elements[0].button?.url) {\n const element = this.elements[0]\n const buttonText = this.elements[0].button.text\n const url = this.elements[0].button.url\n\n return (\n <WhatsappCTAUrlButton\n key={this.id}\n body={element.title}\n headerType={WhatsappCTAUrlHeaderType.Image}\n headerImage={element.image}\n displayText={buttonText}\n url={url}\n />\n )\n }\n\n if (\n this.elements.length === 1 &&\n this.elements[0].button &&\n this.elements[0].button?.payload\n ) {\n const element = this.elements[0]\n const text = FlowCarousel.generateWhatsappElementText(element)\n const buttonPayload = this.elements[0].button.payload\n const buttonText = this.elements[0].button.text\n\n return (\n <Text>\n {text}\n <Button payload={buttonPayload}>{buttonText}</Button>\n </Text>\n )\n }\n\n return (\n <WhatsappInteractiveMediaCarousel\n cards={FlowCarousel.createCardsFromElements(this.elements)}\n // TODO: Add the text message in flow builder frontend and take it from the carousel node with different languages\n textMessage={this.whatsappText || DEFAULT_TEXT_MESSAGE}\n />\n )\n }\n return (\n <Carousel key={this.id}>\n {this.elements.map(element => element.renderElement(this.id))}\n </Carousel>\n )\n }\n}\n"],"names":["isWhatsapp","OutputMessageType","Button","CardType","Carousel","Text","WhatsappCTAUrlButton","WhatsappCTAUrlHeaderType","WhatsappInteractiveMediaCarousel","trackOneContent","ContentFieldsBase","FlowElement","DEFAULT_TEXT_MESSAGE","FlowCarousel","component","locale","cmsApi","botContext","newCarousel","element","request","elements","text","Error","id","carouselMessage","buttonText","url","buttonPayload","index","isValid","console"],"mappings":";;;;;;;;;;;;;;AAKsB;AAWC;AAGsB;AACY;AACb;AAG5C,MAAMY,oBAAoBA,GAAG;AACtB,MAAMC,YAAYA,SAASH,iBAAiBA;IAIjD,OAAO,eACLI,SAAyB,EACzBC,MAAc,EACdC,MAAsB,EACtBC,UAAsB,EACR;QACd,MAAMC,cAAc,IAAIL,YAAYA,CAACC,UAAU,EAAE;QACjDI,YAAY,IAAI,GAAGJ,UAAU,IAAI;QACjCI,YAAY,QAAQ,GAAGJ,UAAU,OAAO,CAAC,QAAQ,CAAC,GAAG,CAACK,CAAAA,UACpDR,0BAA0B,CAACQ,SAASJ,QAAQC,QAAQC;QAEtDC,YAAY,YAAY,GAAGL,YAAYA,CAAC,eAAe,CACrDE,QACAD,UAAU,OAAO,CAAC,aAAa;QAEjCI,YAAY,QAAQ,GAAGJ,UAAU,SAAS;QAE1C,OAAOI;IACT;IAEA,MAAM,UAAUE,OAAsB,EAAiB;QACrD,MAAMX,eAAeA,CAACW,SAAS,IAAI;QACnC,KAAK,MAAMD,WAAW,IAAI,CAAC,QAAQ,CAAE;YACnC,MAAMA,QAAQ,SAAS,CAACC;QAC1B;IACF;IAgBA,OAAO,4BAA4BD,OAGlC,EAAU;QACT,IAAIA,QAAQ,QAAQ,EAAE;YACpB,OAAO,CAAC,CAAC,EAAEA,QAAQ,KAAK,CAAC,GAAG,EAAEA,QAAQ,QAAQ,EAAE;QAClD;QACA,OAAOA,QAAQ,KAAK;IACtB;IAEA,OAAe,wBACbE,QAAuB,EACS;QAChC,OAAOA,SAAS,GAAG,CAACF,CAAAA;YAClB,MAAMG,OAAOT,YAAYA,CAAC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AAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI;gBAE/C,qBACE,KAACrB,IAAIA;;wBACFiB;sCACD,IAACpB,MAAMA;4BAAC,SAAS0B;sCAAgBF;;;;YAGvC;YAEA,qBACE,IAAClB,gCAAgCA;gBAC/B,OAAOK,YAAYA,CAAC,uBAAuB,CAAC,IAAI,CAAC,QAAQ;gBACzD,kHAAkH;gBAClH,aAAa,IAAI,CAAC,YAAY,IAAID,oBAAoBA;;QAG5D;QACA,qBACE,IAACR,QAAQA;sBACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACe,CAAAA,UAAWA,QAAQ,aAAa,CAAC,IAAI,CAAC,EAAE;WAD9C,IAAI,CAAC,EAAE;IAI1B;;QAhPK,qBACE,eAAuB,SACvB,WAA0B,EAAE;;AA+OrC;AAjPaN,YAAYA,CA+BhB,8BAA8B,CAACY;IACpC,MAAMK,UACJL,gBAAgB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAACN,CAAAA,UAAWA,QAAQ,MAAM,CAAC,GAAG,KACpEM,gBAAgB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAACN,CAAAA,UAAWA,QAAQ,MAAM,CAAC,OAAO;IAE1E,IAAI,CAACW,SAAS;QACZC,QAAQ,IAAI,CACV,8HACAN,gBAAgB,OAAO;IAE3B;IACA,OAAOK;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-channel-conditional.js","sources":["../../src/content-fields/flow-channel-conditional.tsx"],"sourcesContent":["import {\n type BotContext,\n EventAction,\n type EventConditionalChannel,\n} from '@botonic/core'\n\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type { HtChannelConditionalNode } from './hubtype-fields/channel-conditional'\nimport type { HtFunctionResult } from './hubtype-fields/function'\n\nexport class FlowChannelConditional extends ContentFieldsBase {\n public resultMapping: HtFunctionResult[] = []\n public conditionalResult?: HtFunctionResult = undefined\n public channelResult: string = ''\n\n static fromHubtypeCMS(\n component: HtChannelConditionalNode,\n botContext: BotContext\n ): FlowChannelConditional {\n const newChannelConditional = new FlowChannelConditional(component.id)\n newChannelConditional.code = component.code\n newChannelConditional.resultMapping = component.content.result_mapping\n newChannelConditional.setConditionalResult(botContext)\n\n return newChannelConditional\n }\n\n setConditionalResult(botContext: BotContext): void {\n const provider = botContext.session.user.provider\n const conditionalResult =\n this.resultMapping.find(rMap => rMap.result === provider) ||\n this.resultMapping.find(rMap => rMap.result === 'default')\n if (!conditionalResult) {\n throw new Error(\n `No conditional result found for node ${this.code} with channel: ${provider}`\n )\n }\n this.conditionalResult = conditionalResult\n this.channelResult = conditionalResult.result as string\n this.followUp = conditionalResult.target\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const eventChannelConditional: EventConditionalChannel = {\n action: EventAction.ConditionalChannel,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n channel: this.channelResult,\n }\n const { action, ...eventArgs } = eventChannelConditional\n await trackEvent(botContext, action, eventArgs)\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n }\n\n toBotonic(): JSX.Element {\n return <></>\n }\n}\n"],"names":["EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","ContentFieldsBase","FlowChannelConditional","component","botContext","newChannelConditional","provider","conditionalResult","rMap","Error","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","eventChannelConditional","action","eventArgs","undefined"],"mappings":";;;;;;;;;;AAIsB;AAKF;AACqC;AAIlD,MAAMI,sBAAsBA,SAASD,iBAAiBA;IAK3D,OAAO,eACLE,SAAmC,EACnCC,UAAsB,EACE;QACxB,MAAMC,wBAAwB,IAAIH,sBAAsBA,CAACC,UA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,EAAE,OACtC,oBAAuCc,gBACvC,gBAAwB;;AAuDjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-country-conditional.js","sources":["../../src/content-fields/flow-country-conditional.tsx"],"sourcesContent":["import {\n type BotContext,\n EventAction,\n type EventConditionalCountry,\n} from '@botonic/core'\n\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type { HtFunctionResult } from './hubtype-fields'\nimport type { HtCountryConditionalNode } from './hubtype-fields/country-conditional'\n\nexport class FlowCountryConditional extends ContentFieldsBase {\n public resultMapping: HtFunctionResult[] = []\n public conditionalResult?: HtFunctionResult = undefined\n\n static fromHubtypeCMS(\n component: HtCountryConditionalNode,\n botContext: BotContext\n ): FlowCountryConditional {\n const newCountryConditional = new FlowCountryConditional(component.id)\n newCountryConditional.code = component.code\n newCountryConditional.resultMapping = component.content.result_mapping\n newCountryConditional.setConditionalResult(botContext)\n\n return newCountryConditional\n }\n\n setConditionalResult(botContext: BotContext): void {\n const country = botContext.getUserCountry()\n const conditionalResult =\n this.resultMapping.find(rMap => rMap.result === country) ||\n this.resultMapping.find(rMap => rMap.result === 'default')\n if (!conditionalResult) {\n throw new Error(\n `No conditional result found for node ${this.code} with country: ${country}`\n )\n }\n this.conditionalResult = conditionalResult\n this.followUp = conditionalResult.target\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n if (!this.conditionalResult?.result) {\n console.warn(\n `Tracking event for node ${this.code} but no conditional result found`\n )\n }\n const eventCountryConditional: EventConditionalCountry = {\n action: EventAction.ConditionalCountry,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n country: (this.conditionalResult?.result as string) ?? '',\n }\n const { action, ...eventArgs } = eventCountryConditional\n await trackEvent(botContext, action, eventArgs)\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(): JSX.Element {\n return <></>\n }\n}\n"],"names":["EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","ContentFieldsBase","FlowCountryConditional","component","botContext","newCountryConditional","country","conditionalResult","rMap","Error","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","console","eventCountryConditional","action","eventArgs","undefined"],"mappings":";;;;;;;;;;AAIsB;AAKF;AACqC;AAIlD,MAAMI,sBAAsBA,SAASD,iBAAiBA;IAI3D,OAAO,eACLE,SAAmC,EACnCC,UAAsB,EACE;QACxB,MAAMC,wBAAwB,IAAIH,sBAAsBA,CAACC,UAAU,EAAE;QACrEE,sBAAsB,IAAI,GAAGF,UAAU,IAAI;QAC3CE,sBAAsB,aAAa,GAAGF,UAAU,OAAO,CAAC,cAAc;QACtEE,sBAAsB,oBAAoB,CAACD;QAE3C,OAAOC;IACT;IAEA,qBAAqBD,UAAsB,EAAQ;QACjD,MAAME,UAAUF,WAAW,cAAc;QACzC,MAAMG,oBACJ,IAAI,CAAC,aAAa,CAAC,IAAI,CAACC,CAAAA,OAAQA,KAAK,MAAM,KAAKF,YAChD,IAAI,CAAC,aAAa,CAAC,IAAI,CAACE,CAAAA,OAAQA,KAAK,MAAM,KAAK;QAClD,IAAI,CAACD,mBAAmB;YACtB,MAAM,IAAIE,MACR,CAAC,qCAAqC,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,EAAEH,SAAS;QAEhF;QACA,IAAI,CAAC,iBAAiB,GAAGC;QACzB,IAAI,CAAC,QAAQ,GAAGA,kBAAkB,MAAM;IAC1C;IAEA,MAAM,UAAUH,UAAsB,EAAiB;QACrD,MAAM,EAAEM,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GACrEf,yCAAyCA,CAACK,YAAY,IAAI,CAAC,EAAE;QAC/D,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ;YACnCW,QAAQ,IAAI,CACV,CAAC,wBAAwB,EAAE,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC;QAE1E;QACA,MAAMC,0BAAmD;YACvD,QAAQlB,8BAA8B;YACtCY;YACAC;YACAC;YACAC;YACAC;YACA,sBAAsB;YACtB,SAAU,IAAI,CAAC,iBAAiB,EAAE,UAAqB;QACzD;QACA,MAAM,EAAEG,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMhB,UAAUA,CAACI,YAAYa,QAAQC;IACvC;IAEA,MAAM,eAAed,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAyB;QACvB,qBAAO;IACT;;QA5DK,qBACE,gBAAoC,EAAE,OACtC,oBAAuCe;;AA2DhD"}
|
|
@@ -13,5 +13,5 @@ export declare class FlowCustomConditional extends ContentFieldsBase {
|
|
|
13
13
|
trackFlow(botContext: BotContext): Promise<void>;
|
|
14
14
|
private isBooleanConditional;
|
|
15
15
|
processContent(botContext: BotContext): Promise<void>;
|
|
16
|
-
toBotonic(): import("react
|
|
16
|
+
toBotonic(): import("react").JSX.Element;
|
|
17
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-custom-conditional.js","sources":["../../src/content-fields/flow-custom-conditional.tsx"],"sourcesContent":["import {\n type BotContext,\n EventAction,\n type EventConditionalCustom,\n} from '@botonic/core'\n\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type { HtCustomConditionalNode } from './hubtype-fields/custom-conditional'\nimport type {\n HtFunctionArgument,\n HtFunctionArguments,\n HtFunctionResult,\n} from './hubtype-fields/function'\n\nexport class FlowCustomConditional extends ContentFieldsBase {\n public arguments: HtFunctionArguments[] = []\n public resultMapping: HtFunctionResult[]\n public conditionalResult?: HtFunctionResult = undefined\n public customResult: boolean = false\n public variableFormat: string = ''\n\n static fromHubtypeCMS(\n component: HtCustomConditionalNode,\n botContext: BotContext\n ): FlowCustomConditional {\n const newCustomConditional = new FlowCustomConditional(component.id)\n newCustomConditional.code = component.code\n newCustomConditional.arguments = component.content.arguments\n newCustomConditional.resultMapping = component.content.result_mapping\n newCustomConditional.setConditionalResult(botContext)\n newCustomConditional.variableFormat = (\n component.content.arguments as HtFunctionArgument[]\n )[0].type\n\n return newCustomConditional\n }\n\n setConditionalResult(botContext: BotContext): void {\n const functionArgument = this.arguments.find(arg => {\n if ('name' in arg) {\n return arg.name === 'keyPath'\n }\n return false\n })\n\n let keyPath = ''\n\n if (functionArgument && 'value' in functionArgument) {\n keyPath = functionArgument.value\n } else {\n throw new Error(`Key path not found for node ${this.code}`)\n }\n\n const botVariable = this.getValueFromKeyPath(botContext, keyPath)\n\n let conditionalResult =\n this.resultMapping.find(rMap => rMap.result === botVariable) ||\n this.resultMapping.find(rMap => rMap.result === 'default')\n\n if (\n this.isBooleanConditional(this.resultMapping) &&\n typeof botVariable !== 'boolean'\n ) {\n conditionalResult =\n this.resultMapping.find(\n rMap =>\n rMap.result === (botVariable !== undefined && botVariable !== null)\n ) || this.resultMapping.find(rMap => rMap.result === 'default')\n }\n\n if (!conditionalResult) {\n throw new Error(\n `No conditional result found for node ${this.code} with key path: ${keyPath}`\n )\n }\n\n this.conditionalResult = conditionalResult\n this.customResult = conditionalResult.result as unknown as boolean\n this.followUp = conditionalResult.target\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n if (!this.conditionalResult?.result) {\n console.warn(\n `Tracking event for node ${this.code} but no conditional result found`\n )\n }\n const eventCustomConditional: EventConditionalCustom = {\n action: EventAction.ConditionalCustom,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n conditionalVariable: this.customResult.toString(),\n variableFormat: this.variableFormat,\n operator: '',\n }\n const { action, ...eventArgs } = eventCustomConditional\n await trackEvent(botContext, action, eventArgs)\n }\n\n private isBooleanConditional(resultMapping: HtFunctionResult[]): boolean {\n return (\n resultMapping.some(rMap => rMap.result === true) &&\n resultMapping.some(rMap => rMap.result === false) &&\n resultMapping.some(rMap => rMap.result === 'default')\n )\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic() {\n return <></>\n }\n}\n"],"names":["EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","ContentFieldsBase","FlowCustomConditional","component","botContext","newCustomConditional","functionArgument","arg","keyPath","Error","botVariable","conditionalResult","rMap","undefined","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","console","eventCustomConditional","action","eventArgs","resultMapping"],"mappings":";;;;;;;;;;AAIsB;AAKF;AACqC;AAQlD,MAAMI,qBAAqBA,SAASD,iBAAiBA;IAO1D,OAAO,eACLE,SAAkC,EAClCC,UAAsB,EACC;QACvB,MAAMC,uBAAuB,IAAIH,qBAAqBA,CAACC,UAAU,EAAE;QACnEE,qBAAqB,IAAI,GAAGF,UAAU,IAAI;QAC1CE,qBAAqB,SAAS,GAAGF,UAAU,OAAO,CAAC,SAAS;QAC5DE,qBAAqB,aAAa,GAAGF,UAAU,OAAO,CAAC,cAAc;QACrEE,qBAAqB,oBAAoB,CAACD;QAC1CC,qBAAqB,cAAc,GACjCF,UAAU,OAAO,CAAC,SACnB,CAAC,EAAE,CAAC,IAAI;QAET,OAAOE;IACT;IAEA,qBAAqBD,UAAsB,EAAQ;QACjD,MAAME,mBAAmB,IAAI,CAAC,SAAS,CAAC,IAAI,CAACC,CAAAA;YAC3C,IAAI,UAAUA,KAAK;gBACjB,OAAOA,IAAI,IAAI,KAAK;YACtB;YACA,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CAAC,gCAAgC,CAAC;QAE1E;QACA,MAAMC,yBAAiD;YACrD,QAAQtB,6BAA6B;YACrCgB;YACAC;YACAC;YACAC;YACAC;YACA,sBAAsB;YACtB,qBAAqB,IAAI,CAAC,YAAY,CAAC,QAAQ;YAC/C,gBAAgB,IAAI,CAAC,cAAc;YACnC,UAAU;QACZ;QACA,MAAM,EAAEG,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMpB,UAAUA,CAACI,YAAYiB,QAAQC;IACvC;IAEQ,qBAAqBC,aAAiC,EAAW;QACvE,OACEA,cAAc,IAAI,CAACX,CAAAA,OAAQA,KAAK,MAAM,KAAK,SAC3CW,cAAc,IAAI,CAACX,CAAAA,OAAQA,KAAK,MAAM,KAAK,UAC3CW,cAAc,IAAI,CAACX,CAAAA,OAAQA,KAAK,MAAM,KAAK;IAE/C;IAEA,MAAM,eAAeR,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAY;QACV,qBAAO;IACT;;QA3GK,qBACE,YAAmC,EAAE,OAErC,oBAAuCS,gBACvC,eAAwB,YACxB,iBAAyB;;AAuGlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-element.js","sources":["../../src/content-fields/flow-element.tsx"],"sourcesContent":["import type { BotContext, Button } from '@botonic/core'\nimport { Element, Pic, Subtitle, Title } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport { ContentFieldsBase } from './content-fields-base'\nimport { FlowButton } from './flow-button'\nimport type { HtCarouselElement } from './hubtype-fields'\n\nexport class FlowElement extends ContentFieldsBase {\n public title = ''\n public subtitle = ''\n public button: FlowButton | undefined\n public image = ''\n public hidden = false\n\n static fromHubtypeCMS(\n component: HtCarouselElement,\n locale: string,\n cmsApi: FlowBuilderApi,\n botContext: BotContext\n ): FlowElement {\n const newElement = new FlowElement(component.id)\n newElement.title = FlowElement.getTextByLocale(locale, component.title)\n newElement.subtitle = FlowElement.getTextByLocale(\n locale,\n component.subtitle\n )\n newElement.image = FlowElement.getAssetByLocale(locale, component.image)\n newElement.button = FlowButton.fromHubtypeCMS(\n component.button,\n locale,\n cmsApi,\n botContext\n )\n return newElement\n }\n\n static fromAIAgent(\n id: string,\n element: {\n title: string\n subtitle: string\n image: string\n button: Button\n }\n ) {\n const newElement = new FlowElement(id)\n newElement.title = element.title\n newElement.subtitle = element.subtitle\n newElement.image = element.image\n newElement.button = FlowButton.fromAIAgent({\n id: `${id}-button`,\n text: element.button.text,\n url: element.button.url,\n })\n return newElement\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n if (this.button) {\n await this.button.trackFlow(botContext)\n }\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.trackFlow(botContext)\n return\n }\n\n renderElement(parentId: string): JSX.Element {\n return (\n <Element key={`${parentId}-${this.id}`}>\n <Pic src={this.image} />\n <Title>{this.title}</Title>\n <Subtitle>{this.subtitle}</Subtitle>\n {this.button?.renderButton(0)}\n </Element>\n )\n }\n}\n"],"names":["Element","Pic","Subtitle","Title","ContentFieldsBase","FlowButton","FlowElement","component","locale","cmsApi","botContext","newElement","id","element","parentId"],"mappings":";;;;;;;;;;AAC8D;AAGL;AACf;AAGnC,MAAMM,WAAWA,SAASF,iBAAiBA;IAOhD,OAAO,eACLG,SAA4B,EAC5BC,MAAc,EACdC,MAAsB,EACtBC,UAAsB,EACT;QACb,MAAMC,aAAa,IAAIL,WAAWA,CAACC,UAAU,EAAE;QAC/CI,WAAW,KAAK,GAAGL,WAAWA,CAAC,eAAe,CAACE,QAAQD,UAAU,KAAK;QACtEI,WAAW,QAAQ,GAAGL,WAAWA,CAAC,eAAe,CAC/CE,QACAD,UAAU,QAAQ;QAEpBI,WAAW,KAAK,GAAGL,WAAWA,CAAC,gBAAgB,CAACE,QAAQD,UAAU,KAAK;QACvEI,WAAW,MAAM,GAAGN,yBAAyB,CAC3CE,UAAU,MAAM,EAChBC,QACAC,QACAC;QAEF,OAAOC;IACT;IAEA,OAAO,YACLC,EAAU,EACVC,OAKC,EACD;QACA,MAAMF,aAAa,IAAIL,WAAWA,CAACM;QACnCD,WAAW,KAAK,GAAGE,QAAQ,KAAK;QAChCF,WAAW,QAAQ,GAAGE,QAAQ,QAAQ;QACtCF,WAAW,KAAK,GAAGE,QAAQ,KAAK;QAChCF,WAAW,MAAM,GAAGN,sBAAsB,CAAC;YACzC,IAAI,GAAGO,GAAG,OAAO,CAAC;YAClB,MAAMC,QAAQ,MAAM,CAAC,IAAI;YACzB,KAAKA,QAAQ,MAAM,CAAC,GAAG;QACzB;QACA,OAAOF;IACT;IAEA,MAAM,UAAUD,UAAsB,EAAiB;QACrD,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAACA;QAC9B;IACF;IAEA,MAAM,eAAeA,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,cAAcI,QAAgB,EAAe;QAC3C,qBACE,KAACd,OAAOA;;8BACN,IAACC,GAAGA;oBAAC,KAAK,IAAI,CAAC,KAAK;;8BACpB,IAACE,KAAKA;8BAAE,IAAI,CAAC,KAAK;;8BAClB,IAACD,QAAQA;8BAAE,IAAI,CAAC,QAAQ;;gBACvB,IAAI,CAAC,MAAM,EAAE,aAAa;;WAJf,GAAGY,SAAS,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE;IAO1C;;QAtEK,qBACE,QAAQ,SACR,WAAW,SAEX,QAAQ,SACR,SAAS;;AAkElB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-go-to-flow.js","sources":["../../src/content-fields/flow-go-to-flow.tsx"],"sourcesContent":["import {\n type BotContext,\n EventAction,\n type EventRedirectFlow,\n} from '@botonic/core'\n\nimport type { FlowBuilderApi } from '../api'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type { HtGoToFlow, HtNodeWithContent } from './hubtype-fields'\n\nexport class FlowGoToFlow extends ContentFieldsBase {\n public flowTargetId: string = ''\n public flowTargetName: string = ''\n public targetId: string = ''\n\n static fromHubtypeCMS(\n component: HtGoToFlow,\n cmsApi: FlowBuilderApi\n ): FlowGoToFlow {\n const newGoToFlow = new FlowGoToFlow(component.id)\n newGoToFlow.code = component.code\n newGoToFlow.flowTargetId = component.content.flow_id\n const targetId = cmsApi.getNodeByFlowId(component.content.flow_id).id\n newGoToFlow.targetId = targetId\n newGoToFlow.flowTargetName = cmsApi.getFlowName(component.content.flow_id)\n newGoToFlow.followUp = cmsApi.getNodeById<HtNodeWithContent>(targetId)\n\n return newGoToFlow\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n const eventGoToFlow: EventRedirectFlow = {\n action: EventAction.RedirectFlow,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId: flowNodeContentId || 'Go to flow',\n flowTargetId: this.flowTargetId,\n flowTargetName: this.flowTargetName,\n flowNodeIsMeaningful: false,\n }\n const { action, ...eventArgs } = eventGoToFlow\n await trackEvent(botContext, action, eventArgs)\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(): JSX.Element {\n return <></>\n }\n}\n"],"names":["EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","ContentFieldsBase","FlowGoToFlow","component","cmsApi","newGoToFlow","targetId","botContext","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","eventGoToFlow","action","eventArgs"],"mappings":";;;;;;;;;;AAIsB;AAMF;AACqC;AAGlD,MAAMI,YAAYA,SAASD,iBAAiBA;IAKjD,OAAO,eACLE,SAAqB,EACrBC,MAAsB,EACR;QACd,MAAMC,cAAc,IAAIH,YAAYA,CAACC,UAAU,EAAE;QACjDE,YAAY,IAAI,GAAGF,UAAU,IAAI;QACjCE,YAAY,YAAY,GAAGF,UAAU,OAAO,CAAC,OAAO;QACpD,MAAMG,WAAWF,OAAO,eAAe,CAACD,UAAU,OAAO,CAAC,OAAO,EAAE,EAAE;QACrEE,YAAY,QAAQ,GAAGC;QACvBD,YAAY,cAAc,GAAGD,OAAO,WAAW,CAACD,UAAU,OAAO,CAAC,OAAO;QACzEE,YAAY,QAAQ,GAAGD,OAAO,WAAW,CAAoBE;QAE7D,OAAOD;IACT;IAEA,MAAM,UAAUE,UAAsB,EAAiB;QACrD,MAAM,EAAEC,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GACrEb,yCAAyCA,CAACQ,YAAY,IAAI,CAAC,EAAE;QAC/D,MAAMM,gBAAmC;YACvC,QAAQf,wBAAwB;YAChCU;YACAC;YACAC;YACAC;YACA,mBAAmBC,qBAAqB;YACxC,cAAc,IAAI,CAAC,YAAY;YAC/B,gBAAgB,IAAI,CAAC,cAAc;YACnC,sBAAsB;QACxB;QACA,MAAM,EAAEE,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMb,UAAUA,CAACO,YAAYO,QAAQC;IACvC;IAEA,MAAM,eAAeR,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAyB;QACvB,qBAAO;IACT;;QA9CK,qBACE,eAAuB,SACvB,iBAAyB,SACzB,WAAmB;;AA4C5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-handoff.js","sources":["../../src/content-fields/flow-handoff.tsx"],"sourcesContent":["import {\n type BotContext,\n HandOffBuilder,\n HelpdeskEvent,\n isDev,\n isWebchat,\n} from '@botonic/core'\nimport { WebchatSettings } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport { getCommonFlowContentEventArgsForContentId } from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type { HtHandoffNode, HtQueueLocale } from './hubtype-fields'\n\nexport class FlowHandoff extends ContentFieldsBase {\n public queue?: HtQueueLocale\n public onFinishPayload?: string\n public handoffAutoAssign: boolean\n public hasQueuePositionChangedNotificationsEnabled: boolean\n public isTestIntegration: boolean\n\n static fromHubtypeCMS(\n cmsHandoff: HtHandoffNode,\n locale: string,\n cmsApi: FlowBuilderApi\n ): FlowHandoff {\n const newHandoff = new FlowHandoff(cmsHandoff.id)\n newHandoff.code = cmsHandoff.code\n newHandoff.queue = FlowHandoff.getQueueByLocale(\n locale,\n cmsHandoff.content.queue\n )\n newHandoff.onFinishPayload = FlowHandoff.getOnFinishPayload(\n cmsHandoff,\n cmsApi\n )\n newHandoff.handoffAutoAssign = cmsHandoff.content.has_auto_assign\n newHandoff.hasQueuePositionChangedNotificationsEnabled =\n cmsHandoff.content.has_queue_position_changed_notifications_enabled\n newHandoff.followUp = cmsHandoff.follow_up\n\n return newHandoff\n }\n\n private static getOnFinishPayload(\n cmsHandoff: HtHandoffNode,\n cmsApi: FlowBuilderApi\n ): string | undefined {\n if (cmsHandoff.target?.id) {\n return cmsApi.getPayload(cmsHandoff.target)\n }\n\n return undefined\n }\n\n async doHandoff(botContext: BotContext): Promise<void> {\n const handOffBuilder = new HandOffBuilder(botContext.session)\n handOffBuilder.withAutoAssignOnWaiting(this.handoffAutoAssign)\n\n if (this.hasQueuePositionChangedNotificationsEnabled) {\n handOffBuilder.withSubscribeHelpdeskEvents([\n HelpdeskEvent.QueuePositionChanged,\n ])\n }\n\n if (this.onFinishPayload) {\n handOffBuilder.withOnFinishPayload(this.onFinishPayload)\n }\n\n if (this.queue) {\n const language = botContext.getSystemLocale()\n\n handOffBuilder.withQueue(this.queue.id)\n\n const { flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n handOffBuilder.withBotEvent({\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n })\n\n handOffBuilder.withExtraData({\n language,\n })\n\n await handOffBuilder.handOff()\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async trackFlow(_botContext: BotContext): Promise<void> {\n // TODO: Not apply for this content because backend track handoff success event\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.doHandoff(botContext)\n return\n }\n\n toBotonic(botContext: BotContext): JSX.Element {\n return isDev(botContext.session) || isWebchat(botContext.session) ? (\n <WebchatSettings key={this.id} enableUserInput={true} />\n ) : (\n <></>\n )\n }\n}\n"],"names":["HandOffBuilder","HelpdeskEvent","isDev","isWebchat","WebchatSettings","getCommonFlowContentEventArgsForContentId","ContentFieldsBase","FlowHandoff","cmsHandoff","locale","cmsApi","newHandoff","undefined","botContext","handOffBuilder","language","flowId","flowName","flowNodeId","flowNodeContentId","_botContext"],"mappings":";;;;;;;;;;;;AAMsB;AAC0B;AAGuB;AACd;AAGlD,MAAMO,WAAWA,SAASD,iBAAiBA;IAOhD,OAAO,eACLE,UAAyB,EACzBC,MAAc,EACdC,MAAsB,EACT;QACb,MAAMC,aAAa,IAAIJ,WAAWA,CAACC,WAAW,EAAE;QAChDG,WAAW,IAAI,GAAGH,WAAW,IAAI;QACjCG,WAAW,KAAK,GAAGJ,WAAWA,CAAC,gBAAgB,CAC7CE,QACAD,WAAW,OAAO,CAAC,KAAK;QAE1BG,WAAW,eAAe,GAAGJ,WAAWA,CAAC,kBAAkB,CACzDC,YACAE;QAEFC,WAAW,iBAAiB,GAAGH,WAAW,OAAO,CAAC,eAAe;QACjEG,WAAW,2CAA2C,GACpDH,WAAW,OAAO,CAAC,gDAAgD;QACrEG,WAAW,QAAQ,GAAGH,WAAW,SAAS;QAE1C,OAAOG;IACT;IAEA,OAAe,mBACbH,UAAyB,EACzB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|
|
1
|
+
{"version":3,"file":"content-fields/flow-image.js","sources":["../../src/content-fields/flow-image.tsx"],"sourcesContent":["import type { BotContext } from '@botonic/core'\nimport { Image } from '@botonic/react'\n\nimport { trackOneContent } from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type { HtImageNode } from './hubtype-fields'\n\nexport class FlowImage extends ContentFieldsBase {\n public src = ''\n\n static fromHubtypeCMS(component: HtImageNode, locale: string): FlowImage {\n const newImage = new FlowImage(component.id)\n newImage.code = component.code\n newImage.src = FlowImage.getAssetByLocale(locale, component.content.image)\n newImage.followUp = component.follow_up\n\n return newImage\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n await trackOneContent(botContext, this)\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(): JSX.Element {\n return <Image key={this.id} src={this.src} />\n }\n}\n"],"names":["Image","trackOneContent","ContentFieldsBase","FlowImage","component","locale","newImage","botContext"],"mappings":";;;;;;;;;;AACsC;AAEO;AACY;AAGlD,MAAMG,SAASA,SAASD,iBAAiBA;IAG9C,OAAO,eAAeE,SAAsB,EAAEC,MAAc,EAAa;QACvE,MAAMC,WAAW,IAAIH,SAASA,CAACC,UAAU,EAAE;QAC3CE,SAAS,IAAI,GAAGF,UAAU,IAAI;QAC9BE,SAAS,GAAG,GAAGH,SAASA,CAAC,gBAAgB,CAACE,QAAQD,UAAU,OAAO,CAAC,KAAK;QACzEE,SAAS,QAAQ,GAAGF,UAAU,SAAS;QAEvC,OAAOE;IACT;IAEA,MAAM,UAAUC,UAAsB,EAAiB;QACrD,MAAMN,eAAeA,CAACM,YAAY,IAAI;IACxC;IAEA,MAAM,eAAeA,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAyB;QACvB,qBAAO,IAACP,KAAKA;YAAe,KAAK,IAAI,CAAC,GAAG;WAAtB,IAAI,CAAC,EAAE;IAC5B;;QAxBK,qBACE,MAAM;;AAwBf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-queue-status-conditional.js","sources":["../../src/content-fields/flow-queue-status-conditional.tsx"],"sourcesContent":["import {\n type BotContext,\n EventAction,\n type EventConditionalQueueStatus,\n} from '@botonic/core'\n\nimport { getArgumentsByLocale } from '../functions'\nimport { HubtypeQueuesApi } from '../services/hubtype-queues-api'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type {\n HtFunctionArguments,\n HtFunctionResult,\n} from './hubtype-fields/function'\nimport type {\n HtQueueStatusConditionalNode,\n HtQueueStatusConditionalResultMapping,\n} from './hubtype-fields/queue-status-conditional'\n\nenum QueueStatusResult {\n OPEN = 'open',\n CLOSED = 'closed',\n OPEN_WITHOUT_AGENTS = 'open-without-agents',\n}\n\ntype ConditionalQueueStatusArgs = {\n queueId: string\n queueName: string\n checkAvailableAgents: boolean\n}\n\nexport class FlowQueueStatusConditional extends ContentFieldsBase {\n public arguments: HtFunctionArguments[] = []\n public resultMapping: HtQueueStatusConditionalResultMapping\n public conditionalResult?: HtFunctionResult\n public queueId: string = ''\n public queueName: string = ''\n public isQueueOpen: boolean = false\n public isAvailableAgent: boolean = false\n\n static async fromHubtypeCMS(\n component: HtQueueStatusConditionalNode,\n locale: string\n ): Promise<FlowQueueStatusConditional> {\n const newChannelConditional = new FlowQueueStatusConditional(component.id)\n newChannelConditional.code = component.code\n newChannelConditional.arguments = component.content.arguments\n newChannelConditional.resultMapping = component.content\n .result_mapping as HtQueueStatusConditionalResultMapping\n await newChannelConditional.setConditionalResult(locale)\n\n return newChannelConditional\n }\n\n async setConditionalResult(locale: string): Promise<void> {\n const args = getArgumentsByLocale(this.arguments, locale)\n\n const queueId = args.find(arg => arg.name === 'queue_id')?.value || ''\n const queueName = args.find(arg => arg.name === 'queue_name')?.value || ''\n const checkAvailableAgents =\n (args.find(arg => arg.name === 'check_available_agents')\n ?.value as unknown as boolean) || false\n\n const queueStatus = await this.conditionalQueueStatus({\n queueId,\n queueName,\n checkAvailableAgents,\n })\n\n const conditionalResult = this.resultMapping.find(\n rMap => rMap.result === queueStatus\n )\n\n if (!conditionalResult) {\n throw new Error(\n `No conditional result found for node ${this.code} with queue: ${queueName}`\n )\n }\n this.conditionalResult = conditionalResult\n this.followUp = conditionalResult.target\n }\n\n async conditionalQueueStatus({\n queueId,\n checkAvailableAgents,\n queueName,\n }: ConditionalQueueStatusArgs): Promise<QueueStatusResult> {\n const queuesApi = new HubtypeQueuesApi(queueId, checkAvailableAgents)\n const data = await queuesApi.getAvailability()\n this.queueId = queueId\n this.queueName = queueName\n this.isQueueOpen = data.open\n this.isAvailableAgent = data.available_agents > 0\n\n if (checkAvailableAgents && data.open && data.available_agents === 0) {\n return QueueStatusResult.OPEN_WITHOUT_AGENTS\n }\n\n return data.open ? QueueStatusResult.OPEN : QueueStatusResult.CLOSED\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n if (!this.conditionalResult?.result) {\n console.warn(\n `Tracking event for node ${this.code} but no conditional result found`\n )\n }\n const eventQueueStatusConditional: EventConditionalQueueStatus = {\n action: EventAction.ConditionalQueueStatus,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n queueId: this.queueId,\n queueName: this.queueName,\n isQueueOpen: this.isQueueOpen,\n isAvailableAgent: this.isAvailableAgent,\n }\n const { action, ...eventArgs } = eventQueueStatusConditional\n await trackEvent(botContext, action, eventArgs)\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(): JSX.Element {\n return <></>\n }\n}\n"],"names":["EventAction","getArgumentsByLocale","HubtypeQueuesApi","getCommonFlowContentEventArgsForContentId","trackEvent","ContentFieldsBase","QueueStatusResult","FlowQueueStatusConditional","component","locale","newChannelConditional","args","queueId","arg","queueName","checkAvailableAgents","queueStatus","conditionalResult","rMap","Error","queuesApi","data","botContext","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","console","eventQueueStatusConditional","action","eventArgs"],"mappings":";;;;;;;;;;;;;;AAIsB;AAE6B;AACc;AAI7C;AACqC;AAUzD,IAAKM,+CAAiBA,iBAAjBA,gDAAAA,SAAAA;;;;WAAAA;EAAAA,+CAAiBA,OAAjBA,EAAAA;AAYE,MAAMC,0BAA0BA,SAASF,iBAAiBA;IAS/D,aAAa,eACXG,SAAuC,EACvCC,MAAc,EACuB;QACrC,MAAMC,wBAAwB,IAAIH,0BAA0BA,CAACC,UAAU,EAAE;QACzEE,sBAAsB,IAAI,GAAGF,UAAU,IAAI;QAC3CE,sBAAsB,SAAS,GAAGF,UAAU,OAAO,CAAC,SAAS;QAC7DE,sBAAsB,aAAa,GAAGF,UAAU,OAAO,CACpD,cAAc;QACjB,MAAME,sBAAsB,oBAAoB,CAACD;QAEjD,OAAOC;IACT;IAEA,MAAM,qBAAqBD,MAAc,EAAiB;QACxD,MAAME,OAAOV,oBAAoBA,CAAC,IAAI,CAAC,SAAS,EAAEQ;QAElD,MAAMG,UAAUD,KAAK,IAAI,CAACE,CAAAA,MAAOA,IAAI,IAAI,KAAK,aAAa,SAAS;QACpE,MAAMC,YAAYH,KAAK,IAAI,CAACE,CAAAA,MAAOA,IAAI,IAAI,KAAK,eAAe,SAAS;QACxE,MAAME,uBACHJ,KAAK,IAAI,CAACE,CAAAA,MAAOA,IAAI,IAAI,KAAK,2BAC3B,SAAgC;QAEtC,MAAMG,cAAc,MAAM,IAAI,CAAC,sBAAsB,CAAC;YACpDJ;YACAE;YACAC;QACF;QAEA,MAAME,oBAAoB,IAAI,CAAC,aAAa,CAAC,IAAI,CA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AM,EAAEG,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMzB,UAAUA,CAACkB,YAAYQ,QAAQC;IACvC;IAEA,MAAM,eAAeT,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAyB;QACvB,qBAAO;IACT;;QAvGK,qBACE,YAAmC,EAAE,OAGrC,UAAkB,SAClB,YAAoB,SACpB,cAAuB,YACvB,mBAA4B;;AAiGrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-rating.js","sources":["../../src/content-fields/flow-rating.tsx"],"sourcesContent":["import { type BotContext, isDev, isWebchat, isWhatsapp } from '@botonic/core'\nimport { CustomRatingMessage, Text, WhatsappButtonList } from '@botonic/react'\n\nimport { trackOneContent } from '../tracking'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { ContentFieldsBase } from './content-fields-base'\nimport { FlowButton } from './flow-button'\nimport { type HtRatingNode, RatingType } from './hubtype-fields'\n\nexport class FlowRating extends ContentFieldsBase {\n public text = ''\n public sendButtonText = ''\n public ratingType = RatingType.Stars\n public buttons: FlowButton[] = []\n public openListButtonText = ''\n\n static fromHubtypeCMS(cmsText: HtRatingNode, locale: string): FlowRating {\n const newRating = new FlowRating(cmsText.id)\n newRating.code = cmsText.code\n newRating.text = FlowRating.getTextByLocale(locale, cmsText.content.text)\n newRating.sendButtonText = FlowRating.getTextByLocale(\n locale,\n cmsText.content.send_button_text\n )\n newRating.ratingType = cmsText.content.rating_type\n newRating.buttons = cmsText.content.buttons.map(button =>\n FlowButton.fromRating(button)\n )\n newRating.openListButtonText = FlowRating.getTextByLocale(\n locale,\n cmsText.content.open_list_button_text\n )\n newRating.followUp = cmsText.follow_up\n\n return newRating\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n await trackOneContent(botContext, this)\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(botContext: BotContext): JSX.Element {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const customRatingMessageEnabled =\n flowBuilderPlugin.customRatingMessageEnabled\n const replacedText = this.replaceVariables(this.text, botContext)\n\n if (isWhatsapp(botContext.session)) {\n return (\n <WhatsappButtonList\n body={replacedText}\n button={this.openListButtonText}\n sections={[\n {\n rows: this.buttons.map(button => ({\n id: button.payload as string,\n title: button.text,\n })),\n },\n ]}\n />\n )\n }\n\n if (\n (isWebchat(botContext.session) || isDev(botContext.session)) &&\n customRatingMessageEnabled\n ) {\n const payloads = this.buttons\n .map(button => button.payload)\n .slice()\n .reverse()\n\n return (\n <CustomRatingMessage\n alt={replacedText}\n payloads={payloads}\n messageText={replacedText}\n buttonText={this.sendButtonText}\n ratingType={this.ratingType}\n />\n )\n }\n\n return (\n <Text key={this.id}>\n {replacedText}\n {this.buttons.map((button, buttonIndex) =>\n button.renderButton(buttonIndex)\n )}\n </Text>\n )\n }\n}\n"],"names":["isDev","isWebchat","isWhatsapp","CustomRatingMessage","Text","WhatsappButtonList","trackOneContent","getFlowBuilderPlugin","ContentFieldsBase","FlowButton","RatingType","FlowRating","cmsText","locale","newRating","button","botContext","flowBuilderPlugin","customRatingMessageEnabled","replacedText","payloads","buttonIndex"],"mappings":";;;;;;;;;;;;;;;;;;AAA6E;AACC;AAEjC;AAC0B;AACd;AACf;AACsB;AAEzD,MAAMW,UAAUA,SAASH,iBAAiBA;IAO/C,OAAO,eAAeI,OAAqB,EAAEC,MAAc,EAAc;QACvE,MAAMC,YAAY,IAAIH,UAAUA,CAACC,QAAQ,EAAE;QAC3CE,UAAU,IAAI,GAAGF,QAAQ,IAAI;QAC7BE,UAAU,IAAI,GAAGH,UAAUA,CAAC,eAAe,CAACE,QAAQD,QAAQ,OAAO,CAAC,IAAI;QACxEE,UAAU,cAAc,GAAGH,UAAUA,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V,qBACE,IAACZ,mBAAmBA;gBAClB,KAAKgB;gBACL,UAAUC;gBACV,aAAaD;gBACb,YAAY,IAAI,CAAC,cAAc;gBAC/B,YAAY,IAAI,CAAC,UAAU;;QAGjC;QAEA,qBACE,KAACf,IAAIA;;gBACFe;gBACA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAACJ,QAAQM,cACzBN,OAAO,YAAY,CAACM;;WAHb,IAAI,CAAC,EAAE;IAOtB;;QAzFK,qBACE,OAAO,SACP,iBAAiB,SACjB,aAAaX,gBAAgB,OAC7B,UAAwB,EAAE,OAC1B,qBAAqB;;AAqF9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-text.js","sources":["../../src/content-fields/flow-text.tsx"],"sourcesContent":["import type {\n BotContext,\n BotExecutorMessage,\n TextMessage,\n TextWithButtonsMessage,\n} from '@botonic/core'\nimport { Text } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport { EMPTY_PAYLOAD, SOURCE_INFO_SEPARATOR } from '../constants'\nimport { trackOneContent } from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport { FlowButton } from './flow-button'\nimport { HtButtonStyle, type HtTextNode } from './hubtype-fields'\n\nexport class FlowText extends ContentFieldsBase {\n public text = ''\n public buttons: FlowButton[] = []\n public buttonStyle = HtButtonStyle.BUTTON\n\n static fromHubtypeCMS(\n cmsText: HtTextNode,\n locale: string,\n cmsApi: FlowBuilderApi,\n botContext: BotContext\n ): FlowText {\n const newText = new FlowText(cmsText.id)\n newText.code = cmsText.code\n newText.buttonStyle = cmsText.content.buttons_style || HtButtonStyle.BUTTON\n newText.text = FlowText.getTextByLocale(locale, cmsText.content.text)\n newText.buttons = cmsText.content.buttons.map(button =>\n FlowButton.fromHubtypeCMS(button, locale, cmsApi, botContext)\n )\n newText.followUp = cmsText.follow_up\n\n return newText\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n await trackOneContent(botContext, this)\n for (const button of this.buttons) {\n await button.trackFlow(botContext)\n }\n }\n\n static fromAIAgent(\n id: string,\n textMessage: TextMessage | TextWithButtonsMessage | BotExecutorMessage\n ): JSX.Element {\n if (textMessage.type === 'text') {\n return <Text key={id}>{textMessage.content.text}</Text>\n }\n\n return (\n <Text key={id}>\n {textMessage.content.text}\n {textMessage.content.buttons.map((button, buttonIndex) => {\n const buttonData = {\n id: `${id}-button-${buttonIndex}`,\n text: button.text,\n url: button.url,\n target: button.target,\n payload:\n button.payload ||\n `${EMPTY_PAYLOAD}${SOURCE_INFO_SEPARATOR}${buttonIndex}`,\n }\n return FlowButton.fromAIAgent(buttonData).renderButton(buttonIndex)\n })}\n </Text>\n )\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(botContext: BotContext): JSX.Element {\n const replacedText = this.replaceVariables(this.text, botContext)\n return (\n <Text key={this.id}>\n {replacedText}\n {this.buttons.map((button, buttonIndex) =>\n button.renderButton(buttonIndex, this.buttonStyle)\n )}\n </Text>\n )\n }\n}\n"],"names":["Text","EMPTY_PAYLOAD","SOURCE_INFO_SEPARATOR","trackOneContent","ContentFieldsBase","FlowButton","HtButtonStyle","FlowText","cmsText","locale","cmsApi","botContext","newText","button","id","textMessage","buttonIndex","buttonData","replacedText"],"mappings":";;;;;;;;;;;;;;;;AAMqC;AAG8B;AACtB;AACY;AACf;AACuB;AAE1D,MAAMO,QAAQA,SAASH,iBAAiBA;IAK7C,OAAO,eACLI,OAAmB,EACnBC,MAAc,EACdC,MAAsB,EACtBC,UAAsB,EACZ;QACV,MAAMC,UAAU,IAAIL,QAAQA,CAACC,QAAQ,EAAE;QACvCI,QAAQ,IAAI,GAAGJ,QAAQ,IAAI;QAC3BI,QAAQ,WAAW,GAAGJ,QAAQ,OAAO,CAAC,aAAa,IAAIF,oBAAoB;QAC3EM,QAAQ,IAAI,GAAGL,QAAQA,CAAC,eAAe,CAACE,QAAQD,Q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C,OAAO,CAAC,GAAG,CAAC,CAACL,QAAQG,cACzBH,OAAO,YAAY,CAACG,aAAa,IAAI,CAAC,WAAW;;WAH1C,IAAI,CAAC,EAAE;IAOtB;;QAzEK,qBACE,OAAO,SACP,UAAwB,EAAE,OAC1B,cAAcV,oBAAoB;;AAuE3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-video.js","sources":["../../src/content-fields/flow-video.tsx"],"sourcesContent":["import type { BotContext } from '@botonic/core'\nimport { Video } from '@botonic/react'\n\nimport { trackOneContent } from '../tracking'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type { HtVideoNode } from './hubtype-fields'\n\nexport class FlowVideo extends ContentFieldsBase {\n public src = ''\n\n static fromHubtypeCMS(component: HtVideoNode, locale: string): FlowVideo {\n const newVideo = new FlowVideo(component.id)\n newVideo.code = component.code\n newVideo.src = FlowVideo.getVideoByLocale(locale, component.content.video)\n newVideo.followUp = component.follow_up\n\n return newVideo\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n await trackOneContent(botContext, this)\n }\n\n async processContent(botContext: BotContext): Promise<void> {\n await this.filterContent(botContext, this)\n await this.trackFlow(botContext)\n return\n }\n\n toBotonic(): JSX.Element {\n return <Video key={this.id} src={this.src} />\n }\n}\n"],"names":["Video","trackOneContent","ContentFieldsBase","FlowVideo","component","locale","newVideo","botContext"],"mappings":";;;;;;;;;;AACsC;AAEO;AACY;AAGlD,MAAMG,SAASA,SAASD,iBAAiBA;IAG9C,OAAO,eAAeE,SAAsB,EAAEC,MAAc,EAAa;QACvE,MAAMC,WAAW,IAAIH,SAASA,CAACC,UAAU,EAAE;QAC3CE,SAAS,IAAI,GAAGF,UAAU,IAAI;QAC9BE,SAAS,GAAG,GAAGH,SAASA,CAAC,gBAAgB,CAACE,QAAQD,UAAU,OAAO,CAAC,KAAK;QACzEE,SAAS,QAAQ,GAAGF,UAAU,SAAS;QAEvC,OAAOE;IACT;IAEA,MAAM,UAAUC,UAAsB,EAAiB;QACrD,MAAMN,eAAeA,CAACM,YAAY,IAAI;IACxC;IAEA,MAAM,eAAeA,UAAsB,EAAiB;QAC1D,MAAM,IAAI,CAAC,aAAa,CAACA,YAAY,IAAI;QACzC,MAAM,IAAI,CAAC,SAAS,CAACA;QACrB;IACF;IAEA,YAAyB;QACvB,qBAAO,IAACP,KAAKA;YAAe,KAAK,IAAI,CAAC,GAAG;WAAtB,IAAI,CAAC,EAAE;IAC5B;;QAxBK,qBACE,MAAM;;AAwBf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/flow-webview.js","sources":["../../src/content-fields/flow-webview.tsx"],"sourcesContent":["import {\n type BotContext,\n EventAction,\n type EventWebviewActionTriggered,\n} from '@botonic/core'\n\nimport type { FlowBuilderApi } from '../api'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { ContentFieldsBase } from './content-fields-base'\nimport type {\n HtNodeWithContent,\n HtWebviewExits,\n HtWebviewNode,\n} from './hubtype-fields'\n\nexport class FlowWebview extends ContentFieldsBase {\n public webviewTargetId: string = ''\n public webviewName: string = ''\n public webviewComponentName: string = ''\n public webviewParams: Record<string, string> = {}\n public exits: HtWebviewExits[] = []\n\n static fromHubtypeCMS(component: HtWebviewNode): FlowWebview {\n const newWebview = new FlowWebview(component.id)\n newWebview.webviewTargetId = component.content.webview_target_id\n newWebview.webviewName = component.content.webview_name\n newWebview.webviewComponentName = component.content.webview_component_name\n newWebview.webviewParams = component.content.webview_params ?? {}\n newWebview.exits = component.content.exits\n newWebview.followUp = component.follow_up\n\n return newWebview\n }\n\n getParams(botContext: BotContext): Record<string, string> {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n\n const params: Record<string, string> = {\n webviewId: this.webviewTargetId,\n t: Date.now().toString(),\n ...this.getResolvedWebviewParams(botContext),\n }\n const exitSuccessContentID = this.getExitSuccessContentID(cmsApi)\n\n if (exitSuccessContentID) {\n params.exitSuccessContentID = exitSuccessContentID\n }\n return params\n }\n\n private getResolvedWebviewParams(\n botContext: BotContext\n ): Record<string, string> {\n return Object.fromEntries(\n Object.entries(this.webviewParams).map(([key, value]) => [\n key,\n this.replaceVariables(value, botContext),\n ])\n )\n }\n\n private getExitSuccessContentID(cmsApi: FlowBuilderApi): string | undefined {\n const webviewSuccessExit = this.exits?.find(exit => exit.name === 'Success')\n const exitSuccessId = webviewSuccessExit?.target?.id\n if (!exitSuccessId) {\n return undefined\n }\n const exitNode = cmsApi.getNodeById<HtNodeWithContent>(exitSuccessId)\n\n return exitNode.code\n }\n\n async trackFlow(botContext: BotContext): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(botContext, this.id)\n\n const eventWebviewActionTriggered: EventWebviewActionTriggered = {\n action: EventAction.WebviewActionTriggered,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n webviewTargetId: this.webviewTargetId,\n webviewName: this.webviewName,\n webviewParams: this.getParams(botContext),\n }\n const { action, ...eventArgs } = eventWebviewActionTriggered\n await trackEvent(botContext, action, eventArgs)\n }\n\n async processContent(): Promise<void> {\n return\n }\n}\n"],"names":["EventAction","getCommonFlowContentEventArgsForContentId","trackEvent","getFlowBuilderPlugin","ContentFieldsBase","FlowWebview","component","newWebview","botContext","flowBuilderPlugin","cmsApi","params","Date","exitSuccessContentID","Object","key","value","webviewSuccessExit","exit","exitSuccessId","undefined","exitNode","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","eventWebviewActionTriggered","action","eventArgs"],"mappings":";;;;;;;;;AAIsB;AAMF;AACmD;AACd;AAOlD,MAAMK,WAAWA,SAASD,iBAAiBA;IAOhD,OAAO,eAAeE,SAAwB,EAAe;QAC3D,MAAMC,aAAa,IAAI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