@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,12 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type BotContext,
|
|
2
3
|
EventAction,
|
|
3
4
|
type EventRedirectFlow,
|
|
4
|
-
INPUT,
|
|
5
|
-
PROVIDER,
|
|
6
5
|
} from '@botonic/core'
|
|
7
|
-
|
|
6
|
+
|
|
8
7
|
import type { FlowBuilderApi } from '../api'
|
|
9
|
-
import { AI_AGENTS_FLOW_NAME } from '../constants'
|
|
10
8
|
import {
|
|
11
9
|
getCommonFlowContentEventArgsForContentId,
|
|
12
10
|
trackEvent,
|
|
@@ -34,26 +32,9 @@ export class FlowGoToFlow extends ContentFieldsBase {
|
|
|
34
32
|
return newGoToFlow
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
botContext: ActionRequest,
|
|
39
|
-
component: HtGoToFlow,
|
|
40
|
-
cmsApi: FlowBuilderApi
|
|
41
|
-
): Promise<void> {
|
|
42
|
-
const goToFlowContent = FlowGoToFlow.fromHubtypeCMS(component, cmsApi)
|
|
43
|
-
if (goToFlowContent.flowTargetName === AI_AGENTS_FLOW_NAME) {
|
|
44
|
-
await goToFlowContent.trackFlow(botContext)
|
|
45
|
-
|
|
46
|
-
botContext.input.payload = undefined
|
|
47
|
-
if (botContext.session.user.provider === PROVIDER.WHATSAPP) {
|
|
48
|
-
botContext.input.type = INPUT.TEXT
|
|
49
|
-
botContext.input.data = botContext.input.referral
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async trackFlow(request: ActionRequest): Promise<void> {
|
|
35
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
55
36
|
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
|
|
56
|
-
getCommonFlowContentEventArgsForContentId(
|
|
37
|
+
getCommonFlowContentEventArgsForContentId(botContext, this.id)
|
|
57
38
|
const eventGoToFlow: EventRedirectFlow = {
|
|
58
39
|
action: EventAction.RedirectFlow,
|
|
59
40
|
flowThreadId,
|
|
@@ -66,7 +47,12 @@ export class FlowGoToFlow extends ContentFieldsBase {
|
|
|
66
47
|
flowNodeIsMeaningful: false,
|
|
67
48
|
}
|
|
68
49
|
const { action, ...eventArgs } = eventGoToFlow
|
|
69
|
-
await trackEvent(
|
|
50
|
+
await trackEvent(botContext, action, eventArgs)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
54
|
+
await this.trackFlow(botContext)
|
|
55
|
+
return
|
|
70
56
|
}
|
|
71
57
|
|
|
72
58
|
toBotonic(): JSX.Element {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type BotContext,
|
|
3
|
+
HandOffBuilder,
|
|
4
|
+
HelpdeskEvent,
|
|
5
|
+
isDev,
|
|
6
|
+
isWebchat,
|
|
7
|
+
} from '@botonic/core'
|
|
8
|
+
import { WebchatSettings } from '@botonic/react'
|
|
3
9
|
|
|
4
10
|
import type { FlowBuilderApi } from '../api'
|
|
5
11
|
import { getCommonFlowContentEventArgsForContentId } from '../tracking'
|
|
@@ -47,8 +53,8 @@ export class FlowHandoff extends ContentFieldsBase {
|
|
|
47
53
|
return undefined
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
async doHandoff(
|
|
51
|
-
const handOffBuilder = new HandOffBuilder(
|
|
56
|
+
async doHandoff(botContext: BotContext): Promise<void> {
|
|
57
|
+
const handOffBuilder = new HandOffBuilder(botContext.session)
|
|
52
58
|
handOffBuilder.withAutoAssignOnWaiting(this.handoffAutoAssign)
|
|
53
59
|
|
|
54
60
|
if (this.hasQueuePositionChangedNotificationsEnabled) {
|
|
@@ -62,12 +68,12 @@ export class FlowHandoff extends ContentFieldsBase {
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
if (this.queue) {
|
|
65
|
-
const language =
|
|
71
|
+
const language = botContext.getSystemLocale()
|
|
66
72
|
|
|
67
73
|
handOffBuilder.withQueue(this.queue.id)
|
|
68
74
|
|
|
69
75
|
const { flowId, flowName, flowNodeId, flowNodeContentId } =
|
|
70
|
-
getCommonFlowContentEventArgsForContentId(
|
|
76
|
+
getCommonFlowContentEventArgsForContentId(botContext, this.id)
|
|
71
77
|
|
|
72
78
|
handOffBuilder.withBotEvent({
|
|
73
79
|
flowId,
|
|
@@ -85,13 +91,18 @@ export class FlowHandoff extends ContentFieldsBase {
|
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
88
|
-
async trackFlow(
|
|
94
|
+
async trackFlow(_botContext: BotContext): Promise<void> {
|
|
89
95
|
// TODO: Not apply for this content because backend track handoff success event
|
|
90
96
|
}
|
|
91
97
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
99
|
+
await this.doHandoff(botContext)
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
toBotonic(botContext: BotContext): JSX.Element {
|
|
104
|
+
return isDev(botContext.session) || isWebchat(botContext.session) ? (
|
|
105
|
+
<WebchatSettings key={this.id} enableUserInput={true} />
|
|
95
106
|
) : (
|
|
96
107
|
<></>
|
|
97
108
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { BotContext } from '@botonic/core'
|
|
2
|
+
import { Image } from '@botonic/react'
|
|
2
3
|
|
|
3
4
|
import { trackOneContent } from '../tracking'
|
|
4
5
|
import { ContentFieldsBase } from './content-fields-base'
|
|
@@ -16,11 +17,16 @@ export class FlowImage extends ContentFieldsBase {
|
|
|
16
17
|
return newImage
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
async trackFlow(
|
|
20
|
-
await trackOneContent(
|
|
20
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
21
|
+
await trackOneContent(botContext, this)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
25
|
+
await this.trackFlow(botContext)
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
toBotonic(): JSX.Element {
|
|
30
|
+
return <Image key={this.id} src={this.src} />
|
|
25
31
|
}
|
|
26
32
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { BotContext } from '@botonic/core'
|
|
2
|
+
import { Text } from '@botonic/react'
|
|
2
3
|
|
|
3
4
|
import { ContentFieldsBase } from './content-fields-base'
|
|
4
5
|
import type { HtKnowledgeBaseNode } from './hubtype-fields'
|
|
@@ -30,19 +31,24 @@ export class FlowKnowledgeBase extends ContentFieldsBase {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
-
async trackFlow(
|
|
34
|
+
async trackFlow(_botContext: BotContext): Promise<void> {
|
|
34
35
|
// TODO: Review how we can track here the knowledge base event here.
|
|
35
36
|
// We should store event args in an attribute of FlowKnowledgeBase
|
|
36
37
|
// when knowledge base is resolved inside the flow builder action
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
41
|
+
await this.trackFlow(botContext)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
toBotonic(botContext: BotContext): JSX.Element {
|
|
40
46
|
return (
|
|
41
47
|
<Text
|
|
42
|
-
key={id}
|
|
48
|
+
key={this.id}
|
|
43
49
|
feedbackEnabled={this.feedbackEnabled}
|
|
44
50
|
inferenceId={this.inferenceId}
|
|
45
|
-
botInteractionId={
|
|
51
|
+
botInteractionId={botContext.input.bot_interaction_id}
|
|
46
52
|
>
|
|
47
53
|
{this.text}
|
|
48
54
|
</Text>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type BotContext,
|
|
3
|
+
EventAction,
|
|
4
|
+
type EventConditionalQueueStatus,
|
|
5
|
+
} from '@botonic/core'
|
|
3
6
|
|
|
4
7
|
import { getArgumentsByLocale } from '../functions'
|
|
5
8
|
import { HubtypeQueuesApi } from '../services/hubtype-queues-api'
|
|
@@ -99,9 +102,9 @@ export class FlowQueueStatusConditional extends ContentFieldsBase {
|
|
|
99
102
|
return data.open ? QueueStatusResult.OPEN : QueueStatusResult.CLOSED
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
async trackFlow(
|
|
105
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
103
106
|
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
|
|
104
|
-
getCommonFlowContentEventArgsForContentId(
|
|
107
|
+
getCommonFlowContentEventArgsForContentId(botContext, this.id)
|
|
105
108
|
if (!this.conditionalResult?.result) {
|
|
106
109
|
console.warn(
|
|
107
110
|
`Tracking event for node ${this.code} but no conditional result found`
|
|
@@ -121,7 +124,12 @@ export class FlowQueueStatusConditional extends ContentFieldsBase {
|
|
|
121
124
|
isAvailableAgent: this.isAvailableAgent,
|
|
122
125
|
}
|
|
123
126
|
const { action, ...eventArgs } = eventQueueStatusConditional
|
|
124
|
-
await trackEvent(
|
|
127
|
+
await trackEvent(botContext, action, eventArgs)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
131
|
+
await this.trackFlow(botContext)
|
|
132
|
+
return
|
|
125
133
|
}
|
|
126
134
|
|
|
127
135
|
toBotonic(): JSX.Element {
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { isDev, isWebchat, isWhatsapp } from '@botonic/core'
|
|
2
|
-
import {
|
|
3
|
-
type ActionRequest,
|
|
4
|
-
CustomRatingMessage,
|
|
5
|
-
Text,
|
|
6
|
-
WhatsappButtonList,
|
|
7
|
-
} from '@botonic/react'
|
|
1
|
+
import { type BotContext, isDev, isWebchat, isWhatsapp } from '@botonic/core'
|
|
2
|
+
import { CustomRatingMessage, Text, WhatsappButtonList } from '@botonic/react'
|
|
8
3
|
|
|
9
|
-
import { getFlowBuilderPlugin } from '../helpers'
|
|
10
4
|
import { trackOneContent } from '../tracking'
|
|
5
|
+
import { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'
|
|
11
6
|
import { ContentFieldsBase } from './content-fields-base'
|
|
12
7
|
import { FlowButton } from './flow-button'
|
|
13
8
|
import { type HtRatingNode, RatingType } from './hubtype-fields'
|
|
@@ -40,17 +35,22 @@ export class FlowRating extends ContentFieldsBase {
|
|
|
40
35
|
return newRating
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
async trackFlow(
|
|
44
|
-
await trackOneContent(
|
|
38
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
39
|
+
await trackOneContent(botContext, this)
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
43
|
+
await this.trackFlow(botContext)
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
toBotonic(botContext: BotContext): JSX.Element {
|
|
48
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)
|
|
49
49
|
const customRatingMessageEnabled =
|
|
50
50
|
flowBuilderPlugin.customRatingMessageEnabled
|
|
51
|
-
const replacedText = this.replaceVariables(this.text,
|
|
51
|
+
const replacedText = this.replaceVariables(this.text, botContext)
|
|
52
52
|
|
|
53
|
-
if (isWhatsapp(
|
|
53
|
+
if (isWhatsapp(botContext.session)) {
|
|
54
54
|
return (
|
|
55
55
|
<WhatsappButtonList
|
|
56
56
|
body={replacedText}
|
|
@@ -68,7 +68,7 @@ export class FlowRating extends ContentFieldsBase {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (
|
|
71
|
-
(isWebchat(
|
|
71
|
+
(isWebchat(botContext.session) || isDev(botContext.session)) &&
|
|
72
72
|
customRatingMessageEnabled
|
|
73
73
|
) {
|
|
74
74
|
const payloads = this.buttons
|
|
@@ -88,7 +88,7 @@ export class FlowRating extends ContentFieldsBase {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
|
-
<Text key={id}>
|
|
91
|
+
<Text key={this.id}>
|
|
92
92
|
{replacedText}
|
|
93
93
|
{this.buttons.map((button, buttonIndex) =>
|
|
94
94
|
button.renderButton(buttonIndex)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
BotContext,
|
|
2
3
|
BotExecutorMessage,
|
|
3
4
|
TextMessage,
|
|
4
5
|
TextWithButtonsMessage,
|
|
5
6
|
} from '@botonic/core'
|
|
6
|
-
import {
|
|
7
|
+
import { Text } from '@botonic/react'
|
|
7
8
|
|
|
8
9
|
import type { FlowBuilderApi } from '../api'
|
|
9
10
|
import { EMPTY_PAYLOAD, SOURCE_INFO_SEPARATOR } from '../constants'
|
|
@@ -34,10 +35,10 @@ export class FlowText extends ContentFieldsBase {
|
|
|
34
35
|
return newText
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
async trackFlow(
|
|
38
|
-
await trackOneContent(
|
|
38
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
39
|
+
await trackOneContent(botContext, this)
|
|
39
40
|
for (const button of this.buttons) {
|
|
40
|
-
await button.trackFlow(
|
|
41
|
+
await button.trackFlow(botContext)
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -57,6 +58,7 @@ export class FlowText extends ContentFieldsBase {
|
|
|
57
58
|
id: `${id}-button-${buttonIndex}`,
|
|
58
59
|
text: button.text,
|
|
59
60
|
url: button.url,
|
|
61
|
+
target: button.target,
|
|
60
62
|
payload:
|
|
61
63
|
button.payload ||
|
|
62
64
|
`${EMPTY_PAYLOAD}${SOURCE_INFO_SEPARATOR}${buttonIndex}`,
|
|
@@ -67,10 +69,15 @@ export class FlowText extends ContentFieldsBase {
|
|
|
67
69
|
)
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
73
|
+
await this.trackFlow(botContext)
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
toBotonic(botContext: BotContext): JSX.Element {
|
|
78
|
+
const replacedText = this.replaceVariables(this.text, botContext)
|
|
72
79
|
return (
|
|
73
|
-
<Text key={id}>
|
|
80
|
+
<Text key={this.id}>
|
|
74
81
|
{replacedText}
|
|
75
82
|
{this.buttons.map((button, buttonIndex) =>
|
|
76
83
|
button.renderButton(buttonIndex, this.buttonStyle)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { BotContext } from '@botonic/core'
|
|
2
|
+
import { Video } from '@botonic/react'
|
|
2
3
|
|
|
3
4
|
import { trackOneContent } from '../tracking'
|
|
4
5
|
import { ContentFieldsBase } from './content-fields-base'
|
|
@@ -16,11 +17,16 @@ export class FlowVideo extends ContentFieldsBase {
|
|
|
16
17
|
return newVideo
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
async trackFlow(
|
|
20
|
-
await trackOneContent(
|
|
20
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
21
|
+
await trackOneContent(botContext, this)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
25
|
+
await this.trackFlow(botContext)
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
toBotonic(): JSX.Element {
|
|
30
|
+
return <Video key={this.id} src={this.src} />
|
|
25
31
|
}
|
|
26
32
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type BotContext,
|
|
3
|
+
EventAction,
|
|
4
|
+
type EventWebviewActionTriggered,
|
|
5
|
+
} from '@botonic/core'
|
|
3
6
|
|
|
4
7
|
import {
|
|
5
8
|
getCommonFlowContentEventArgsForContentId,
|
|
@@ -25,9 +28,9 @@ export class FlowWebview extends ContentFieldsBase {
|
|
|
25
28
|
return newWebview
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
async trackFlow(
|
|
31
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
29
32
|
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =
|
|
30
|
-
getCommonFlowContentEventArgsForContentId(
|
|
33
|
+
getCommonFlowContentEventArgsForContentId(botContext, this.id)
|
|
31
34
|
|
|
32
35
|
const eventWebviewActionTriggered: EventWebviewActionTriggered = {
|
|
33
36
|
action: EventAction.WebviewActionTriggered,
|
|
@@ -41,6 +44,10 @@ export class FlowWebview extends ContentFieldsBase {
|
|
|
41
44
|
webviewName: this.webviewName,
|
|
42
45
|
}
|
|
43
46
|
const { action, ...eventArgs } = eventWebviewActionTriggered
|
|
44
|
-
await trackEvent(
|
|
47
|
+
await trackEvent(botContext, action, eventArgs)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async processContent(): Promise<void> {
|
|
51
|
+
return
|
|
45
52
|
}
|
|
46
53
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { isWhatsapp } from '@botonic/core'
|
|
1
|
+
import { type BotContext, isWhatsapp } from '@botonic/core'
|
|
2
2
|
import {
|
|
3
|
-
type ActionRequest,
|
|
4
3
|
Button,
|
|
5
4
|
Text,
|
|
6
5
|
WhatsappCTAUrlButton,
|
|
@@ -115,14 +114,19 @@ export class FlowWhatsappCtaUrlButtonNode extends ContentFieldsBase {
|
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
async trackFlow(
|
|
119
|
-
await trackOneContent(
|
|
117
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
118
|
+
await trackOneContent(botContext, this)
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
122
|
+
await this.trackFlow(botContext)
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
toBotonic(botContext: BotContext): JSX.Element {
|
|
127
|
+
const replacedText = this.replaceVariables(this.text, botContext)
|
|
124
128
|
|
|
125
|
-
if (!isWhatsapp(
|
|
129
|
+
if (!isWhatsapp(botContext.session)) {
|
|
126
130
|
return (
|
|
127
131
|
<Text>
|
|
128
132
|
{replacedText}
|
|
@@ -137,7 +141,7 @@ export class FlowWhatsappCtaUrlButtonNode extends ContentFieldsBase {
|
|
|
137
141
|
) {
|
|
138
142
|
return (
|
|
139
143
|
<WhatsappCTAUrlButton
|
|
140
|
-
key={id}
|
|
144
|
+
key={this.id}
|
|
141
145
|
body={replacedText}
|
|
142
146
|
headerType={this.headerType}
|
|
143
147
|
headerImage={this.headerImage}
|
|
@@ -154,7 +158,7 @@ export class FlowWhatsappCtaUrlButtonNode extends ContentFieldsBase {
|
|
|
154
158
|
) {
|
|
155
159
|
return (
|
|
156
160
|
<WhatsappCTAUrlButton
|
|
157
|
-
key={id}
|
|
161
|
+
key={this.id}
|
|
158
162
|
body={replacedText}
|
|
159
163
|
headerType={this.headerType}
|
|
160
164
|
headerVideo={this.headerVideo}
|
|
@@ -171,7 +175,7 @@ export class FlowWhatsappCtaUrlButtonNode extends ContentFieldsBase {
|
|
|
171
175
|
) {
|
|
172
176
|
return (
|
|
173
177
|
<WhatsappCTAUrlButton
|
|
174
|
-
key={id}
|
|
178
|
+
key={this.id}
|
|
175
179
|
body={replacedText}
|
|
176
180
|
headerType={this.headerType}
|
|
177
181
|
headerDocument={this.headerDocument}
|
|
@@ -185,7 +189,7 @@ export class FlowWhatsappCtaUrlButtonNode extends ContentFieldsBase {
|
|
|
185
189
|
if (this.headerType === WhatsappCTAUrlHeaderType.Text && this.header) {
|
|
186
190
|
return (
|
|
187
191
|
<WhatsappCTAUrlButton
|
|
188
|
-
key={id}
|
|
192
|
+
key={this.id}
|
|
189
193
|
body={replacedText}
|
|
190
194
|
header={this.header}
|
|
191
195
|
headerType={this.headerType}
|
|
@@ -198,7 +202,7 @@ export class FlowWhatsappCtaUrlButtonNode extends ContentFieldsBase {
|
|
|
198
202
|
|
|
199
203
|
return (
|
|
200
204
|
<WhatsappCTAUrlButton
|
|
201
|
-
key={id}
|
|
205
|
+
key={this.id}
|
|
202
206
|
body={replacedText}
|
|
203
207
|
footer={this.footer}
|
|
204
208
|
displayText={this.displayText}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { isWhatsapp } from '@botonic/core'
|
|
1
|
+
import { type BotContext, isWhatsapp } from '@botonic/core'
|
|
2
2
|
import {
|
|
3
|
-
type ActionRequest,
|
|
4
3
|
Text,
|
|
5
4
|
WhatsAppTemplateButtonSubType,
|
|
6
5
|
WhatsAppTemplateComponentType,
|
|
@@ -15,8 +14,8 @@ import {
|
|
|
15
14
|
type WhatsappTemplateVoiceCallButton,
|
|
16
15
|
} from '@botonic/react'
|
|
17
16
|
|
|
18
|
-
import { getFlowBuilderPlugin } from '../helpers'
|
|
19
17
|
import { trackOneContent } from '../tracking'
|
|
18
|
+
import { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'
|
|
20
19
|
import { ContentFieldsBase } from './content-fields-base'
|
|
21
20
|
import type {
|
|
22
21
|
HtButton,
|
|
@@ -81,7 +80,7 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
|
|
|
81
80
|
whatsappTemplate: HtWhatsAppTemplate,
|
|
82
81
|
headerVariables: HeaderVariables,
|
|
83
82
|
locale: string,
|
|
84
|
-
|
|
83
|
+
botContext: BotContext
|
|
85
84
|
): WhatsappTemplateComponentHeader | undefined {
|
|
86
85
|
const headerComponent = whatsappTemplate.components.find(
|
|
87
86
|
component => component.type === WhatsAppTemplateComponentType.HEADER
|
|
@@ -91,7 +90,7 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
|
|
|
91
90
|
headerComponent &&
|
|
92
91
|
headerComponent.format === WhatsAppTemplateParameterType.TEXT
|
|
93
92
|
) {
|
|
94
|
-
return this.createHeaderTextComponent(headerVariables,
|
|
93
|
+
return this.createHeaderTextComponent(headerVariables, botContext)
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
if (
|
|
@@ -113,12 +112,12 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
|
|
|
113
112
|
|
|
114
113
|
private createHeaderTextComponent(
|
|
115
114
|
headerVariables: HeaderVariables,
|
|
116
|
-
|
|
115
|
+
botContext: BotContext
|
|
117
116
|
): WhatsappTemplateComponentHeader {
|
|
118
117
|
return {
|
|
119
118
|
type: WhatsAppTemplateComponentType.HEADER,
|
|
120
119
|
parameters: Object.values(headerVariables.text || {}).map(value => {
|
|
121
|
-
const valueVariable = this.replaceVariables(value,
|
|
120
|
+
const valueVariable = this.replaceVariables(value, botContext)
|
|
122
121
|
return {
|
|
123
122
|
type: WhatsAppTemplateParameterType.TEXT,
|
|
124
123
|
text: valueVariable,
|
|
@@ -163,15 +162,15 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
|
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
164
|
|
|
166
|
-
// TODO: To use named variables (contact_info_fields) we need to take it from
|
|
165
|
+
// TODO: To use named variables (contact_info_fields) we need to take it from botContext.session.user.contact_info, this only be able in toBotonic method
|
|
167
166
|
private getBodyComponent(
|
|
168
167
|
variableValues: Record<string, string>,
|
|
169
|
-
|
|
168
|
+
botContext: BotContext
|
|
170
169
|
): WhatsappTemplateComponentBody {
|
|
171
170
|
return {
|
|
172
171
|
type: WhatsAppTemplateComponentType.BODY,
|
|
173
172
|
parameters: Object.entries(variableValues).map(([key, value]) => {
|
|
174
|
-
const valueVariable = this.replaceVariables(value,
|
|
173
|
+
const valueVariable = this.replaceVariables(value, botContext)
|
|
175
174
|
return {
|
|
176
175
|
type: WhatsAppTemplateParameterType.TEXT,
|
|
177
176
|
parameter_name: key,
|
|
@@ -185,7 +184,7 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
|
|
|
185
184
|
whatsappTemplate: HtWhatsAppTemplate,
|
|
186
185
|
buttonNodes: HtButton[],
|
|
187
186
|
urlVariableValues: Record<string, string>,
|
|
188
|
-
|
|
187
|
+
botContext: BotContext
|
|
189
188
|
): WhatsappTemplateComponentButtons | undefined {
|
|
190
189
|
const htWhatsappTemplateButtons = whatsappTemplate.components.find(
|
|
191
190
|
component => component.type === WhatsAppTemplateComponentType.BUTTONS
|
|
@@ -200,7 +199,7 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
|
|
|
200
199
|
if (!urlParam) {
|
|
201
200
|
return null
|
|
202
201
|
}
|
|
203
|
-
return this.createUrlButtonComponent(index, urlParam,
|
|
202
|
+
return this.createUrlButtonComponent(index, urlParam, botContext)
|
|
204
203
|
}
|
|
205
204
|
|
|
206
205
|
if (button.type === WhatsAppTemplateButtonSubType.QUICK_REPLY) {
|
|
@@ -224,9 +223,9 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
|
|
|
224
223
|
private createUrlButtonComponent(
|
|
225
224
|
index: number,
|
|
226
225
|
urlParam: string,
|
|
227
|
-
|
|
226
|
+
botContext: BotContext
|
|
228
227
|
): WhatsappTemplateUrlButton {
|
|
229
|
-
const variableUrlParam = this.replaceVariables(urlParam,
|
|
228
|
+
const variableUrlParam = this.replaceVariables(urlParam, botContext)
|
|
230
229
|
return {
|
|
231
230
|
type: WhatsAppTemplateComponentType.BUTTON,
|
|
232
231
|
sub_type: WhatsAppTemplateButtonSubType.URL,
|
|
@@ -270,34 +269,39 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
|
|
|
270
269
|
}
|
|
271
270
|
}
|
|
272
271
|
|
|
273
|
-
async trackFlow(
|
|
274
|
-
await trackOneContent(
|
|
272
|
+
async trackFlow(botContext: BotContext): Promise<void> {
|
|
273
|
+
await trackOneContent(botContext, this)
|
|
275
274
|
}
|
|
276
275
|
|
|
277
|
-
|
|
276
|
+
async processContent(botContext: BotContext): Promise<void> {
|
|
277
|
+
await this.trackFlow(botContext)
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
toBotonic(botContext: BotContext): JSX.Element {
|
|
278
282
|
const templateName = this.htWhatsappTemplate.name
|
|
279
283
|
const templateLanguage = this.htWhatsappTemplate.language
|
|
280
|
-
const body = this.getBodyComponent(this.variableValues,
|
|
281
|
-
const pluginFlowBuilder = getFlowBuilderPlugin(
|
|
284
|
+
const body = this.getBodyComponent(this.variableValues, botContext)
|
|
285
|
+
const pluginFlowBuilder = getFlowBuilderPlugin(botContext.plugins)
|
|
282
286
|
const resolvedLocale = pluginFlowBuilder.cmsApi.getResolvedLocale()
|
|
283
287
|
|
|
284
288
|
const header = this.getHeaderComponent(
|
|
285
289
|
this.htWhatsappTemplate,
|
|
286
290
|
this.headerVariables || ({} as HeaderVariables),
|
|
287
291
|
resolvedLocale,
|
|
288
|
-
|
|
292
|
+
botContext
|
|
289
293
|
)
|
|
290
294
|
const buttons = this.getButtons(
|
|
291
295
|
this.htWhatsappTemplate,
|
|
292
296
|
this.buttons || [],
|
|
293
297
|
this.urlVariableValues || {},
|
|
294
|
-
|
|
298
|
+
botContext
|
|
295
299
|
)
|
|
296
300
|
|
|
297
|
-
if (isWhatsapp(
|
|
301
|
+
if (isWhatsapp(botContext.session)) {
|
|
298
302
|
return (
|
|
299
303
|
<WhatsappTemplate
|
|
300
|
-
key={id}
|
|
304
|
+
key={this.id}
|
|
301
305
|
name={templateName}
|
|
302
306
|
language={templateLanguage}
|
|
303
307
|
header={header}
|
|
@@ -308,7 +312,7 @@ export class FlowWhatsappTemplate extends ContentFieldsBase {
|
|
|
308
312
|
}
|
|
309
313
|
|
|
310
314
|
return (
|
|
311
|
-
<Text key={id}>
|
|
315
|
+
<Text key={this.id}>
|
|
312
316
|
{`WhatsApp Template: ${templateName} (${templateLanguage})`}
|
|
313
317
|
{header && `${JSON.stringify(header, null, 2)}`}
|
|
314
318
|
{body && `${JSON.stringify(body, null, 2)}`}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WhatsappButtonListRowProps } from '@botonic/react'
|
|
2
2
|
|
|
3
3
|
import type { FlowBuilderApi } from '../../api'
|
|
4
4
|
import { SOURCE_INFO_SEPARATOR } from '../../constants'
|
|
@@ -29,12 +29,15 @@ export class FlowWhatsappButtonListRow extends ContentFieldsBase {
|
|
|
29
29
|
return newRow
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// Not apply for this content, because it is a child of the FlowWhatsappButtonList content
|
|
32
|
+
async trackFlow(): Promise<void> {
|
|
33
|
+
return
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
async processContent(): Promise<void> {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
renderRow(
|
|
38
41
|
rowIndex: number,
|
|
39
42
|
sectionIndex: number
|
|
40
43
|
): WhatsappButtonListRowProps | undefined {
|