@botonic/plugin-flow-builder 0.46.1 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/action/ai-agent-from-user-input.d.ts +3 -0
- package/lib/cjs/action/ai-agent-from-user-input.js +23 -0
- package/lib/cjs/action/ai-agent-from-user-input.js.map +1 -0
- package/lib/cjs/action/context.d.ts +11 -0
- package/lib/cjs/action/context.js +17 -0
- package/lib/cjs/action/context.js.map +1 -0
- package/lib/cjs/action/fallback.d.ts +1 -1
- package/lib/cjs/action/first-interaction.d.ts +1 -1
- package/lib/cjs/action/first-interaction.js +4 -4
- package/lib/cjs/action/first-interaction.js.map +1 -1
- package/lib/cjs/action/get-contents.d.ts +3 -0
- package/lib/cjs/action/get-contents.js +44 -0
- package/lib/cjs/action/get-contents.js.map +1 -0
- package/lib/cjs/action/index.d.ts +6 -15
- package/lib/cjs/action/index.js +31 -94
- package/lib/cjs/action/index.js.map +1 -1
- package/lib/cjs/action/knowledge-bases.d.ts +1 -1
- package/lib/cjs/action/knowledge-bases.js +3 -3
- package/lib/cjs/action/knowledge-bases.js.map +1 -1
- package/lib/cjs/action/payload.d.ts +1 -1
- package/lib/cjs/api.d.ts +0 -1
- package/lib/cjs/api.js +0 -7
- package/lib/cjs/api.js.map +1 -1
- package/lib/cjs/content-fields/content-fields-base.d.ts +5 -4
- package/lib/cjs/content-fields/content-fields-base.js +7 -7
- package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-ai-agent.d.ts +14 -5
- package/lib/cjs/content-fields/flow-ai-agent.js +100 -17
- package/lib/cjs/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/cjs/content-fields/flow-bot-action.d.ts +4 -2
- package/lib/cjs/content-fields/flow-bot-action.js +10 -5
- package/lib/cjs/content-fields/flow-bot-action.js.map +1 -1
- package/lib/cjs/content-fields/flow-button.d.ts +5 -2
- package/lib/cjs/content-fields/flow-button.js +6 -2
- package/lib/cjs/content-fields/flow-button.js.map +1 -1
- package/lib/cjs/content-fields/flow-capture-user-input.d.ts +4 -3
- package/lib/cjs/content-fields/flow-capture-user-input.js +7 -5
- package/lib/cjs/content-fields/flow-capture-user-input.js.map +1 -1
- package/lib/cjs/content-fields/flow-carousel.d.ts +4 -3
- package/lib/cjs/content-fields/flow-carousel.js +11 -7
- package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
- package/lib/cjs/content-fields/flow-channel-conditional.d.ts +5 -4
- package/lib/cjs/content-fields/flow-channel-conditional.js +10 -7
- package/lib/cjs/content-fields/flow-channel-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-country-conditional.d.ts +5 -4
- package/lib/cjs/content-fields/flow-country-conditional.js +11 -7
- package/lib/cjs/content-fields/flow-country-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-custom-conditional.d.ts +5 -4
- package/lib/cjs/content-fields/flow-custom-conditional.js +11 -7
- package/lib/cjs/content-fields/flow-custom-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-element.d.ts +4 -4
- package/lib/cjs/content-fields/flow-element.js +7 -3
- package/lib/cjs/content-fields/flow-element.js.map +1 -1
- package/lib/cjs/content-fields/flow-go-to-flow.d.ts +3 -3
- package/lib/cjs/content-fields/flow-go-to-flow.js +7 -15
- package/lib/cjs/content-fields/flow-go-to-flow.js.map +1 -1
- package/lib/cjs/content-fields/flow-handoff.d.ts +5 -4
- package/lib/cjs/content-fields/flow-handoff.js +11 -7
- package/lib/cjs/content-fields/flow-handoff.js.map +1 -1
- package/lib/cjs/content-fields/flow-image.d.ts +4 -3
- package/lib/cjs/content-fields/flow-image.js +8 -4
- package/lib/cjs/content-fields/flow-image.js.map +1 -1
- package/lib/cjs/content-fields/flow-knowledge-base.d.ts +4 -3
- package/lib/cjs/content-fields/flow-knowledge-base.js +7 -3
- package/lib/cjs/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-queue-status-conditional.d.ts +3 -2
- package/lib/cjs/content-fields/flow-queue-status-conditional.js +7 -3
- package/lib/cjs/content-fields/flow-queue-status-conditional.js.map +1 -1
- package/lib/cjs/content-fields/flow-rating.d.ts +4 -3
- package/lib/cjs/content-fields/flow-rating.js +13 -9
- package/lib/cjs/content-fields/flow-rating.js.map +1 -1
- package/lib/cjs/content-fields/flow-text.d.ts +4 -4
- package/lib/cjs/content-fields/flow-text.js +11 -6
- package/lib/cjs/content-fields/flow-text.js.map +1 -1
- package/lib/cjs/content-fields/flow-video.d.ts +4 -3
- package/lib/cjs/content-fields/flow-video.js +8 -4
- package/lib/cjs/content-fields/flow-video.js.map +1 -1
- package/lib/cjs/content-fields/flow-webview.d.ts +3 -2
- package/lib/cjs/content-fields/flow-webview.js +6 -3
- package/lib/cjs/content-fields/flow-webview.js.map +1 -1
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.d.ts +5 -3
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js +14 -10
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
- package/lib/cjs/content-fields/flow-whatsapp-template.d.ts +5 -3
- package/lib/cjs/content-fields/flow-whatsapp-template.js +26 -22
- package/lib/cjs/content-fields/flow-whatsapp-template.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +4 -3
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +6 -4
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +4 -3
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +7 -5
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +4 -3
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +10 -6
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/index.d.ts +3 -0
- package/lib/cjs/content-fields/whatsapp-button-list/index.js +10 -0
- package/lib/cjs/content-fields/whatsapp-button-list/index.js.map +1 -0
- package/lib/cjs/filters/index.d.ts +1 -0
- package/lib/cjs/filters/index.js +15 -0
- package/lib/cjs/filters/index.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +4 -8
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/structured-output/flow-builder-content.d.ts +16 -0
- package/lib/cjs/structured-output/flow-builder-content.js +12 -0
- package/lib/cjs/structured-output/flow-builder-content.js.map +1 -0
- package/lib/cjs/tracking.js +6 -6
- package/lib/cjs/tracking.js.map +1 -1
- package/lib/cjs/types.d.ts +2 -1
- package/lib/cjs/user-input/capture-user-input-api.js +4 -4
- package/lib/cjs/user-input/capture-user-input-api.js.map +1 -1
- package/lib/cjs/user-input/index.js +4 -4
- package/lib/cjs/user-input/index.js.map +1 -1
- package/lib/cjs/user-input/smart-intent.js +2 -2
- package/lib/cjs/user-input/smart-intent.js.map +1 -1
- package/lib/cjs/utils/ai-agent.d.ts +18 -0
- package/lib/cjs/utils/ai-agent.js +177 -0
- package/lib/cjs/utils/ai-agent.js.map +1 -0
- package/lib/cjs/utils/authentication.d.ts +2 -0
- package/lib/cjs/utils/authentication.js +21 -0
- package/lib/cjs/utils/authentication.js.map +1 -0
- package/lib/{esm/helpers.d.ts → cjs/utils/get-flow-builder-plugin.d.ts} +1 -1
- package/lib/cjs/{helpers.js → utils/get-flow-builder-plugin.js} +1 -1
- package/lib/cjs/utils/get-flow-builder-plugin.js.map +1 -0
- package/lib/cjs/{utils.d.ts → utils/input.d.ts} +1 -2
- package/lib/cjs/{utils.js → utils/input.js} +3 -21
- package/lib/cjs/utils/input.js.map +1 -0
- package/lib/esm/action/ai-agent-from-user-input.d.ts +3 -0
- package/lib/esm/action/ai-agent-from-user-input.js +23 -0
- package/lib/esm/action/ai-agent-from-user-input.js.map +1 -0
- package/lib/esm/action/context.d.ts +11 -0
- package/lib/esm/action/context.js +17 -0
- package/lib/esm/action/context.js.map +1 -0
- package/lib/esm/action/fallback.d.ts +1 -1
- package/lib/esm/action/first-interaction.d.ts +1 -1
- package/lib/esm/action/first-interaction.js +4 -4
- package/lib/esm/action/first-interaction.js.map +1 -1
- package/lib/esm/action/get-contents.d.ts +3 -0
- package/lib/esm/action/get-contents.js +44 -0
- package/lib/esm/action/get-contents.js.map +1 -0
- package/lib/esm/action/index.d.ts +6 -15
- package/lib/esm/action/index.js +31 -94
- package/lib/esm/action/index.js.map +1 -1
- package/lib/esm/action/knowledge-bases.d.ts +1 -1
- package/lib/esm/action/knowledge-bases.js +3 -3
- package/lib/esm/action/knowledge-bases.js.map +1 -1
- package/lib/esm/action/payload.d.ts +1 -1
- package/lib/esm/api.d.ts +0 -1
- package/lib/esm/api.js +0 -7
- package/lib/esm/api.js.map +1 -1
- package/lib/esm/content-fields/content-fields-base.d.ts +5 -4
- package/lib/esm/content-fields/content-fields-base.js +7 -7
- package/lib/esm/content-fields/content-fields-base.js.map +1 -1
- package/lib/esm/content-fields/flow-ai-agent.d.ts +14 -5
- package/lib/esm/content-fields/flow-ai-agent.js +100 -17
- package/lib/esm/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/esm/content-fields/flow-bot-action.d.ts +4 -2
- package/lib/esm/content-fields/flow-bot-action.js +10 -5
- package/lib/esm/content-fields/flow-bot-action.js.map +1 -1
- package/lib/esm/content-fields/flow-button.d.ts +5 -2
- package/lib/esm/content-fields/flow-button.js +6 -2
- package/lib/esm/content-fields/flow-button.js.map +1 -1
- package/lib/esm/content-fields/flow-capture-user-input.d.ts +4 -3
- package/lib/esm/content-fields/flow-capture-user-input.js +7 -5
- package/lib/esm/content-fields/flow-capture-user-input.js.map +1 -1
- package/lib/esm/content-fields/flow-carousel.d.ts +4 -3
- package/lib/esm/content-fields/flow-carousel.js +11 -7
- package/lib/esm/content-fields/flow-carousel.js.map +1 -1
- package/lib/esm/content-fields/flow-channel-conditional.d.ts +5 -4
- package/lib/esm/content-fields/flow-channel-conditional.js +10 -7
- package/lib/esm/content-fields/flow-channel-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-country-conditional.d.ts +5 -4
- package/lib/esm/content-fields/flow-country-conditional.js +11 -7
- package/lib/esm/content-fields/flow-country-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-custom-conditional.d.ts +5 -4
- package/lib/esm/content-fields/flow-custom-conditional.js +11 -7
- package/lib/esm/content-fields/flow-custom-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-element.d.ts +4 -4
- package/lib/esm/content-fields/flow-element.js +7 -3
- package/lib/esm/content-fields/flow-element.js.map +1 -1
- package/lib/esm/content-fields/flow-go-to-flow.d.ts +3 -3
- package/lib/esm/content-fields/flow-go-to-flow.js +7 -15
- package/lib/esm/content-fields/flow-go-to-flow.js.map +1 -1
- package/lib/esm/content-fields/flow-handoff.d.ts +5 -4
- package/lib/esm/content-fields/flow-handoff.js +11 -7
- package/lib/esm/content-fields/flow-handoff.js.map +1 -1
- package/lib/esm/content-fields/flow-image.d.ts +4 -3
- package/lib/esm/content-fields/flow-image.js +8 -4
- package/lib/esm/content-fields/flow-image.js.map +1 -1
- package/lib/esm/content-fields/flow-knowledge-base.d.ts +4 -3
- package/lib/esm/content-fields/flow-knowledge-base.js +7 -3
- package/lib/esm/content-fields/flow-knowledge-base.js.map +1 -1
- package/lib/esm/content-fields/flow-queue-status-conditional.d.ts +3 -2
- package/lib/esm/content-fields/flow-queue-status-conditional.js +7 -3
- package/lib/esm/content-fields/flow-queue-status-conditional.js.map +1 -1
- package/lib/esm/content-fields/flow-rating.d.ts +4 -3
- package/lib/esm/content-fields/flow-rating.js +13 -9
- package/lib/esm/content-fields/flow-rating.js.map +1 -1
- package/lib/esm/content-fields/flow-text.d.ts +4 -4
- package/lib/esm/content-fields/flow-text.js +11 -6
- package/lib/esm/content-fields/flow-text.js.map +1 -1
- package/lib/esm/content-fields/flow-video.d.ts +4 -3
- package/lib/esm/content-fields/flow-video.js +8 -4
- package/lib/esm/content-fields/flow-video.js.map +1 -1
- package/lib/esm/content-fields/flow-webview.d.ts +3 -2
- package/lib/esm/content-fields/flow-webview.js +6 -3
- package/lib/esm/content-fields/flow-webview.js.map +1 -1
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.d.ts +5 -3
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js +14 -10
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +1 -1
- package/lib/esm/content-fields/flow-whatsapp-template.d.ts +5 -3
- package/lib/esm/content-fields/flow-whatsapp-template.js +26 -22
- package/lib/esm/content-fields/flow-whatsapp-template.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +4 -3
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +6 -4
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +4 -3
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +7 -5
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +4 -3
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +10 -6
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/index.d.ts +3 -0
- package/lib/esm/content-fields/whatsapp-button-list/index.js +10 -0
- package/lib/esm/content-fields/whatsapp-button-list/index.js.map +1 -0
- package/lib/esm/filters/index.d.ts +1 -0
- package/lib/esm/filters/index.js +15 -0
- package/lib/esm/filters/index.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +4 -8
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/structured-output/flow-builder-content.d.ts +16 -0
- package/lib/esm/structured-output/flow-builder-content.js +12 -0
- package/lib/esm/structured-output/flow-builder-content.js.map +1 -0
- package/lib/esm/tracking.js +6 -6
- package/lib/esm/tracking.js.map +1 -1
- package/lib/esm/types.d.ts +2 -1
- package/lib/esm/user-input/capture-user-input-api.js +4 -4
- package/lib/esm/user-input/capture-user-input-api.js.map +1 -1
- package/lib/esm/user-input/index.js +4 -4
- package/lib/esm/user-input/index.js.map +1 -1
- package/lib/esm/user-input/smart-intent.js +2 -2
- package/lib/esm/user-input/smart-intent.js.map +1 -1
- package/lib/esm/utils/ai-agent.d.ts +18 -0
- package/lib/esm/utils/ai-agent.js +177 -0
- package/lib/esm/utils/ai-agent.js.map +1 -0
- package/lib/esm/utils/authentication.d.ts +2 -0
- package/lib/esm/utils/authentication.js +21 -0
- package/lib/esm/utils/authentication.js.map +1 -0
- package/lib/{cjs/helpers.d.ts → esm/utils/get-flow-builder-plugin.d.ts} +1 -1
- package/lib/esm/{helpers.js → utils/get-flow-builder-plugin.js} +1 -1
- package/lib/esm/utils/get-flow-builder-plugin.js.map +1 -0
- package/lib/esm/{utils.d.ts → utils/input.d.ts} +1 -2
- package/lib/esm/{utils.js → utils/input.js} +3 -21
- package/lib/esm/utils/input.js.map +1 -0
- package/package.json +2 -2
- package/src/action/ai-agent-from-user-input.ts +35 -0
- package/src/action/context.ts +29 -0
- package/src/action/fallback.ts +1 -1
- package/src/action/first-interaction.ts +4 -4
- package/src/action/get-contents.ts +51 -0
- package/src/action/index.tsx +42 -136
- package/src/action/knowledge-bases.ts +5 -2
- package/src/action/payload.ts +1 -1
- package/src/api.ts +0 -8
- package/src/content-fields/content-fields-base.ts +11 -9
- package/src/content-fields/flow-ai-agent.tsx +166 -28
- package/src/content-fields/flow-bot-action.tsx +17 -6
- package/src/content-fields/flow-button.tsx +10 -3
- package/src/content-fields/flow-capture-user-input.tsx +9 -6
- package/src/content-fields/flow-carousel.tsx +21 -11
- package/src/content-fields/flow-channel-conditional.tsx +16 -9
- package/src/content-fields/flow-country-conditional.tsx +17 -9
- package/src/content-fields/flow-custom-conditional.tsx +17 -9
- package/src/content-fields/flow-element.tsx +10 -11
- package/src/content-fields/flow-go-to-flow.tsx +10 -24
- package/src/content-fields/flow-handoff.tsx +21 -10
- package/src/content-fields/flow-image.tsx +11 -5
- package/src/content-fields/flow-knowledge-base.tsx +11 -5
- package/src/content-fields/flow-queue-status-conditional.tsx +13 -5
- package/src/content-fields/flow-rating.tsx +16 -16
- package/src/content-fields/flow-text.tsx +14 -7
- package/src/content-fields/flow-video.tsx +11 -5
- package/src/content-fields/flow-webview.tsx +12 -5
- package/src/content-fields/flow-whatsapp-cta-url-button.tsx +16 -12
- package/src/content-fields/flow-whatsapp-template.tsx +28 -24
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx +8 -5
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx +8 -6
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +15 -15
- package/src/content-fields/whatsapp-button-list/index.ts +3 -0
- package/src/filters/index.ts +20 -0
- package/src/index.ts +3 -14
- package/src/structured-output/flow-builder-content.ts +17 -0
- package/src/tracking.ts +1 -1
- package/src/types.ts +2 -2
- package/src/user-input/capture-user-input-api.ts +2 -2
- package/src/user-input/index.ts +1 -1
- package/src/user-input/smart-intent.ts +1 -1
- package/src/utils/ai-agent.ts +233 -0
- package/src/utils/authentication.ts +23 -0
- package/src/{helpers.ts → utils/get-flow-builder-plugin.ts} +1 -1
- package/src/{utils.ts → utils/input.ts} +3 -23
- package/lib/cjs/action/ai-agent.d.ts +0 -3
- package/lib/cjs/action/ai-agent.js +0 -67
- package/lib/cjs/action/ai-agent.js.map +0 -1
- package/lib/cjs/helpers.js.map +0 -1
- package/lib/cjs/utils.js.map +0 -1
- package/lib/esm/action/ai-agent.d.ts +0 -3
- package/lib/esm/action/ai-agent.js +0 -67
- package/lib/esm/action/ai-agent.js.map +0 -1
- package/lib/esm/helpers.js.map +0 -1
- package/lib/esm/utils.js.map +0 -1
- package/src/action/ai-agent.ts +0 -102
|
@@ -1,14 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
type AgenticOutputMessage,
|
|
3
|
+
type BotContext,
|
|
4
|
+
EventAction,
|
|
5
|
+
type EventAiAgent,
|
|
6
|
+
type GuardrailRule,
|
|
7
|
+
type HubtypeAssistantMessage,
|
|
8
|
+
type InferenceResponse,
|
|
9
|
+
VerbosityLevel,
|
|
10
|
+
} from '@botonic/core'
|
|
11
|
+
import {
|
|
12
|
+
type FlowBuilderContentMessage,
|
|
13
|
+
FlowBuilderContentSchema,
|
|
14
|
+
} from '../structured-output/flow-builder-content'
|
|
15
|
+
import {
|
|
16
|
+
getCommonFlowContentEventArgsForContentId,
|
|
17
|
+
trackEvent,
|
|
18
|
+
} from '../tracking'
|
|
19
|
+
import { HubtypeAssistantContent } from '../utils/ai-agent'
|
|
20
|
+
import { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'
|
|
5
21
|
import { ContentFieldsBase } from './content-fields-base'
|
|
6
22
|
import { FlowCarousel } from './flow-carousel'
|
|
7
23
|
import { FlowText } from './flow-text'
|
|
24
|
+
import type { HtNodeWithContent } from './hubtype-fields'
|
|
8
25
|
import type {
|
|
9
26
|
HtAiAgentNode,
|
|
10
27
|
HtInputGuardrailRule,
|
|
11
28
|
} from './hubtype-fields/ai-agent'
|
|
29
|
+
import type { FlowContent } from './index'
|
|
12
30
|
|
|
13
31
|
export class FlowAiAgent extends ContentFieldsBase {
|
|
14
32
|
public name: string = ''
|
|
@@ -19,7 +37,9 @@ export class FlowAiAgent extends ContentFieldsBase {
|
|
|
19
37
|
public inputGuardrailRules: HtInputGuardrailRule[]
|
|
20
38
|
public sources?: { id: string; name: string }[]
|
|
21
39
|
|
|
22
|
-
public
|
|
40
|
+
public aiAgentResponse?: InferenceResponse<FlowBuilderContentMessage>
|
|
41
|
+
public messages: AgenticOutputMessage<FlowBuilderContentMessage>[] = []
|
|
42
|
+
public jsxElements: JSX.Element[] = []
|
|
23
43
|
|
|
24
44
|
static fromHubtypeCMS(component: HtAiAgentNode): FlowAiAgent {
|
|
25
45
|
const newAiAgent = new FlowAiAgent(component.id)
|
|
@@ -37,31 +57,149 @@ export class FlowAiAgent extends ContentFieldsBase {
|
|
|
37
57
|
return newAiAgent
|
|
38
58
|
}
|
|
39
59
|
|
|
40
|
-
async
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
async resolveAIAgentResponse(
|
|
61
|
+
botContext: BotContext,
|
|
62
|
+
previousContents?: FlowContent[]
|
|
63
|
+
): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {
|
|
64
|
+
const aiAgentResponse = await this.getAIAgentResponse(
|
|
65
|
+
botContext,
|
|
66
|
+
previousContents
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if (aiAgentResponse) {
|
|
70
|
+
this.aiAgentResponse = aiAgentResponse
|
|
71
|
+
await this.trackAiAgentResponse(botContext)
|
|
72
|
+
this.messages = aiAgentResponse.messages
|
|
73
|
+
await this.messagesToBotonicJSXElements(botContext)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return aiAgentResponse
|
|
44
77
|
}
|
|
45
78
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
async getAIAgentResponse(
|
|
80
|
+
botContext: BotContext,
|
|
81
|
+
previousContents?: FlowContent[]
|
|
82
|
+
): Promise<InferenceResponse<FlowBuilderContentMessage> | undefined> {
|
|
83
|
+
const previousHubtypeContents: HubtypeAssistantMessage[] =
|
|
84
|
+
previousContents?.map(content => {
|
|
85
|
+
return {
|
|
86
|
+
role: 'assistant',
|
|
87
|
+
content: HubtypeAssistantContent.adapt(content),
|
|
88
|
+
}
|
|
89
|
+
}) || []
|
|
90
|
+
|
|
91
|
+
const activeInputGuardrailRules: GuardrailRule[] =
|
|
92
|
+
this.inputGuardrailRules
|
|
93
|
+
?.filter(rule => rule.is_active)
|
|
94
|
+
?.map(rule => ({
|
|
95
|
+
name: rule.name,
|
|
96
|
+
description: rule.description,
|
|
97
|
+
})) || []
|
|
98
|
+
|
|
99
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)
|
|
100
|
+
|
|
101
|
+
const aiAgentResponse = await flowBuilderPlugin.getAiAgentResponse?.(
|
|
102
|
+
botContext,
|
|
103
|
+
{
|
|
104
|
+
name: this.name,
|
|
105
|
+
instructions: this.instructions,
|
|
106
|
+
model: this.model,
|
|
107
|
+
verbosity: this.verbosity,
|
|
108
|
+
activeTools: this.activeTools,
|
|
109
|
+
inputGuardrailRules: activeInputGuardrailRules,
|
|
110
|
+
sourceIds: this.sources?.map(source => source.id),
|
|
111
|
+
outputMessagesSchemas: [FlowBuilderContentSchema],
|
|
112
|
+
previousHubtypeMessages: previousHubtypeContents,
|
|
113
|
+
}
|
|
65
114
|
)
|
|
115
|
+
|
|
116
|
+
return aiAgentResponse
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async trackFlow(): Promise<void> {
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async trackAiAgentResponse(botContext: BotContext) {
|
|
124
|
+
const { flowThreadId, flowId, flowName, flowNodeId } =
|
|
125
|
+
getCommonFlowContentEventArgsForContentId(botContext, this.id)
|
|
126
|
+
|
|
127
|
+
const event: EventAiAgent = {
|
|
128
|
+
action: EventAction.AiAgent,
|
|
129
|
+
flowThreadId: flowThreadId,
|
|
130
|
+
flowId: flowId,
|
|
131
|
+
flowName: flowName,
|
|
132
|
+
flowNodeId: flowNodeId,
|
|
133
|
+
flowNodeContentId: this.name,
|
|
134
|
+
flowNodeIsMeaningful: true,
|
|
135
|
+
toolsExecuted: this.aiAgentResponse?.toolsExecuted ?? [],
|
|
136
|
+
memoryLength: this.aiAgentResponse?.memoryLength ?? 0,
|
|
137
|
+
inputMessageId: botContext.input.message_id!,
|
|
138
|
+
exit: this.aiAgentResponse?.exit ?? true,
|
|
139
|
+
inputGuardrailsTriggered:
|
|
140
|
+
this.aiAgentResponse?.inputGuardrailsTriggered ?? [],
|
|
141
|
+
outputGuardrailsTriggered: [], //aiAgentResponse.outputGuardrailsTriggered,
|
|
142
|
+
error: this.aiAgentResponse?.error ?? false,
|
|
143
|
+
}
|
|
144
|
+
const { action, ...eventArgs } = event
|
|
145
|
+
|
|
146
|
+
await trackEvent(botContext, action, eventArgs)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async getFlowContentsByContentId(
|
|
150
|
+
botContext: BotContext,
|
|
151
|
+
contentId: string
|
|
152
|
+
): Promise<FlowContent[]> {
|
|
153
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)
|
|
154
|
+
const cmsApi = flowBuilderPlugin.cmsApi
|
|
155
|
+
const node = cmsApi.getNodeByContentID(contentId)
|
|
156
|
+
const flowContents = await flowBuilderPlugin.getContentsByNode(
|
|
157
|
+
node as HtNodeWithContent
|
|
158
|
+
)
|
|
159
|
+
return flowContents
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async messagesToBotonicJSXElements(botContext: BotContext): Promise<void> {
|
|
163
|
+
for (const message of this.messages) {
|
|
164
|
+
if (
|
|
165
|
+
message.type === 'text' ||
|
|
166
|
+
message.type === 'textWithButtons' ||
|
|
167
|
+
message.type === 'botExecutor'
|
|
168
|
+
) {
|
|
169
|
+
this.jsxElements.push(FlowText.fromAIAgent(this.id, message))
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (message.type === 'carousel') {
|
|
173
|
+
this.jsxElements.push(
|
|
174
|
+
FlowCarousel.fromAIAgent(this.id, message, botContext)
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (message.type === 'flowBuilderContent') {
|
|
179
|
+
const flowContents = await this.getFlowContentsByContentId(
|
|
180
|
+
botContext,
|
|
181
|
+
message.contentId
|
|
182
|
+
)
|
|
183
|
+
for (const content of flowContents) {
|
|
184
|
+
await content.processContent(botContext)
|
|
185
|
+
this.jsxElements.push(content.toBotonic(botContext))
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async processContent(
|
|
193
|
+
botContext: BotContext,
|
|
194
|
+
previousContents?: FlowContent[]
|
|
195
|
+
): Promise<void> {
|
|
196
|
+
if (this.messages.length === 0) {
|
|
197
|
+
await this.resolveAIAgentResponse(botContext, previousContents)
|
|
198
|
+
}
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
toBotonic(): JSX.Element {
|
|
203
|
+
return <>{this.jsxElements}</>
|
|
66
204
|
}
|
|
67
205
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type BotContext,
|
|
3
|
+
BotonicAction,
|
|
4
|
+
EventAction,
|
|
5
|
+
type EventBotAction,
|
|
6
|
+
} from '@botonic/core'
|
|
2
7
|
import type { ActionRequest } from '@botonic/react'
|
|
3
8
|
|
|
4
9
|
import type { FlowBuilderApi } from '../api'
|
|
@@ -25,9 +30,9 @@ export class FlowBotAction extends ContentFieldsBase {
|
|
|
25
30
|
return newBotAction
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
async trackFlow(
|
|
33
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
29
34
|
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
|
|
30
|
-
getCommonFlowContentEventArgsForContentId(
|
|
35
|
+
getCommonFlowContentEventArgsForContentId(botContext, this.id)
|
|
31
36
|
const eventBotAction: EventBotAction = {
|
|
32
37
|
action: EventAction.BotAction,
|
|
33
38
|
flowThreadId,
|
|
@@ -39,11 +44,17 @@ export class FlowBotAction extends ContentFieldsBase {
|
|
|
39
44
|
payload: this.payload,
|
|
40
45
|
}
|
|
41
46
|
const { action, ...eventArgs } = eventBotAction
|
|
42
|
-
await trackEvent(
|
|
47
|
+
await trackEvent(botContext, action, eventArgs)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
doBotAction(botContext: ActionRequest): void {
|
|
51
|
+
botContext.session._botonic_action = `${BotonicAction.Redirect}:${this.payload}`
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
55
|
+
this.doBotAction(botContext)
|
|
56
|
+
await this.trackFlow(botContext)
|
|
57
|
+
return
|
|
47
58
|
}
|
|
48
59
|
|
|
49
60
|
toBotonic(): JSX.Element {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { BotContext } from '@botonic/core'
|
|
2
|
+
import { Button, Reply, type Webview } from '@botonic/react'
|
|
2
3
|
|
|
3
4
|
import type { FlowBuilderApi } from '../api'
|
|
4
5
|
import { SOURCE_INFO_SEPARATOR } from '../constants'
|
|
@@ -92,11 +93,13 @@ export class FlowButton extends ContentFieldsBase {
|
|
|
92
93
|
text: string
|
|
93
94
|
payload?: string
|
|
94
95
|
url?: string
|
|
96
|
+
target?: string
|
|
95
97
|
}): FlowButton {
|
|
96
98
|
const newButton = new FlowButton(button.id)
|
|
97
99
|
newButton.text = button.text
|
|
98
100
|
if (button.url) {
|
|
99
101
|
newButton.url = button.url
|
|
102
|
+
newButton.target = button.target
|
|
100
103
|
} else {
|
|
101
104
|
newButton.payload = button.payload
|
|
102
105
|
}
|
|
@@ -126,12 +129,16 @@ export class FlowButton extends ContentFieldsBase {
|
|
|
126
129
|
return FlowWebview.fromHubtypeCMS(targetNode)
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
async trackFlow(
|
|
132
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
130
133
|
if (this.flowWebview) {
|
|
131
|
-
await this.flowWebview.trackFlow(
|
|
134
|
+
await this.flowWebview.trackFlow(botContext)
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
137
|
|
|
138
|
+
async processContent(): Promise<void> {
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
|
|
135
142
|
renderButton(buttonIndex: number, buttonStyle?: HtButtonStyle): JSX.Element {
|
|
136
143
|
if (buttonStyle === HtButtonStyle.QUICK_REPLY) {
|
|
137
144
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BotContext } from '@botonic/core'
|
|
2
2
|
|
|
3
|
-
import { getFlowBuilderPlugin } from '../
|
|
3
|
+
import { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'
|
|
4
4
|
import { ContentFieldsBase } from './content-fields-base'
|
|
5
5
|
import {
|
|
6
6
|
HtAiValidationType,
|
|
@@ -30,13 +30,16 @@ export class FlowCaptureUserInput extends ContentFieldsBase {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
-
async trackFlow(
|
|
33
|
+
async trackFlow(_botContext: BotContext): Promise<void> {
|
|
34
34
|
return
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
async processContent(): Promise<void> {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
toBotonic(botContext: BotContext): JSX.Element {
|
|
42
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)
|
|
40
43
|
const cmsApi = flowBuilderPlugin.cmsApi
|
|
41
44
|
cmsApi.setCaptureUserInputId(this.id)
|
|
42
45
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type BotContext,
|
|
3
|
+
type CarouselMessage,
|
|
4
|
+
isWhatsapp,
|
|
5
|
+
} from '@botonic/core'
|
|
2
6
|
import {
|
|
3
7
|
type ActionRequest,
|
|
4
8
|
Button,
|
|
@@ -111,10 +115,10 @@ export class FlowCarousel extends ContentFieldsBase {
|
|
|
111
115
|
static fromAIAgent(
|
|
112
116
|
id: string,
|
|
113
117
|
carouselMessage: CarouselMessage,
|
|
114
|
-
|
|
118
|
+
botContext: ActionRequest
|
|
115
119
|
): JSX.Element {
|
|
116
120
|
if (
|
|
117
|
-
isWhatsapp(
|
|
121
|
+
isWhatsapp(botContext.session) &&
|
|
118
122
|
FlowCarousel.areElementsValidForWhatsapp(carouselMessage)
|
|
119
123
|
) {
|
|
120
124
|
if (
|
|
@@ -168,9 +172,10 @@ export class FlowCarousel extends ContentFieldsBase {
|
|
|
168
172
|
return (
|
|
169
173
|
<Carousel key={id}>
|
|
170
174
|
{carouselMessage.content.elements.map((element, index) =>
|
|
171
|
-
FlowElement.fromAIAgent(
|
|
172
|
-
id
|
|
173
|
-
|
|
175
|
+
FlowElement.fromAIAgent(
|
|
176
|
+
`${id}-element-${index}`,
|
|
177
|
+
element
|
|
178
|
+
).renderElement(id)
|
|
174
179
|
)}
|
|
175
180
|
</Carousel>
|
|
176
181
|
)
|
|
@@ -196,10 +201,15 @@ export class FlowCarousel extends ContentFieldsBase {
|
|
|
196
201
|
}
|
|
197
202
|
}
|
|
198
203
|
|
|
199
|
-
|
|
204
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
205
|
+
await this.trackFlow(botContext)
|
|
206
|
+
return
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
toBotonic(botContext: BotContext): JSX.Element {
|
|
200
210
|
const carouselMessage = this.toCarouselMessage(this.elements)
|
|
201
211
|
if (
|
|
202
|
-
isWhatsapp(
|
|
212
|
+
isWhatsapp(botContext.session) &&
|
|
203
213
|
FlowCarousel.areElementsValidForWhatsapp(carouselMessage)
|
|
204
214
|
) {
|
|
205
215
|
if (this.elements.length === 1 && this.elements[0].button?.url) {
|
|
@@ -209,7 +219,7 @@ export class FlowCarousel extends ContentFieldsBase {
|
|
|
209
219
|
|
|
210
220
|
return (
|
|
211
221
|
<WhatsappCTAUrlButton
|
|
212
|
-
key={id}
|
|
222
|
+
key={this.id}
|
|
213
223
|
body={element.title}
|
|
214
224
|
headerType={WhatsappCTAUrlHeaderType.Image}
|
|
215
225
|
headerImage={element.image}
|
|
@@ -246,8 +256,8 @@ export class FlowCarousel extends ContentFieldsBase {
|
|
|
246
256
|
)
|
|
247
257
|
}
|
|
248
258
|
return (
|
|
249
|
-
<Carousel key={id}>
|
|
250
|
-
{this.elements.map(element => element.
|
|
259
|
+
<Carousel key={this.id}>
|
|
260
|
+
{this.elements.map(element => element.renderElement(this.id))}
|
|
251
261
|
</Carousel>
|
|
252
262
|
)
|
|
253
263
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type BotContext,
|
|
3
|
+
EventAction,
|
|
4
|
+
type EventConditionalChannel,
|
|
5
|
+
} from '@botonic/core'
|
|
3
6
|
|
|
4
7
|
import {
|
|
5
8
|
getCommonFlowContentEventArgsForContentId,
|
|
@@ -16,18 +19,18 @@ export class FlowChannelConditional extends ContentFieldsBase {
|
|
|
16
19
|
|
|
17
20
|
static fromHubtypeCMS(
|
|
18
21
|
component: HtChannelConditionalNode,
|
|
19
|
-
|
|
22
|
+
botContext: BotContext
|
|
20
23
|
): FlowChannelConditional {
|
|
21
24
|
const newChannelConditional = new FlowChannelConditional(component.id)
|
|
22
25
|
newChannelConditional.code = component.code
|
|
23
26
|
newChannelConditional.resultMapping = component.content.result_mapping
|
|
24
|
-
newChannelConditional.setConditionalResult(
|
|
27
|
+
newChannelConditional.setConditionalResult(botContext)
|
|
25
28
|
|
|
26
29
|
return newChannelConditional
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
setConditionalResult(
|
|
30
|
-
const provider =
|
|
32
|
+
setConditionalResult(botContext: BotContext): void {
|
|
33
|
+
const provider = botContext.session.user.provider
|
|
31
34
|
const conditionalResult =
|
|
32
35
|
this.resultMapping.find(rMap => rMap.result === provider) ||
|
|
33
36
|
this.resultMapping.find(rMap => rMap.result === 'default')
|
|
@@ -41,9 +44,9 @@ export class FlowChannelConditional extends ContentFieldsBase {
|
|
|
41
44
|
this.followUp = conditionalResult.target
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
async trackFlow(
|
|
47
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
45
48
|
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
|
|
46
|
-
getCommonFlowContentEventArgsForContentId(
|
|
49
|
+
getCommonFlowContentEventArgsForContentId(botContext, this.id)
|
|
47
50
|
|
|
48
51
|
const eventChannelConditional: EventConditionalChannel = {
|
|
49
52
|
action: EventAction.ConditionalChannel,
|
|
@@ -56,7 +59,11 @@ export class FlowChannelConditional extends ContentFieldsBase {
|
|
|
56
59
|
channel: this.channelResult,
|
|
57
60
|
}
|
|
58
61
|
const { action, ...eventArgs } = eventChannelConditional
|
|
59
|
-
await trackEvent(
|
|
62
|
+
await trackEvent(botContext, action, eventArgs)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
66
|
+
await this.trackFlow(botContext)
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
toBotonic(): JSX.Element {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type BotContext,
|
|
3
|
+
EventAction,
|
|
4
|
+
type EventConditionalCountry,
|
|
5
|
+
} from '@botonic/core'
|
|
3
6
|
|
|
4
7
|
import {
|
|
5
8
|
getCommonFlowContentEventArgsForContentId,
|
|
@@ -15,18 +18,18 @@ export class FlowCountryConditional extends ContentFieldsBase {
|
|
|
15
18
|
|
|
16
19
|
static fromHubtypeCMS(
|
|
17
20
|
component: HtCountryConditionalNode,
|
|
18
|
-
|
|
21
|
+
botContext: BotContext
|
|
19
22
|
): FlowCountryConditional {
|
|
20
23
|
const newCountryConditional = new FlowCountryConditional(component.id)
|
|
21
24
|
newCountryConditional.code = component.code
|
|
22
25
|
newCountryConditional.resultMapping = component.content.result_mapping
|
|
23
|
-
newCountryConditional.setConditionalResult(
|
|
26
|
+
newCountryConditional.setConditionalResult(botContext)
|
|
24
27
|
|
|
25
28
|
return newCountryConditional
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
setConditionalResult(
|
|
29
|
-
const country =
|
|
31
|
+
setConditionalResult(botContext: BotContext): void {
|
|
32
|
+
const country = botContext.getUserCountry()
|
|
30
33
|
const conditionalResult =
|
|
31
34
|
this.resultMapping.find(rMap => rMap.result === country) ||
|
|
32
35
|
this.resultMapping.find(rMap => rMap.result === 'default')
|
|
@@ -39,9 +42,9 @@ export class FlowCountryConditional extends ContentFieldsBase {
|
|
|
39
42
|
this.followUp = conditionalResult.target
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
async trackFlow(
|
|
45
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
43
46
|
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
|
|
44
|
-
getCommonFlowContentEventArgsForContentId(
|
|
47
|
+
getCommonFlowContentEventArgsForContentId(botContext, this.id)
|
|
45
48
|
if (!this.conditionalResult?.result) {
|
|
46
49
|
console.warn(
|
|
47
50
|
`Tracking event for node ${this.code} but no conditional result found`
|
|
@@ -58,7 +61,12 @@ export class FlowCountryConditional extends ContentFieldsBase {
|
|
|
58
61
|
country: (this.conditionalResult?.result as string) ?? '',
|
|
59
62
|
}
|
|
60
63
|
const { action, ...eventArgs } = eventCountryConditional
|
|
61
|
-
await trackEvent(
|
|
64
|
+
await trackEvent(botContext, action, eventArgs)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
68
|
+
await this.trackFlow(botContext)
|
|
69
|
+
return
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
toBotonic(): JSX.Element {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type BotContext,
|
|
3
|
+
EventAction,
|
|
4
|
+
type EventConditionalCustom,
|
|
5
|
+
} from '@botonic/core'
|
|
3
6
|
|
|
4
7
|
import {
|
|
5
8
|
getCommonFlowContentEventArgsForContentId,
|
|
@@ -22,13 +25,13 @@ export class FlowCustomConditional extends ContentFieldsBase {
|
|
|
22
25
|
|
|
23
26
|
static fromHubtypeCMS(
|
|
24
27
|
component: HtCustomConditionalNode,
|
|
25
|
-
|
|
28
|
+
botContext: BotContext
|
|
26
29
|
): FlowCustomConditional {
|
|
27
30
|
const newCustomConditional = new FlowCustomConditional(component.id)
|
|
28
31
|
newCustomConditional.code = component.code
|
|
29
32
|
newCustomConditional.arguments = component.content.arguments
|
|
30
33
|
newCustomConditional.resultMapping = component.content.result_mapping
|
|
31
|
-
newCustomConditional.setConditionalResult(
|
|
34
|
+
newCustomConditional.setConditionalResult(botContext)
|
|
32
35
|
newCustomConditional.variableFormat = (
|
|
33
36
|
component.content.arguments as HtFunctionArgument[]
|
|
34
37
|
)[0].type
|
|
@@ -36,7 +39,7 @@ export class FlowCustomConditional extends ContentFieldsBase {
|
|
|
36
39
|
return newCustomConditional
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
setConditionalResult(
|
|
42
|
+
setConditionalResult(botContext: BotContext): void {
|
|
40
43
|
const functionArgument = this.arguments.find(arg => {
|
|
41
44
|
if ('name' in arg) {
|
|
42
45
|
return arg.name === 'keyPath'
|
|
@@ -52,7 +55,7 @@ export class FlowCustomConditional extends ContentFieldsBase {
|
|
|
52
55
|
throw new Error(`Key path not found for node ${this.code}`)
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
const botVariable = this.getValueFromKeyPath(
|
|
58
|
+
const botVariable = this.getValueFromKeyPath(botContext, keyPath)
|
|
56
59
|
|
|
57
60
|
let conditionalResult =
|
|
58
61
|
this.resultMapping.find(rMap => rMap.result === botVariable) ||
|
|
@@ -80,9 +83,9 @@ export class FlowCustomConditional extends ContentFieldsBase {
|
|
|
80
83
|
this.followUp = conditionalResult.target
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
async trackFlow(
|
|
86
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
84
87
|
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
|
|
85
|
-
getCommonFlowContentEventArgsForContentId(
|
|
88
|
+
getCommonFlowContentEventArgsForContentId(botContext, this.id)
|
|
86
89
|
if (!this.conditionalResult?.result) {
|
|
87
90
|
console.warn(
|
|
88
91
|
`Tracking event for node ${this.code} but no conditional result found`
|
|
@@ -100,7 +103,7 @@ export class FlowCustomConditional extends ContentFieldsBase {
|
|
|
100
103
|
variableFormat: this.variableFormat,
|
|
101
104
|
}
|
|
102
105
|
const { action, ...eventArgs } = eventCustomConditional
|
|
103
|
-
await trackEvent(
|
|
106
|
+
await trackEvent(botContext, action, eventArgs)
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
private isBooleanConditional(resultMapping: HtFunctionResult[]): boolean {
|
|
@@ -111,6 +114,11 @@ export class FlowCustomConditional extends ContentFieldsBase {
|
|
|
111
114
|
)
|
|
112
115
|
}
|
|
113
116
|
|
|
117
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
118
|
+
await this.trackFlow(botContext)
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
|
|
114
122
|
toBotonic() {
|
|
115
123
|
return <></>
|
|
116
124
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type { Button } from '@botonic/core'
|
|
2
|
-
import {
|
|
3
|
-
type ActionRequest,
|
|
4
|
-
Element,
|
|
5
|
-
Pic,
|
|
6
|
-
Subtitle,
|
|
7
|
-
Title,
|
|
8
|
-
} from '@botonic/react'
|
|
1
|
+
import type { BotContext, Button } from '@botonic/core'
|
|
2
|
+
import { Element, Pic, Subtitle, Title } from '@botonic/react'
|
|
9
3
|
|
|
10
4
|
import type { FlowBuilderApi } from '../api'
|
|
11
5
|
import { ContentFieldsBase } from './content-fields-base'
|
|
@@ -60,13 +54,18 @@ export class FlowElement extends ContentFieldsBase {
|
|
|
60
54
|
return newElement
|
|
61
55
|
}
|
|
62
56
|
|
|
63
|
-
async trackFlow(
|
|
57
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
64
58
|
if (this.button) {
|
|
65
|
-
await this.button.trackFlow(
|
|
59
|
+
await this.button.trackFlow(botContext)
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
|
|
63
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
64
|
+
await this.trackFlow(botContext)
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
renderElement(parentId: string): JSX.Element {
|
|
70
69
|
return (
|
|
71
70
|
<Element key={`${parentId}-${this.id}`}>
|
|
72
71
|
<Pic src={this.image} />
|