@botonic/plugin-flow-builder 0.57.0-rslib-esm.1 → 0.58.0-alpha-new-stack.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/action/ai-agent-from-user-input.js +8 -0
- package/lib/action/ai-agent-from-user-input.js.map +1 -1
- package/lib/action/first-interaction.js +10 -0
- package/lib/action/first-interaction.js.map +1 -1
- package/lib/action/get-contents.js +5 -2
- package/lib/action/get-contents.js.map +1 -1
- package/lib/action/index.js +8 -1
- package/lib/action/index.js.map +1 -1
- package/lib/api.d.ts +8 -3
- package/lib/api.js +37 -13
- package/lib/api.js.map +1 -1
- package/lib/bot-context-manager.d.ts +17 -0
- package/lib/bot-context-manager.js +101 -0
- package/lib/bot-context-manager.js.map +1 -0
- package/lib/constants.d.ts +2 -1
- package/lib/constants.js +4 -3
- package/lib/constants.js.map +1 -1
- package/lib/content-fields/contact-reasons-conditional-matcher.d.ts +4 -0
- package/lib/content-fields/contact-reasons-conditional-matcher.js +10 -0
- package/lib/content-fields/contact-reasons-conditional-matcher.js.map +1 -0
- package/lib/content-fields/flow-ai-agent-base.js +7 -1
- package/lib/content-fields/flow-ai-agent-base.js.map +1 -1
- package/lib/content-fields/flow-ai-agent-router.js +2 -1
- package/lib/content-fields/flow-ai-agent-router.js.map +1 -1
- package/lib/content-fields/flow-ai-agent.js +2 -1
- package/lib/content-fields/flow-ai-agent.js.map +1 -1
- package/lib/content-fields/flow-contact-reasons-conditional.d.ts +14 -0
- package/lib/content-fields/flow-contact-reasons-conditional.js +68 -0
- package/lib/content-fields/flow-contact-reasons-conditional.js.map +1 -0
- package/lib/content-fields/flow-do-nothing.d.ts +9 -0
- package/lib/content-fields/flow-do-nothing.js +33 -0
- package/lib/content-fields/flow-do-nothing.js.map +1 -0
- package/lib/content-fields/flow-handoff.d.ts +7 -1
- package/lib/content-fields/flow-handoff.js +41 -3
- package/lib/content-fields/flow-handoff.js.map +1 -1
- package/lib/content-fields/flow-whatsapp-request-contact-info.d.ts +2 -1
- package/lib/content-fields/flow-whatsapp-request-contact-info.js +11 -0
- package/lib/content-fields/flow-whatsapp-request-contact-info.js.map +1 -1
- package/lib/content-fields/hubtype-fields/contact-reasons-conditional.d.ts +16 -0
- package/lib/content-fields/hubtype-fields/contact-reasons-conditional.js +4 -0
- package/lib/content-fields/hubtype-fields/contact-reasons-conditional.js.map +1 -0
- package/lib/content-fields/hubtype-fields/do-nothing.d.ts +6 -0
- package/lib/content-fields/hubtype-fields/do-nothing.js +4 -0
- package/lib/content-fields/hubtype-fields/do-nothing.js.map +1 -0
- package/lib/content-fields/hubtype-fields/handoff.d.ts +11 -1
- package/lib/content-fields/hubtype-fields/handoff.js +7 -1
- package/lib/content-fields/hubtype-fields/handoff.js.map +1 -1
- package/lib/content-fields/hubtype-fields/index.d.ts +1 -0
- package/lib/content-fields/hubtype-fields/index.js +2 -0
- package/lib/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/content-fields/hubtype-fields/node-types.d.ts +3 -1
- package/lib/content-fields/hubtype-fields/node-types.js +2 -0
- package/lib/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/content-fields/hubtype-fields/nodes.d.ts +3 -1
- package/lib/content-fields/hubtype-fields/nodes.js.map +1 -1
- package/lib/content-fields/hubtype-fields/whatsapp-request-contact-info.d.ts +2 -0
- package/lib/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +1 -1
- package/lib/content-fields/index.d.ts +4 -2
- package/lib/content-fields/index.js +6 -0
- package/lib/content-fields/index.js.map +1 -1
- package/lib/flow-factory.js +5 -1
- package/lib/flow-factory.js.map +1 -1
- package/lib/index.d.ts +5 -8
- package/lib/index.js +17 -55
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +2 -2
- package/lib/types.js.map +1 -1
- package/lib/utils/hubtype-assistant-content.d.ts +1 -0
- package/lib/utils/hubtype-assistant-content.js +13 -0
- package/lib/utils/hubtype-assistant-content.js.map +1 -1
- package/package.json +4 -4
- package/src/action/ai-agent-from-user-input.ts +7 -0
- package/src/action/first-interaction.ts +6 -0
- package/src/action/get-contents.ts +17 -2
- package/src/action/index.tsx +7 -0
- package/src/api.ts +52 -15
- package/src/bot-context-manager.ts +153 -0
- package/src/constants.ts +2 -1
- package/src/content-fields/contact-reasons-conditional-matcher.ts +24 -0
- package/src/content-fields/flow-ai-agent-base.tsx +12 -1
- package/src/content-fields/flow-ai-agent-router.tsx +1 -0
- package/src/content-fields/flow-ai-agent.tsx +1 -0
- package/src/content-fields/flow-contact-reasons-conditional.tsx +90 -0
- package/src/content-fields/flow-do-nothing.tsx +29 -0
- package/src/content-fields/flow-handoff.tsx +54 -7
- package/src/content-fields/flow-whatsapp-request-contact-info.tsx +19 -1
- package/src/content-fields/hubtype-fields/contact-reasons-conditional.ts +18 -0
- package/src/content-fields/hubtype-fields/do-nothing.ts +7 -0
- package/src/content-fields/hubtype-fields/handoff.ts +17 -1
- package/src/content-fields/hubtype-fields/index.ts +1 -0
- package/src/content-fields/hubtype-fields/node-types.ts +2 -0
- package/src/content-fields/hubtype-fields/nodes.ts +4 -0
- package/src/content-fields/hubtype-fields/whatsapp-request-contact-info.ts +2 -0
- package/src/content-fields/index.ts +6 -0
- package/src/flow-factory.ts +11 -0
- package/src/index.ts +26 -88
- package/src/types.ts +1 -2
- package/src/utils/hubtype-assistant-content.ts +14 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type { HtBaseNode, HtPayloadLocale, HtQueueLocale } from './common.js';
|
|
1
|
+
import type { HtBaseNode, HtNodeLink, HtPayloadLocale, HtQueueLocale } from './common.js';
|
|
2
2
|
import type { HtNodeWithContentType } from './node-types.js';
|
|
3
|
+
export declare enum DiscardType {
|
|
4
|
+
ByAgent = "discarded",
|
|
5
|
+
ByUser = "discarded_by_user",
|
|
6
|
+
BySystem = "discarded_by_system"
|
|
7
|
+
}
|
|
3
8
|
export interface HtHandoffNode extends HtBaseNode {
|
|
4
9
|
type: HtNodeWithContentType.HANDOFF;
|
|
5
10
|
content: {
|
|
@@ -7,5 +12,10 @@ export interface HtHandoffNode extends HtBaseNode {
|
|
|
7
12
|
payload: HtPayloadLocale[];
|
|
8
13
|
has_auto_assign: boolean;
|
|
9
14
|
has_queue_position_changed_notifications_enabled: boolean;
|
|
15
|
+
has_differentiated_close_types: boolean;
|
|
16
|
+
resolved_by_agent?: HtNodeLink;
|
|
17
|
+
discarded_by_agent?: HtNodeLink;
|
|
18
|
+
discarded_by_user?: HtNodeLink;
|
|
19
|
+
discarded_by_system?: HtNodeLink;
|
|
10
20
|
};
|
|
11
21
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
var handoff_DiscardType = /*#__PURE__*/ function(DiscardType) {
|
|
2
|
+
DiscardType["ByAgent"] = "discarded";
|
|
3
|
+
DiscardType["ByUser"] = "discarded_by_user";
|
|
4
|
+
DiscardType["BySystem"] = "discarded_by_system";
|
|
5
|
+
return DiscardType;
|
|
6
|
+
}({});
|
|
1
7
|
|
|
2
|
-
|
|
8
|
+
export { handoff_DiscardType as DiscardType };
|
|
3
9
|
|
|
4
10
|
//# sourceMappingURL=handoff.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fields/hubtype-fields/handoff.js","sources":["../../../src/content-fields/hubtype-fields/handoff.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"content-fields/hubtype-fields/handoff.js","sources":["../../../src/content-fields/hubtype-fields/handoff.ts"],"sourcesContent":["import type {\n HtBaseNode,\n HtNodeLink,\n HtPayloadLocale,\n HtQueueLocale,\n} from './common'\nimport type { HtNodeWithContentType } from './node-types'\n\nexport enum DiscardType {\n ByAgent = 'discarded',\n ByUser = 'discarded_by_user',\n BySystem = 'discarded_by_system',\n}\n\nexport interface HtHandoffNode extends HtBaseNode {\n type: HtNodeWithContentType.HANDOFF\n content: {\n queue: HtQueueLocale[]\n payload: HtPayloadLocale[]\n has_auto_assign: boolean\n has_queue_position_changed_notifications_enabled: boolean\n has_differentiated_close_types: boolean\n resolved_by_agent?: HtNodeLink\n discarded_by_agent?: HtNodeLink\n discarded_by_user?: HtNodeLink\n discarded_by_system?: HtNodeLink\n }\n}\n"],"names":["DiscardType"],"mappings":"AAQO,IAAKA,mBAAWA,0BAAXA;;;;WAAAA;MAIX"}
|
|
@@ -6,6 +6,7 @@ export * from './capture-user-input.js';
|
|
|
6
6
|
export * from './carousel.js';
|
|
7
7
|
export * from './common.js';
|
|
8
8
|
export * from './custom-conditional-v2.js';
|
|
9
|
+
export * from './do-nothing.js';
|
|
9
10
|
export * from './fallback.js';
|
|
10
11
|
export * from './function.js';
|
|
11
12
|
export * from './go-to-flow.js';
|
|
@@ -6,6 +6,7 @@ export * from "./capture-user-input.js";
|
|
|
6
6
|
export * from "./carousel.js";
|
|
7
7
|
export * from "./common.js";
|
|
8
8
|
export * from "./custom-conditional-v2.js";
|
|
9
|
+
export * from "./do-nothing.js";
|
|
9
10
|
export * from "./fallback.js";
|
|
10
11
|
export * from "./function.js";
|
|
11
12
|
export * from "./go-to-flow.js";
|
|
@@ -52,6 +53,7 @@ export * from "./whatsapp-template.js";
|
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
|
|
56
|
+
|
|
55
57
|
|
|
56
58
|
|
|
57
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fields/hubtype-fields/index.js","sources":["../../../src/content-fields/hubtype-fields/index.ts"],"sourcesContent":["export * from './ai-agent'\nexport * from './ai-agent-router'\nexport * from './bot-action'\nexport * from './button'\nexport * from './capture-user-input'\nexport * from './carousel'\nexport * from './common'\nexport * from './custom-conditional-v2'\nexport * from './fallback'\nexport * from './function'\nexport * from './go-to-flow'\nexport * from './handoff'\nexport * from './image'\nexport * from './keyword'\nexport * from './node-types'\nexport * from './nodes'\nexport * from './payload'\nexport * from './rating'\nexport * from './smart-intent'\nexport * from './text'\nexport * from './url'\nexport * from './video'\nexport * from './webview'\nexport * from './whatsapp-button-list'\nexport * from './whatsapp-cta-url-button'\nexport * from './whatsapp-request-contact-info'\nexport * from './whatsapp-template'\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content-fields/hubtype-fields/index.js","sources":["../../../src/content-fields/hubtype-fields/index.ts"],"sourcesContent":["export * from './ai-agent'\nexport * from './ai-agent-router'\nexport * from './bot-action'\nexport * from './button'\nexport * from './capture-user-input'\nexport * from './carousel'\nexport * from './common'\nexport * from './custom-conditional-v2'\nexport * from './do-nothing'\nexport * from './fallback'\nexport * from './function'\nexport * from './go-to-flow'\nexport * from './handoff'\nexport * from './image'\nexport * from './keyword'\nexport * from './node-types'\nexport * from './nodes'\nexport * from './payload'\nexport * from './rating'\nexport * from './smart-intent'\nexport * from './text'\nexport * from './url'\nexport * from './video'\nexport * from './webview'\nexport * from './whatsapp-button-list'\nexport * from './whatsapp-cta-url-button'\nexport * from './whatsapp-request-contact-info'\nexport * from './whatsapp-template'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA0B;AACO;AACL;AACJ;AACY;AACV;AACF;AACe;AACX;AACF;AACA;AACE;AACH;AACF;AACE;AACG;AACL;AACE;AACD;AACM;AACR;AACD;AACE;AACE;AACa;AACG;AACM;AACZ"}
|
|
@@ -19,7 +19,9 @@ export declare enum HtNodeWithContentType {
|
|
|
19
19
|
WEBVIEW = "webview",
|
|
20
20
|
GO_TO_FLOW = "go-to-flow",
|
|
21
21
|
CAPTURE_USER_INPUT = "capture-user-input",
|
|
22
|
-
CUSTOM_CONDITION = "custom-condition"
|
|
22
|
+
CUSTOM_CONDITION = "custom-condition",
|
|
23
|
+
DO_NOTHING = "do-nothing",
|
|
24
|
+
CONTACT_REASONS_CONDITION = "contact-reasons-condition"
|
|
23
25
|
}
|
|
24
26
|
export declare enum HtNodeWithoutContentType {
|
|
25
27
|
URL = "url",
|
|
@@ -20,6 +20,8 @@ var node_types_HtNodeWithContentType = /*#__PURE__*/ function(HtNodeWithContentT
|
|
|
20
20
|
HtNodeWithContentType["GO_TO_FLOW"] = "go-to-flow";
|
|
21
21
|
HtNodeWithContentType["CAPTURE_USER_INPUT"] = "capture-user-input";
|
|
22
22
|
HtNodeWithContentType["CUSTOM_CONDITION"] = "custom-condition";
|
|
23
|
+
HtNodeWithContentType["DO_NOTHING"] = "do-nothing";
|
|
24
|
+
HtNodeWithContentType["CONTACT_REASONS_CONDITION"] = "contact-reasons-condition";
|
|
23
25
|
return HtNodeWithContentType;
|
|
24
26
|
}({});
|
|
25
27
|
var node_types_HtNodeWithoutContentType = /*#__PURE__*/ function(HtNodeWithoutContentType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fields/hubtype-fields/node-types.js","sources":["../../../src/content-fields/hubtype-fields/node-types.ts"],"sourcesContent":["export enum HtNodeWithContentType {\n CAROUSEL = 'carousel',\n HANDOFF = 'handoff',\n IMAGE = 'image',\n TEXT = 'text',\n KEYWORD = 'keyword',\n SMART_INTENT = 'smart-intent',\n FUNCTION = 'function',\n FALLBACK = 'fallback',\n VIDEO = 'video',\n WHATSAPP_BUTTON_LIST = 'whatsapp-button-list',\n WHATSAPP_CTA_URL_BUTTON = 'whatsapp-cta-url-button',\n WHATSAPP_REQUEST_CONTACT_INFO = 'whatsapp-request-contact-info',\n WHATSAPP_TEMPLATE = 'whatsapp-template',\n BOT_ACTION = 'bot-action',\n AI_AGENT = 'ai-agent',\n AI_AGENT_ROUTER = 'ai-agent-router',\n RATING = 'rating',\n WEBVIEW = 'webview',\n GO_TO_FLOW = 'go-to-flow',\n CAPTURE_USER_INPUT = 'capture-user-input',\n CUSTOM_CONDITION = 'custom-condition',\n}\n\nexport enum HtNodeWithoutContentType {\n URL = 'url',\n PAYLOAD = 'payload',\n}\n\nexport enum HtButtonStyle {\n BUTTON = 'button',\n QUICK_REPLY = 'quick-reply',\n}\n"],"names":["HtNodeWithContentType","HtNodeWithoutContentType","HtButtonStyle"],"mappings":"AAAO,IAAKA,gCAAqBA,0BAArBA
|
|
1
|
+
{"version":3,"file":"content-fields/hubtype-fields/node-types.js","sources":["../../../src/content-fields/hubtype-fields/node-types.ts"],"sourcesContent":["export enum HtNodeWithContentType {\n CAROUSEL = 'carousel',\n HANDOFF = 'handoff',\n IMAGE = 'image',\n TEXT = 'text',\n KEYWORD = 'keyword',\n SMART_INTENT = 'smart-intent',\n FUNCTION = 'function',\n FALLBACK = 'fallback',\n VIDEO = 'video',\n WHATSAPP_BUTTON_LIST = 'whatsapp-button-list',\n WHATSAPP_CTA_URL_BUTTON = 'whatsapp-cta-url-button',\n WHATSAPP_REQUEST_CONTACT_INFO = 'whatsapp-request-contact-info',\n WHATSAPP_TEMPLATE = 'whatsapp-template',\n BOT_ACTION = 'bot-action',\n AI_AGENT = 'ai-agent',\n AI_AGENT_ROUTER = 'ai-agent-router',\n RATING = 'rating',\n WEBVIEW = 'webview',\n GO_TO_FLOW = 'go-to-flow',\n CAPTURE_USER_INPUT = 'capture-user-input',\n CUSTOM_CONDITION = 'custom-condition',\n DO_NOTHING = 'do-nothing',\n CONTACT_REASONS_CONDITION = 'contact-reasons-condition',\n}\n\nexport enum HtNodeWithoutContentType {\n URL = 'url',\n PAYLOAD = 'payload',\n}\n\nexport enum HtButtonStyle {\n BUTTON = 'button',\n QUICK_REPLY = 'quick-reply',\n}\n"],"names":["HtNodeWithContentType","HtNodeWithoutContentType","HtButtonStyle"],"mappings":"AAAO,IAAKA,gCAAqBA,0BAArBA;;;;;;;;;;;;;;;;;;;;;;;;WAAAA;MAwBX;AAEM,IAAKC,mCAAwBA,0BAAxBA;;;WAAAA;MAGX;AAEM,IAAKC,wBAAaA,0BAAbA;;;WAAAA;MAGX"}
|
|
@@ -3,7 +3,9 @@ import type { HtAiAgentRouterNode } from './ai-agent-router.js';
|
|
|
3
3
|
import type { HtBotActionNode } from './bot-action.js';
|
|
4
4
|
import type { HtCaptureUserInputNode } from './capture-user-input.js';
|
|
5
5
|
import type { HtCarouselNode } from './carousel.js';
|
|
6
|
+
import type { HtContactReasonsNode } from './contact-reasons-conditional.js';
|
|
6
7
|
import type { HtCustomConditionalV2Node } from './custom-conditional-v2.js';
|
|
8
|
+
import type { HtDoNothingNode } from './do-nothing.js';
|
|
7
9
|
import type { HtFallbackNode } from './fallback.js';
|
|
8
10
|
import type { HtFunctionNode } from './function.js';
|
|
9
11
|
import type { HtGoToFlow } from './go-to-flow.js';
|
|
@@ -21,6 +23,6 @@ import type { HtWhatsappButtonListNode } from './whatsapp-button-list.js';
|
|
|
21
23
|
import type { HtWhatsappCTAUrlButtonNode } from './whatsapp-cta-url-button.js';
|
|
22
24
|
import type { HtWhatsappRequestContactInfoNode } from './whatsapp-request-contact-info.js';
|
|
23
25
|
import type { HtWhatsappTemplateNode } from './whatsapp-template.js';
|
|
24
|
-
export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode | HtFunctionNode | HtFallbackNode | HtWhatsappButtonListNode | HtWhatsappCTAUrlButtonNode | HtWhatsappRequestContactInfoNode | HtSmartIntentNode | HtBotActionNode | HtAiAgentNode | HtAiAgentRouterNode | HtRatingNode | HtWebviewNode | HtGoToFlow | HtWhatsappTemplateNode | HtCaptureUserInputNode | HtCustomConditionalV2Node;
|
|
26
|
+
export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode | HtFunctionNode | HtFallbackNode | HtWhatsappButtonListNode | HtWhatsappCTAUrlButtonNode | HtWhatsappRequestContactInfoNode | HtSmartIntentNode | HtBotActionNode | HtAiAgentNode | HtAiAgentRouterNode | HtRatingNode | HtWebviewNode | HtGoToFlow | HtWhatsappTemplateNode | HtCaptureUserInputNode | HtCustomConditionalV2Node | HtDoNothingNode | HtContactReasonsNode;
|
|
25
27
|
export type HtNodeWithoutContent = HtUrlNode | HtPayloadNode;
|
|
26
28
|
export type HtNodeComponent = HtNodeWithContent | HtNodeWithoutContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fields/hubtype-fields/nodes.js","sources":["../../../src/content-fields/hubtype-fields/nodes.ts"],"sourcesContent":["import type { HtAiAgentNode } from './ai-agent'\nimport type { HtAiAgentRouterNode } from './ai-agent-router'\nimport type { HtBotActionNode } from './bot-action'\nimport type { HtCaptureUserInputNode } from './capture-user-input'\nimport type { HtCarouselNode } from './carousel'\nimport type { HtCustomConditionalV2Node } from './custom-conditional-v2'\n// import { HtChannelConditionalNode } from './channel-conditional'\n// import { HtCountryConditionalNode } from './country-conditional'\n// import { HtCustomConditionalNode } from './custom-conditional'\nimport type { HtFallbackNode } from './fallback'\nimport type { HtFunctionNode } from './function'\nimport type { HtGoToFlow } from './go-to-flow'\nimport type { HtHandoffNode } from './handoff'\nimport type { HtImageNode } from './image'\nimport type { HtKeywordNode } from './keyword'\nimport type { HtPayloadNode } from './payload'\n// import { HtQueueStatusConditionalNode } from './queue-status-conditional'\nimport type { HtRatingNode } from './rating'\nimport type { HtSmartIntentNode } from './smart-intent'\nimport type { HtTextNode } from './text'\nimport type { HtUrlNode } from './url'\nimport type { HtVideoNode } from './video'\nimport type { HtWebviewNode } from './webview'\nimport type { HtWhatsappButtonListNode } from './whatsapp-button-list'\nimport type { HtWhatsappCTAUrlButtonNode } from './whatsapp-cta-url-button'\nimport type { HtWhatsappRequestContactInfoNode } from './whatsapp-request-contact-info'\nimport type { HtWhatsappTemplateNode } from './whatsapp-template'\n\nexport type HtNodeWithContent =\n | HtTextNode\n | HtImageNode\n | HtVideoNode\n | HtCarouselNode\n | HtHandoffNode\n | HtKeywordNode\n | HtFunctionNode\n | HtFallbackNode\n | HtWhatsappButtonListNode\n | HtWhatsappCTAUrlButtonNode\n | HtWhatsappRequestContactInfoNode\n | HtSmartIntentNode\n | HtBotActionNode\n | HtAiAgentNode\n | HtAiAgentRouterNode\n | HtRatingNode\n | HtWebviewNode\n | HtGoToFlow\n | HtWhatsappTemplateNode\n | HtCaptureUserInputNode\n | HtCustomConditionalV2Node\n// | HtChannelConditionalNode\n// | HtCountryConditionalNode\n// | HtCustomConditionalNode\n// | HtQueueStatusConditionalNode\n\nexport type HtNodeWithoutContent = HtUrlNode | HtPayloadNode\n\nexport type HtNodeComponent = HtNodeWithContent | HtNodeWithoutContent\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content-fields/hubtype-fields/nodes.js","sources":["../../../src/content-fields/hubtype-fields/nodes.ts"],"sourcesContent":["import type { HtAiAgentNode } from './ai-agent'\nimport type { HtAiAgentRouterNode } from './ai-agent-router'\nimport type { HtBotActionNode } from './bot-action'\nimport type { HtCaptureUserInputNode } from './capture-user-input'\nimport type { HtCarouselNode } from './carousel'\nimport type { HtContactReasonsNode } from './contact-reasons-conditional'\nimport type { HtCustomConditionalV2Node } from './custom-conditional-v2'\nimport type { HtDoNothingNode } from './do-nothing'\n// import { HtChannelConditionalNode } from './channel-conditional'\n// import { HtCountryConditionalNode } from './country-conditional'\n// import { HtCustomConditionalNode } from './custom-conditional'\nimport type { HtFallbackNode } from './fallback'\nimport type { HtFunctionNode } from './function'\nimport type { HtGoToFlow } from './go-to-flow'\nimport type { HtHandoffNode } from './handoff'\nimport type { HtImageNode } from './image'\nimport type { HtKeywordNode } from './keyword'\nimport type { HtPayloadNode } from './payload'\n// import { HtQueueStatusConditionalNode } from './queue-status-conditional'\nimport type { HtRatingNode } from './rating'\nimport type { HtSmartIntentNode } from './smart-intent'\nimport type { HtTextNode } from './text'\nimport type { HtUrlNode } from './url'\nimport type { HtVideoNode } from './video'\nimport type { HtWebviewNode } from './webview'\nimport type { HtWhatsappButtonListNode } from './whatsapp-button-list'\nimport type { HtWhatsappCTAUrlButtonNode } from './whatsapp-cta-url-button'\nimport type { HtWhatsappRequestContactInfoNode } from './whatsapp-request-contact-info'\nimport type { HtWhatsappTemplateNode } from './whatsapp-template'\n\nexport type HtNodeWithContent =\n | HtTextNode\n | HtImageNode\n | HtVideoNode\n | HtCarouselNode\n | HtHandoffNode\n | HtKeywordNode\n | HtFunctionNode\n | HtFallbackNode\n | HtWhatsappButtonListNode\n | HtWhatsappCTAUrlButtonNode\n | HtWhatsappRequestContactInfoNode\n | HtSmartIntentNode\n | HtBotActionNode\n | HtAiAgentNode\n | HtAiAgentRouterNode\n | HtRatingNode\n | HtWebviewNode\n | HtGoToFlow\n | HtWhatsappTemplateNode\n | HtCaptureUserInputNode\n | HtCustomConditionalV2Node\n | HtDoNothingNode\n | HtContactReasonsNode\n// | HtChannelConditionalNode\n// | HtCountryConditionalNode\n// | HtCustomConditionalNode\n// | HtQueueStatusConditionalNode\n\nexport type HtNodeWithoutContent = HtUrlNode | HtPayloadNode\n\nexport type HtNodeComponent = HtNodeWithContent | HtNodeWithoutContent\n"],"names":[],"mappings":"AA6DsE"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { HtButton } from './button.js';
|
|
1
2
|
import type { HtBaseNode, HtTextLocale } from './common.js';
|
|
2
3
|
import type { HtNodeWithContentType } from './node-types.js';
|
|
3
4
|
export interface HtWhatsappRequestContactInfoNode extends HtBaseNode {
|
|
4
5
|
type: HtNodeWithContentType.WHATSAPP_REQUEST_CONTACT_INFO;
|
|
5
6
|
content: {
|
|
6
7
|
text: HtTextLocale[];
|
|
8
|
+
button: HtButton;
|
|
7
9
|
};
|
|
8
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fields/hubtype-fields/whatsapp-request-contact-info.js","sources":["../../../src/content-fields/hubtype-fields/whatsapp-request-contact-info.ts"],"sourcesContent":["import type { HtBaseNode, HtTextLocale } from './common'\nimport type { HtNodeWithContentType } from './node-types'\n\nexport interface HtWhatsappRequestContactInfoNode extends HtBaseNode {\n type: HtNodeWithContentType.WHATSAPP_REQUEST_CONTACT_INFO\n content: {\n text: HtTextLocale[]\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content-fields/hubtype-fields/whatsapp-request-contact-info.js","sources":["../../../src/content-fields/hubtype-fields/whatsapp-request-contact-info.ts"],"sourcesContent":["import type { HtButton } from './button'\nimport type { HtBaseNode, HtTextLocale } from './common'\nimport type { HtNodeWithContentType } from './node-types'\n\nexport interface HtWhatsappRequestContactInfoNode extends HtBaseNode {\n type: HtNodeWithContentType.WHATSAPP_REQUEST_CONTACT_INFO\n content: {\n text: HtTextLocale[]\n button: HtButton\n }\n}\n"],"names":[],"mappings":"AAUC"}
|
|
@@ -5,8 +5,10 @@ import { FlowBotAction } from './flow-bot-action.js';
|
|
|
5
5
|
import { FlowCaptureUserInput } from './flow-capture-user-input.js';
|
|
6
6
|
import { FlowCarousel } from './flow-carousel.js';
|
|
7
7
|
import { FlowChannelConditional } from './flow-channel-conditional.js';
|
|
8
|
+
import { FlowContactReasonsConditional } from './flow-contact-reasons-conditional.js';
|
|
8
9
|
import { FlowCountryConditional } from './flow-country-conditional.js';
|
|
9
10
|
import { FlowCustomConditional } from './flow-custom-conditional.js';
|
|
11
|
+
import { FlowDoNothing } from './flow-do-nothing.js';
|
|
10
12
|
import { FlowGoToFlow } from './flow-go-to-flow.js';
|
|
11
13
|
import { FlowHandoff } from './flow-handoff.js';
|
|
12
14
|
import { FlowImage } from './flow-image.js';
|
|
@@ -21,5 +23,5 @@ import { FlowWhatsappButtonList, FlowWhatsappButtonListRow, FlowWhatsappButtonLi
|
|
|
21
23
|
export { ContentFieldsBase } from './content-fields-base.js';
|
|
22
24
|
export { FlowButton } from './flow-button.js';
|
|
23
25
|
export { FlowElement } from './flow-element.js';
|
|
24
|
-
export { FlowAiAgent, FlowAiAgentRouter, FlowBotAction, FlowCaptureUserInput, FlowCarousel, FlowChannelConditional, FlowCountryConditional, FlowCustomConditional, FlowCustomConditionalV2, FlowGoToFlow, FlowHandoff, FlowImage, FlowQueueStatusConditional, FlowRating, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappButtonListRow, FlowWhatsappButtonListSection, FlowWhatsappCtaUrlButtonNode, FlowWhatsappRequestContactInfoNode, FlowWhatsappTemplate, };
|
|
25
|
-
export type FlowContent = FlowCarousel | FlowImage | FlowText | FlowVideo | FlowWhatsappButtonList | FlowWhatsappCtaUrlButtonNode | FlowWhatsappRequestContactInfoNode | FlowWhatsappTemplate | FlowHandoff | FlowBotAction | FlowAiAgent | FlowRating | FlowCountryConditional | FlowChannelConditional | FlowQueueStatusConditional | FlowCustomConditional | FlowGoToFlow | FlowCaptureUserInput | FlowAiAgentRouter | FlowCustomConditionalV2;
|
|
26
|
+
export { FlowAiAgent, FlowAiAgentRouter, FlowBotAction, FlowCaptureUserInput, FlowCarousel, FlowChannelConditional, FlowContactReasonsConditional, FlowCountryConditional, FlowCustomConditional, FlowCustomConditionalV2, FlowDoNothing, FlowGoToFlow, FlowHandoff, FlowImage, FlowQueueStatusConditional, FlowRating, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappButtonListRow, FlowWhatsappButtonListSection, FlowWhatsappCtaUrlButtonNode, FlowWhatsappRequestContactInfoNode, FlowWhatsappTemplate, };
|
|
27
|
+
export type FlowContent = FlowCarousel | FlowImage | FlowText | FlowVideo | FlowWhatsappButtonList | FlowWhatsappCtaUrlButtonNode | FlowWhatsappRequestContactInfoNode | FlowWhatsappTemplate | FlowHandoff | FlowBotAction | FlowAiAgent | FlowRating | FlowCountryConditional | FlowChannelConditional | FlowQueueStatusConditional | FlowCustomConditional | FlowGoToFlow | FlowCaptureUserInput | FlowAiAgentRouter | FlowCustomConditionalV2 | FlowDoNothing | FlowContactReasonsConditional;
|
|
@@ -41,6 +41,10 @@
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
44
48
|
|
|
45
49
|
|
|
46
50
|
|
|
@@ -53,8 +57,10 @@ export { FlowBotAction } from "./flow-bot-action.js";
|
|
|
53
57
|
export { FlowCaptureUserInput } from "./flow-capture-user-input.js";
|
|
54
58
|
export { FlowCarousel } from "./flow-carousel.js";
|
|
55
59
|
export { FlowChannelConditional } from "./flow-channel-conditional.js";
|
|
60
|
+
export { FlowContactReasonsConditional } from "./flow-contact-reasons-conditional.js";
|
|
56
61
|
export { FlowCountryConditional } from "./flow-country-conditional.js";
|
|
57
62
|
export { FlowCustomConditional } from "./flow-custom-conditional.js";
|
|
63
|
+
export { FlowDoNothing } from "./flow-do-nothing.js";
|
|
58
64
|
export { FlowGoToFlow } from "./flow-go-to-flow.js";
|
|
59
65
|
export { FlowHandoff } from "./flow-handoff.js";
|
|
60
66
|
export { FlowImage } from "./flow-image.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-fields/index.js","sources":["../../src/content-fields/index.ts"],"sourcesContent":["import { FlowCustomConditionalV2 } from './custom-conditional/flow-custom-condition-v2'\nimport { FlowAiAgent } from './flow-ai-agent'\nimport { FlowAiAgentRouter } from './flow-ai-agent-router'\nimport { FlowBotAction } from './flow-bot-action'\nimport { FlowCaptureUserInput } from './flow-capture-user-input'\nimport { FlowCarousel } from './flow-carousel'\nimport { FlowChannelConditional } from './flow-channel-conditional'\nimport { FlowCountryConditional } from './flow-country-conditional'\nimport { FlowCustomConditional } from './flow-custom-conditional'\nimport { FlowGoToFlow } from './flow-go-to-flow'\nimport { FlowHandoff } from './flow-handoff'\nimport { FlowImage } from './flow-image'\nimport { FlowQueueStatusConditional } from './flow-queue-status-conditional'\nimport { FlowRating } from './flow-rating'\nimport { FlowText } from './flow-text'\nimport { FlowVideo } from './flow-video'\nimport { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button'\nimport { FlowWhatsappRequestContactInfoNode } from './flow-whatsapp-request-contact-info'\nimport { FlowWhatsappTemplate } from './flow-whatsapp-template'\nimport {\n FlowWhatsappButtonList,\n FlowWhatsappButtonListRow,\n FlowWhatsappButtonListSection,\n} from './whatsapp-button-list'\n\nexport { ContentFieldsBase } from './content-fields-base'\nexport { FlowButton } from './flow-button'\nexport { FlowElement } from './flow-element'\nexport {\n FlowAiAgent,\n FlowAiAgentRouter,\n FlowBotAction,\n FlowCaptureUserInput,\n FlowCarousel,\n FlowChannelConditional,\n FlowCountryConditional,\n FlowCustomConditional,\n FlowCustomConditionalV2,\n FlowGoToFlow,\n FlowHandoff,\n FlowImage,\n FlowQueueStatusConditional,\n FlowRating,\n FlowText,\n FlowVideo,\n FlowWhatsappButtonList,\n FlowWhatsappButtonListRow,\n FlowWhatsappButtonListSection,\n FlowWhatsappCtaUrlButtonNode,\n FlowWhatsappRequestContactInfoNode,\n FlowWhatsappTemplate,\n}\n\nexport type FlowContent =\n | FlowCarousel\n | FlowImage\n | FlowText\n | FlowVideo\n | FlowWhatsappButtonList\n | FlowWhatsappCtaUrlButtonNode\n | FlowWhatsappRequestContactInfoNode\n | FlowWhatsappTemplate\n | FlowHandoff\n | FlowBotAction\n | FlowAiAgent\n | FlowRating\n | FlowCountryConditional\n | FlowChannelConditional\n | FlowQueueStatusConditional\n | FlowCustomConditional\n | FlowGoToFlow\n | FlowCaptureUserInput\n | FlowAiAgentRouter\n | FlowCustomConditionalV2\n"],"names":["FlowCustomConditionalV2","FlowAiAgent","FlowAiAgentRouter","FlowBotAction","FlowCaptureUserInput","FlowCarousel","FlowChannelConditional","FlowCountryConditional","FlowCustomConditional","FlowGoToFlow","FlowHandoff","FlowImage","FlowQueueStatusConditional","FlowRating","FlowText","FlowVideo","FlowWhatsappCtaUrlButtonNode","FlowWhatsappRequestContactInfoNode","FlowWhatsappTemplate","FlowWhatsappButtonList","FlowWhatsappButtonListRow","FlowWhatsappButtonListSection","ContentFieldsBase","FlowButton","FlowElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"content-fields/index.js","sources":["../../src/content-fields/index.ts"],"sourcesContent":["import { FlowCustomConditionalV2 } from './custom-conditional/flow-custom-condition-v2'\nimport { FlowAiAgent } from './flow-ai-agent'\nimport { FlowAiAgentRouter } from './flow-ai-agent-router'\nimport { FlowBotAction } from './flow-bot-action'\nimport { FlowCaptureUserInput } from './flow-capture-user-input'\nimport { FlowCarousel } from './flow-carousel'\nimport { FlowChannelConditional } from './flow-channel-conditional'\nimport { FlowContactReasonsConditional } from './flow-contact-reasons-conditional'\nimport { FlowCountryConditional } from './flow-country-conditional'\nimport { FlowCustomConditional } from './flow-custom-conditional'\nimport { FlowDoNothing } from './flow-do-nothing'\nimport { FlowGoToFlow } from './flow-go-to-flow'\nimport { FlowHandoff } from './flow-handoff'\nimport { FlowImage } from './flow-image'\nimport { FlowQueueStatusConditional } from './flow-queue-status-conditional'\nimport { FlowRating } from './flow-rating'\nimport { FlowText } from './flow-text'\nimport { FlowVideo } from './flow-video'\nimport { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button'\nimport { FlowWhatsappRequestContactInfoNode } from './flow-whatsapp-request-contact-info'\nimport { FlowWhatsappTemplate } from './flow-whatsapp-template'\nimport {\n FlowWhatsappButtonList,\n FlowWhatsappButtonListRow,\n FlowWhatsappButtonListSection,\n} from './whatsapp-button-list'\n\nexport { ContentFieldsBase } from './content-fields-base'\nexport { FlowButton } from './flow-button'\nexport { FlowElement } from './flow-element'\nexport {\n FlowAiAgent,\n FlowAiAgentRouter,\n FlowBotAction,\n FlowCaptureUserInput,\n FlowCarousel,\n FlowChannelConditional,\n FlowContactReasonsConditional,\n FlowCountryConditional,\n FlowCustomConditional,\n FlowCustomConditionalV2,\n FlowDoNothing,\n FlowGoToFlow,\n FlowHandoff,\n FlowImage,\n FlowQueueStatusConditional,\n FlowRating,\n FlowText,\n FlowVideo,\n FlowWhatsappButtonList,\n FlowWhatsappButtonListRow,\n FlowWhatsappButtonListSection,\n FlowWhatsappCtaUrlButtonNode,\n FlowWhatsappRequestContactInfoNode,\n FlowWhatsappTemplate,\n}\n\nexport type FlowContent =\n | FlowCarousel\n | FlowImage\n | FlowText\n | FlowVideo\n | FlowWhatsappButtonList\n | FlowWhatsappCtaUrlButtonNode\n | FlowWhatsappRequestContactInfoNode\n | FlowWhatsappTemplate\n | FlowHandoff\n | FlowBotAction\n | FlowAiAgent\n | FlowRating\n | FlowCountryConditional\n | FlowChannelConditional\n | FlowQueueStatusConditional\n | FlowCustomConditional\n | FlowGoToFlow\n | FlowCaptureUserInput\n | FlowAiAgentRouter\n | FlowCustomConditionalV2\n | FlowDoNothing\n | FlowContactReasonsConditional\n"],"names":["FlowCustomConditionalV2","FlowAiAgent","FlowAiAgentRouter","FlowBotAction","FlowCaptureUserInput","FlowCarousel","FlowChannelConditional","FlowContactReasonsConditional","FlowCountryConditional","FlowCustomConditional","FlowDoNothing","FlowGoToFlow","FlowHandoff","FlowImage","FlowQueueStatusConditional","FlowRating","FlowText","FlowVideo","FlowWhatsappCtaUrlButtonNode","FlowWhatsappRequestContactInfoNode","FlowWhatsappTemplate","FlowWhatsappButtonList","FlowWhatsappButtonListRow","FlowWhatsappButtonListSection","ContentFieldsBase","FlowButton","FlowElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAuF;AAC1C;AACa;AACT;AACe;AAClB;AACqB;AACe;AACf;AACF;AAChB;AACD;AACJ;AACJ;AACoC;AAClC;AACJ;AACE;AACqC;AACY;AAC1B;AAKhC;AAE0B;AACf;AACE;AA0B3C"}
|
package/lib/flow-factory.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlowAiAgent, FlowAiAgentRouter, FlowBotAction, FlowCarousel, FlowChannelConditional, FlowCountryConditional, FlowCustomConditional, FlowCustomConditionalV2, FlowGoToFlow, FlowHandoff, FlowImage, FlowQueueStatusConditional, FlowRating, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, FlowWhatsappRequestContactInfoNode, FlowWhatsappTemplate } from "./content-fields/index.js";
|
|
1
|
+
import { FlowAiAgent, FlowAiAgentRouter, FlowBotAction, FlowCarousel, FlowChannelConditional, FlowContactReasonsConditional, FlowCountryConditional, FlowCustomConditional, FlowCustomConditionalV2, FlowDoNothing, FlowGoToFlow, FlowHandoff, FlowImage, FlowQueueStatusConditional, FlowRating, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, FlowWhatsappRequestContactInfoNode, FlowWhatsappTemplate } from "./content-fields/index.js";
|
|
2
2
|
import { FlowCaptureUserInput } from "./content-fields/flow-capture-user-input.js";
|
|
3
3
|
import { HtNodeWithContentType } from "./content-fields/hubtype-fields/index.js";
|
|
4
4
|
|
|
@@ -45,6 +45,10 @@ class FlowFactory {
|
|
|
45
45
|
return FlowCaptureUserInput.fromHubtypeCMS(hubtypeContent);
|
|
46
46
|
case HtNodeWithContentType.CUSTOM_CONDITION:
|
|
47
47
|
return FlowCustomConditionalV2.fromHubtypeCMS(hubtypeContent, this.botContext);
|
|
48
|
+
case HtNodeWithContentType.DO_NOTHING:
|
|
49
|
+
return FlowDoNothing.fromHubtypeCMS(hubtypeContent);
|
|
50
|
+
case HtNodeWithContentType.CONTACT_REASONS_CONDITION:
|
|
51
|
+
return FlowContactReasonsConditional.fromHubtypeCMS(hubtypeContent, this.botContext);
|
|
48
52
|
default:
|
|
49
53
|
return undefined;
|
|
50
54
|
}
|
package/lib/flow-factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-factory.js","sources":["../src/flow-factory.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\n\nimport type { FlowBuilderApi } from './api'\nimport {\n FlowAiAgent,\n FlowAiAgentRouter,\n FlowBotAction,\n FlowCarousel,\n FlowChannelConditional,\n type FlowContent,\n FlowCountryConditional,\n FlowCustomConditional,\n FlowCustomConditionalV2,\n FlowGoToFlow,\n FlowHandoff,\n FlowImage,\n FlowQueueStatusConditional,\n FlowRating,\n FlowText,\n FlowVideo,\n FlowWhatsappButtonList,\n FlowWhatsappCtaUrlButtonNode,\n FlowWhatsappRequestContactInfoNode,\n FlowWhatsappTemplate,\n} from './content-fields'\nimport { FlowCaptureUserInput } from './content-fields/flow-capture-user-input'\nimport {\n type HtFunctionNode,\n type HtNodeComponent,\n HtNodeWithContentType,\n} from './content-fields/hubtype-fields'\n\nexport class FlowFactory {\n public botContext: BotContext\n public cmsApi: FlowBuilderApi\n public locale: string\n\n constructor(botContext: BotContext, cmsApi: FlowBuilderApi, locale: string) {\n this.botContext = botContext\n this.cmsApi = cmsApi\n this.locale = locale\n }\n\n async getFlowContent(\n hubtypeContent: HtNodeComponent\n ): Promise<FlowContent | undefined> {\n switch (hubtypeContent.type) {\n case HtNodeWithContentType.TEXT:\n return FlowText.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi,\n this.botContext\n )\n case HtNodeWithContentType.IMAGE:\n return FlowImage.fromHubtypeCMS(hubtypeContent, this.locale)\n case HtNodeWithContentType.CAROUSEL:\n return FlowCarousel.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi,\n this.botContext\n )\n case HtNodeWithContentType.VIDEO:\n return FlowVideo.fromHubtypeCMS(hubtypeContent, this.locale)\n case HtNodeWithContentType.WHATSAPP_BUTTON_LIST:\n return FlowWhatsappButtonList.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi\n )\n case HtNodeWithContentType.WHATSAPP_CTA_URL_BUTTON:\n return FlowWhatsappCtaUrlButtonNode.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi,\n this.botContext\n )\n case HtNodeWithContentType.WHATSAPP_REQUEST_CONTACT_INFO:\n return FlowWhatsappRequestContactInfoNode.fromHubtypeCMS(\n hubtypeContent,\n this.locale\n )\n case HtNodeWithContentType.HANDOFF:\n return FlowHandoff.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi\n )\n\n case HtNodeWithContentType.AI_AGENT_ROUTER:\n return FlowAiAgentRouter.fromHubtypeCMS(hubtypeContent, this.botContext)\n\n case HtNodeWithContentType.AI_AGENT:\n return FlowAiAgent.fromHubtypeCMS(hubtypeContent, this.botContext)\n\n case HtNodeWithContentType.RATING:\n return FlowRating.fromHubtypeCMS(hubtypeContent, this.locale)\n\n case HtNodeWithContentType.BOT_ACTION:\n return FlowBotAction.fromHubtypeCMS(hubtypeContent, this.cmsApi)\n\n case HtNodeWithContentType.FUNCTION:\n return this.resolveFlowFunctionContent(hubtypeContent)\n\n case HtNodeWithContentType.GO_TO_FLOW:\n return FlowGoToFlow.fromHubtypeCMS(hubtypeContent, this.cmsApi)\n\n case HtNodeWithContentType.WHATSAPP_TEMPLATE:\n return FlowWhatsappTemplate.fromHubtypeCMS(hubtypeContent, this.locale)\n\n case HtNodeWithContentType.CAPTURE_USER_INPUT:\n return FlowCaptureUserInput.fromHubtypeCMS(hubtypeContent)\n\n case HtNodeWithContentType.CUSTOM_CONDITION:\n return FlowCustomConditionalV2.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n\n default:\n return undefined\n }\n }\n\n private async resolveFlowFunctionContent(\n hubtypeContent: HtFunctionNode\n ): Promise<FlowContent | undefined> {\n switch (hubtypeContent.content.action) {\n case 'check-country':\n return FlowCountryConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n case 'get-channel-type':\n return FlowChannelConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n case 'check-queue-status':\n return FlowQueueStatusConditional.fromHubtypeCMS(\n hubtypeContent,\n this.locale\n )\n case 'check-bot-variable':\n return FlowCustomConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n default:\n return undefined\n }\n }\n}\n"],"names":["FlowAiAgent","FlowAiAgentRouter","FlowBotAction","FlowCarousel","FlowChannelConditional","FlowCountryConditional","FlowCustomConditional","FlowCustomConditionalV2","FlowGoToFlow","FlowHandoff","FlowImage","FlowQueueStatusConditional","FlowRating","FlowText","FlowVideo","FlowWhatsappButtonList","FlowWhatsappCtaUrlButtonNode","FlowWhatsappRequestContactInfoNode","FlowWhatsappTemplate","FlowCaptureUserInput","HtNodeWithContentType","FlowFactory","hubtypeContent","undefined","botContext","cmsApi","locale"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"flow-factory.js","sources":["../src/flow-factory.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\n\nimport type { FlowBuilderApi } from './api'\nimport {\n FlowAiAgent,\n FlowAiAgentRouter,\n FlowBotAction,\n FlowCarousel,\n FlowChannelConditional,\n FlowContactReasonsConditional,\n type FlowContent,\n FlowCountryConditional,\n FlowCustomConditional,\n FlowCustomConditionalV2,\n FlowDoNothing,\n FlowGoToFlow,\n FlowHandoff,\n FlowImage,\n FlowQueueStatusConditional,\n FlowRating,\n FlowText,\n FlowVideo,\n FlowWhatsappButtonList,\n FlowWhatsappCtaUrlButtonNode,\n FlowWhatsappRequestContactInfoNode,\n FlowWhatsappTemplate,\n} from './content-fields'\nimport { FlowCaptureUserInput } from './content-fields/flow-capture-user-input'\nimport {\n type HtFunctionNode,\n type HtNodeComponent,\n HtNodeWithContentType,\n} from './content-fields/hubtype-fields'\n\nexport class FlowFactory {\n public botContext: BotContext\n public cmsApi: FlowBuilderApi\n public locale: string\n\n constructor(botContext: BotContext, cmsApi: FlowBuilderApi, locale: string) {\n this.botContext = botContext\n this.cmsApi = cmsApi\n this.locale = locale\n }\n\n async getFlowContent(\n hubtypeContent: HtNodeComponent\n ): Promise<FlowContent | undefined> {\n switch (hubtypeContent.type) {\n case HtNodeWithContentType.TEXT:\n return FlowText.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi,\n this.botContext\n )\n case HtNodeWithContentType.IMAGE:\n return FlowImage.fromHubtypeCMS(hubtypeContent, this.locale)\n case HtNodeWithContentType.CAROUSEL:\n return FlowCarousel.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi,\n this.botContext\n )\n case HtNodeWithContentType.VIDEO:\n return FlowVideo.fromHubtypeCMS(hubtypeContent, this.locale)\n case HtNodeWithContentType.WHATSAPP_BUTTON_LIST:\n return FlowWhatsappButtonList.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi\n )\n case HtNodeWithContentType.WHATSAPP_CTA_URL_BUTTON:\n return FlowWhatsappCtaUrlButtonNode.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi,\n this.botContext\n )\n case HtNodeWithContentType.WHATSAPP_REQUEST_CONTACT_INFO:\n return FlowWhatsappRequestContactInfoNode.fromHubtypeCMS(\n hubtypeContent,\n this.locale\n )\n case HtNodeWithContentType.HANDOFF:\n return FlowHandoff.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi\n )\n\n case HtNodeWithContentType.AI_AGENT_ROUTER:\n return FlowAiAgentRouter.fromHubtypeCMS(hubtypeContent, this.botContext)\n\n case HtNodeWithContentType.AI_AGENT:\n return FlowAiAgent.fromHubtypeCMS(hubtypeContent, this.botContext)\n\n case HtNodeWithContentType.RATING:\n return FlowRating.fromHubtypeCMS(hubtypeContent, this.locale)\n\n case HtNodeWithContentType.BOT_ACTION:\n return FlowBotAction.fromHubtypeCMS(hubtypeContent, this.cmsApi)\n\n case HtNodeWithContentType.FUNCTION:\n return this.resolveFlowFunctionContent(hubtypeContent)\n\n case HtNodeWithContentType.GO_TO_FLOW:\n return FlowGoToFlow.fromHubtypeCMS(hubtypeContent, this.cmsApi)\n\n case HtNodeWithContentType.WHATSAPP_TEMPLATE:\n return FlowWhatsappTemplate.fromHubtypeCMS(hubtypeContent, this.locale)\n\n case HtNodeWithContentType.CAPTURE_USER_INPUT:\n return FlowCaptureUserInput.fromHubtypeCMS(hubtypeContent)\n\n case HtNodeWithContentType.CUSTOM_CONDITION:\n return FlowCustomConditionalV2.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n\n case HtNodeWithContentType.DO_NOTHING:\n return FlowDoNothing.fromHubtypeCMS(hubtypeContent)\n\n case HtNodeWithContentType.CONTACT_REASONS_CONDITION:\n return FlowContactReasonsConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n\n default:\n return undefined\n }\n }\n\n private async resolveFlowFunctionContent(\n hubtypeContent: HtFunctionNode\n ): Promise<FlowContent | undefined> {\n switch (hubtypeContent.content.action) {\n case 'check-country':\n return FlowCountryConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n case 'get-channel-type':\n return FlowChannelConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n case 'check-queue-status':\n return FlowQueueStatusConditional.fromHubtypeCMS(\n hubtypeContent,\n this.locale\n )\n case 'check-bot-variable':\n return FlowCustomConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n default:\n return undefined\n }\n }\n}\n"],"names":["FlowAiAgent","FlowAiAgentRouter","FlowBotAction","FlowCarousel","FlowChannelConditional","FlowContactReasonsConditional","FlowCountryConditional","FlowCustomConditional","FlowCustomConditionalV2","FlowDoNothing","FlowGoToFlow","FlowHandoff","FlowImage","FlowQueueStatusConditional","FlowRating","FlowText","FlowVideo","FlowWhatsappButtonList","FlowWhatsappCtaUrlButtonNode","FlowWhatsappRequestContactInfoNode","FlowWhatsappTemplate","FlowCaptureUserInput","HtNodeWithContentType","FlowFactory","hubtypeContent","undefined","botContext","cmsApi","locale"],"mappings":";;;;;;;AA0ByB;AACsD;AAKvC;AAEjC,MAAMuB,WAAWA;IAWtB,MAAM,eACJC,cAA+B,EACG;QAClC,OAAQA,eAAe,IAAI;YACzB,KAAKF,0BAA0B;gBAC7B,OAAOP,uBAAuB,CAC5BS,gBACA,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,UAAU;YAEnB,KAAKF,2BAA2B;gBAC9B,OAAOV,wBAAwB,CAACY,gBAAgB,IAAI,CAAC,MAAM;YAC7D,KAAKF,8BAA8B;gBACjC,OAAOnB,2BAA2B,CAChCqB,gBACA,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,UAAU;YAEnB,KAAKF,2BAA2B;gBAC9B,OAAON,wBAAwB,CAACQ,gBAAgB,IAAI,CAAC,MAAM;YAC7D,KAAKF,0CAA0C;gBAC7C,OAAOL,qCAAqC,CAC1CO,gBACA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,CAAC,MAAM;YACnC,KAAK;gBACH,OAAOlB,qCAAqC,CAC1CkB,gBACA,IAAI,CAAC,UAAU;YAEnB,KAAK;gBACH,OAAOpB,qCAAqC,CAC1CoB,gBACA,IAAI,CAAC,UAAU;YAEnB,KAAK;gBACH,OAAOX,yCAAyC,CAC9CW,gBACA,IAAI,CAAC,MAAM;YAEf,KAAK;gBACH,OAAOjB,oCAAoC,CACzCiB,gBACA,IAAI,CAAC,UAAU;YAEnB;gBACE,OAAOC;QACX;IACF;IA5HA,YAAYC,UAAsB,EAAEC,MAAsB,EAAEC,MAAc,CAAE;QAC1E,IAAI,CAAC,UAAU,GAAGF;QAClB,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,MAAM,GAAGC;IAChB;AAyHF"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BotContext, Plugin, ResolvedPlugins, Session } from '@botonic/core';
|
|
2
2
|
import { FlowBuilderApi } from './api.js';
|
|
3
3
|
import type { FlowContent } from './content-fields/index.js';
|
|
4
4
|
import { type HtNodeWithContent } from './content-fields/hubtype-fields/index.js';
|
|
@@ -8,7 +8,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
8
8
|
cmsApi: FlowBuilderApi;
|
|
9
9
|
private flow?;
|
|
10
10
|
private functions;
|
|
11
|
-
private
|
|
11
|
+
private botContext;
|
|
12
12
|
getAccessToken: (session: Session) => string;
|
|
13
13
|
trackEvent?: TrackEventFunction;
|
|
14
14
|
getAiAgentResponse?: AiAgentFunction;
|
|
@@ -20,12 +20,9 @@ export default class BotonicPluginFlowBuilder implements Plugin {
|
|
|
20
20
|
customRatingMessageEnabled: boolean;
|
|
21
21
|
disableAIAgentInFirstInteraction: boolean;
|
|
22
22
|
constructor(options: BotonicPluginFlowBuilderOptions<ResolvedPlugins, any>);
|
|
23
|
-
resolveFlowUrl(
|
|
24
|
-
pre(
|
|
25
|
-
|
|
26
|
-
private updateRequestBeforeRoutes;
|
|
27
|
-
private removeSourceSuffix;
|
|
28
|
-
post(request: PluginPreRequest): void;
|
|
23
|
+
resolveFlowUrl(botContext: BotContext): string;
|
|
24
|
+
pre(botContext: BotContext): Promise<void>;
|
|
25
|
+
post(botContext: BotContext): void;
|
|
29
26
|
getContentsByContentID(contentID: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
|
|
30
27
|
getUUIDByContentID(contentID: string): string;
|
|
31
28
|
private getContentsById;
|
package/lib/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { INPUT, PROVIDER } from "@botonic/core";
|
|
2
1
|
import { v7 } from "uuid";
|
|
3
2
|
import { FlowBuilderApi } from "./api.js";
|
|
4
|
-
import {
|
|
3
|
+
import { BotContextManager } from "./bot-context-manager.js";
|
|
4
|
+
import { AGENT_RATING_PAYLOAD, EMPTY_PAYLOAD, FLOW_BUILDER_API_URL_PROD, SEPARATOR } from "./constants.js";
|
|
5
5
|
import { HtNodeWithContentType } from "./content-fields/hubtype-fields/index.js";
|
|
6
6
|
import { FlowFactory } from "./flow-factory.js";
|
|
7
7
|
import { CustomFunction, DEFAULT_FUNCTION_NAMES } from "./functions/index.js";
|
|
8
8
|
import { FlowBuilderJSONVersion } from "./types.js";
|
|
9
|
-
import { getNextPayloadByUserInput } from "./user-input/index.js";
|
|
10
9
|
import { resolveGetAccessToken } from "./utils/authentication.js";
|
|
11
|
-
import { inputHasTextOrTranscript } from "./utils/input.js";
|
|
12
10
|
|
|
13
11
|
export * from "./action/index.js";
|
|
14
12
|
export * from "./content-fields/index.js";
|
|
@@ -29,67 +27,31 @@ export * from "./webview/index.js";
|
|
|
29
27
|
|
|
30
28
|
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
30
|
|
|
37
31
|
|
|
38
32
|
|
|
39
33
|
class BotonicPluginFlowBuilder {
|
|
40
|
-
resolveFlowUrl(
|
|
41
|
-
if (
|
|
34
|
+
resolveFlowUrl(botContext) {
|
|
35
|
+
if (botContext.session.is_test_integration) {
|
|
42
36
|
return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${FlowBuilderJSONVersion.DRAFT}/`;
|
|
43
37
|
}
|
|
44
38
|
return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${this.jsonVersion}/`;
|
|
45
39
|
}
|
|
46
|
-
async pre(
|
|
47
|
-
|
|
48
|
-
this.convertWhatsappAiAgentEmptyPayloads(request);
|
|
49
|
-
this.currentRequest = request;
|
|
40
|
+
async pre(botContext) {
|
|
41
|
+
this.botContext = botContext;
|
|
50
42
|
this.cmsApi = await FlowBuilderApi.create({
|
|
51
|
-
flowUrl: this.resolveFlowUrl(
|
|
43
|
+
flowUrl: this.resolveFlowUrl(botContext),
|
|
52
44
|
url: this.apiUrl,
|
|
53
45
|
flow: this.flow,
|
|
54
|
-
accessToken: this.getAccessToken(
|
|
55
|
-
|
|
46
|
+
accessToken: this.getAccessToken(botContext.session),
|
|
47
|
+
botContext: this.botContext
|
|
56
48
|
});
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const resolvedLocale = this.cmsApi.getResolvedLocale();
|
|
60
|
-
const nextPayload = await getNextPayloadByUserInput(this.cmsApi, resolvedLocale, request, this.smartIntentsConfig);
|
|
61
|
-
request.input.payload = nextPayload;
|
|
62
|
-
}
|
|
63
|
-
await this.updateRequestBeforeRoutes(request);
|
|
64
|
-
}
|
|
65
|
-
convertWhatsappAiAgentEmptyPayloads(request) {
|
|
66
|
-
if (request.session.user.provider === PROVIDER.WHATSAPP) {
|
|
67
|
-
const shouldUseReferral = request.input.referral && request.input.payload?.startsWith(EMPTY_PAYLOAD);
|
|
68
|
-
if (shouldUseReferral) {
|
|
69
|
-
request.input.type = INPUT.TEXT;
|
|
70
|
-
request.input.data = request.input.referral;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async updateRequestBeforeRoutes(request) {
|
|
75
|
-
this.cmsApi.removeCaptureUserInputId();
|
|
76
|
-
if (request.input.payload) {
|
|
77
|
-
request.input.payload = this.removeSourceSuffix(request.input.payload);
|
|
78
|
-
if (this.cmsApi.isBotAction(request.input.payload)) {
|
|
79
|
-
const cmsBotAction = this.cmsApi.getNodeById(request.input.payload);
|
|
80
|
-
request.input.payload = this.cmsApi.createPayloadWithParams(cmsBotAction);
|
|
81
|
-
// Re-execute convertWhatsappAiAgentEmptyPayloads function to handle
|
|
82
|
-
// the case that a BotAction has a payload equals to EMPTY_PAYLOAD
|
|
83
|
-
this.convertWhatsappAiAgentEmptyPayloads(request);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
removeSourceSuffix(payload) {
|
|
88
|
-
return payload.split(SOURCE_INFO_SEPARATOR)[0];
|
|
49
|
+
const botContextManager = new BotContextManager(this.cmsApi, this.smartIntentsConfig);
|
|
50
|
+
await botContextManager.prepareInputForRoutes(botContext);
|
|
89
51
|
}
|
|
90
|
-
post(
|
|
91
|
-
|
|
92
|
-
delete
|
|
52
|
+
post(botContext) {
|
|
53
|
+
botContext.input.nluResolution = undefined;
|
|
54
|
+
delete botContext.session.user.system_locale_updated;
|
|
93
55
|
}
|
|
94
56
|
async getContentsByContentID(contentID, prevContents) {
|
|
95
57
|
const node = this.cmsApi.getNodeByContentID(contentID);
|
|
@@ -105,18 +67,18 @@ class BotonicPluginFlowBuilder {
|
|
|
105
67
|
}
|
|
106
68
|
async getStartContents() {
|
|
107
69
|
const startNode = this.cmsApi.getStartNode();
|
|
108
|
-
this.
|
|
70
|
+
this.botContext.session.flow_thread_id = v7();
|
|
109
71
|
return await this.getContentsByNode(startNode);
|
|
110
72
|
}
|
|
111
73
|
async getContentsByNode(node, prevContents) {
|
|
112
74
|
const contents = prevContents || [];
|
|
113
75
|
const resolvedLocale = this.cmsApi.getResolvedLocale();
|
|
114
76
|
if (node.type === HtNodeWithContentType.FUNCTION && !DEFAULT_FUNCTION_NAMES.includes(node.content.action)) {
|
|
115
|
-
const customFunctionResolver = new CustomFunction(this.functions, this.
|
|
77
|
+
const customFunctionResolver = new CustomFunction(this.functions, this.botContext, resolvedLocale);
|
|
116
78
|
const targetId = await customFunctionResolver.call(node);
|
|
117
79
|
return this.getContentsById(targetId, contents);
|
|
118
80
|
}
|
|
119
|
-
const flowFactory = new FlowFactory(this.
|
|
81
|
+
const flowFactory = new FlowFactory(this.botContext, this.cmsApi, resolvedLocale);
|
|
120
82
|
const content = await flowFactory.getFlowContent(node);
|
|
121
83
|
if (content) {
|
|
122
84
|
contents.push(content);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {\n INPUT,\n type Plugin,\n type PluginPreRequest,\n PROVIDER,\n type ResolvedPlugins,\n type Session,\n} from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\nimport { v7 as uuidv7 } from 'uuid'\n\nimport { FlowBuilderApi } from './api'\nimport {\n EMPTY_PAYLOAD,\n FLOW_BUILDER_API_URL_PROD,\n SEPARATOR,\n SOURCE_INFO_SEPARATOR,\n} from './constants'\nimport type { FlowContent } from './content-fields'\nimport {\n type HtBotActionNode,\n type HtFlowBuilderData,\n type HtNodeWithContent,\n HtNodeWithContentType,\n} from './content-fields/hubtype-fields'\nimport { FlowFactory } from './flow-factory'\nimport { CustomFunction, DEFAULT_FUNCTION_NAMES } from './functions'\nimport {\n type AiAgentFunction,\n type BotonicPluginFlowBuilderOptions,\n type ContentFilter,\n FlowBuilderJSONVersion,\n type InShadowingConfig,\n type PayloadParamsBase,\n type RatingSubmittedInfo,\n type TrackEventFunction,\n} from './types'\nimport { getNextPayloadByUserInput } from './user-input'\nimport type { SmartIntentsInferenceConfig } from './user-input/smart-intent'\nimport { resolveGetAccessToken } from './utils/authentication'\nimport { inputHasTextOrTranscript } from './utils/input'\n\n// TODO: Create a proper service to wrap all calls and allow api versioning\n\nexport default class BotonicPluginFlowBuilder implements Plugin {\n public cmsApi: FlowBuilderApi\n private flow?: HtFlowBuilderData\n private functions: Record<any, any>\n private currentRequest: PluginPreRequest\n public getAccessToken: (session: Session) => string\n public trackEvent?: TrackEventFunction\n public getAiAgentResponse?: AiAgentFunction\n public smartIntentsConfig: SmartIntentsInferenceConfig\n public inShadowing: InShadowingConfig\n public contentFilters: ContentFilter[]\n\n // TODO: Rethink how we construct FlowBuilderApi to be simpler\n public jsonVersion: FlowBuilderJSONVersion\n public apiUrl: string\n public customRatingMessageEnabled: boolean\n public disableAIAgentInFirstInteraction: boolean\n\n constructor(options: BotonicPluginFlowBuilderOptions<ResolvedPlugins, any>) {\n this.apiUrl = options.apiUrl || FLOW_BUILDER_API_URL_PROD\n this.jsonVersion = options.jsonVersion || FlowBuilderJSONVersion.LATEST\n this.flow = options.flow\n this.getAccessToken = resolveGetAccessToken(options.getAccessToken)\n this.trackEvent = options.trackEvent\n this.getAiAgentResponse = options.getAiAgentResponse\n this.smartIntentsConfig = {\n ...options?.smartIntentsConfig,\n useLatest: this.jsonVersion === FlowBuilderJSONVersion.LATEST,\n }\n const customFunctions = options.customFunctions || {}\n this.functions = customFunctions\n this.inShadowing = {\n allowKeywords: options.inShadowing?.allowKeywords || false,\n allowSmartIntents: options.inShadowing?.allowSmartIntents || false,\n allowAiAgents: options.inShadowing?.allowAiAgents || false,\n }\n this.contentFilters = options.contentFilters || []\n this.customRatingMessageEnabled =\n options.customRatingMessageEnabled || false\n this.disableAIAgentInFirstInteraction =\n options.disableAIAgentInFirstInteraction || false\n }\n\n resolveFlowUrl(request: PluginPreRequest): string {\n if (request.session.is_test_integration) {\n return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${FlowBuilderJSONVersion.DRAFT}/`\n }\n return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${this.jsonVersion}/`\n }\n\n async pre(request: PluginPreRequest): Promise<void> {\n // When AI Agent is executed in Whatsapp, button payloads come as referral and must be converted to text being processed by the agent.\n this.convertWhatsappAiAgentEmptyPayloads(request)\n\n this.currentRequest = request\n this.cmsApi = await FlowBuilderApi.create({\n flowUrl: this.resolveFlowUrl(request),\n url: this.apiUrl,\n flow: this.flow,\n accessToken: this.getAccessToken(request.session),\n request: this.currentRequest,\n })\n\n const checkUserTextInput =\n inputHasTextOrTranscript(request.input) && !request.input.payload\n\n if (checkUserTextInput) {\n const resolvedLocale = this.cmsApi.getResolvedLocale()\n const nextPayload = await getNextPayloadByUserInput(\n this.cmsApi,\n resolvedLocale,\n request as unknown as ActionRequest,\n this.smartIntentsConfig\n )\n request.input.payload = nextPayload\n }\n\n await this.updateRequestBeforeRoutes(request)\n }\n\n private convertWhatsappAiAgentEmptyPayloads(request: PluginPreRequest): void {\n if (request.session.user.provider === PROVIDER.WHATSAPP) {\n const shouldUseReferral =\n request.input.referral &&\n request.input.payload?.startsWith(EMPTY_PAYLOAD)\n\n if (shouldUseReferral) {\n request.input.type = INPUT.TEXT\n request.input.data = request.input.referral\n }\n }\n }\n\n private async updateRequestBeforeRoutes(\n request: PluginPreRequest\n ): Promise<void> {\n this.cmsApi.removeCaptureUserInputId()\n if (request.input.payload) {\n request.input.payload = this.removeSourceSuffix(request.input.payload)\n\n if (this.cmsApi.isBotAction(request.input.payload)) {\n const cmsBotAction = this.cmsApi.getNodeById<HtBotActionNode>(\n request.input.payload\n )\n\n request.input.payload =\n this.cmsApi.createPayloadWithParams(cmsBotAction)\n\n // Re-execute convertWhatsappAiAgentEmptyPayloads function to handle\n // the case that a BotAction has a payload equals to EMPTY_PAYLOAD\n this.convertWhatsappAiAgentEmptyPayloads(request)\n }\n }\n }\n\n private removeSourceSuffix(payload: string): string {\n return payload.split(SOURCE_INFO_SEPARATOR)[0]\n }\n\n post(request: PluginPreRequest): void {\n request.input.nluResolution = undefined\n delete request.session.user.system_locale_updated\n }\n\n async getContentsByContentID(\n contentID: string,\n prevContents?: FlowContent[]\n ): Promise<FlowContent[]> {\n const node = this.cmsApi.getNodeByContentID(contentID) as HtNodeWithContent\n return await this.getContentsByNode(node, prevContents)\n }\n\n getUUIDByContentID(contentID: string): string {\n const node = this.cmsApi.getNodeByContentID(contentID)\n return node.id\n }\n\n private async getContentsById(\n id: string,\n prevContents?: FlowContent[]\n ): Promise<FlowContent[]> {\n const node = this.cmsApi.getNodeById(id) as HtNodeWithContent\n return await this.getContentsByNode(node, prevContents)\n }\n\n async getStartContents(): Promise<FlowContent[]> {\n const startNode = this.cmsApi.getStartNode()\n this.currentRequest.session.flow_thread_id = uuidv7()\n return await this.getContentsByNode(startNode)\n }\n\n async getContentsByNode(\n node: HtNodeWithContent,\n prevContents?: FlowContent[]\n ): Promise<FlowContent[]> {\n const contents = prevContents || []\n const resolvedLocale = this.cmsApi.getResolvedLocale()\n\n if (\n node.type === HtNodeWithContentType.FUNCTION &&\n !DEFAULT_FUNCTION_NAMES.includes(node.content.action)\n ) {\n const customFunctionResolver = new CustomFunction(\n this.functions,\n this.currentRequest,\n resolvedLocale\n )\n const targetId = await customFunctionResolver.call(node)\n return this.getContentsById(targetId, contents)\n }\n\n const flowFactory = new FlowFactory(\n this.currentRequest,\n this.cmsApi,\n resolvedLocale\n )\n const content = await flowFactory.getFlowContent(node)\n if (content) {\n contents.push(content)\n }\n\n // If node is BOT_ACTION not add more contents to render, next nodes render after execute action\n if (node.type === HtNodeWithContentType.BOT_ACTION) {\n return contents\n }\n\n // TODO: prevent infinite recursive calls\n if (content?.followUp) {\n return this.getContentsById(content.followUp.id, contents)\n } else if (node.follow_up) {\n console.log('FOLLOWUP FROM NODE-------> OLD SYSTEM')\n return this.getContentsById(node.follow_up.id, contents)\n }\n\n return contents\n }\n\n getPayloadParams<T extends PayloadParamsBase>(payload: string): T {\n const payloadParams = JSON.parse(payload.split(SEPARATOR)[1] || '{}')\n return payloadParams\n }\n\n getFlowName(flowId: string): string {\n return this.cmsApi.getFlowName(flowId)\n }\n\n getRatingSubmittedInfo(payload: string): RatingSubmittedInfo {\n const buttonId = payload?.split(SEPARATOR)[1]\n const ratingNode = this.cmsApi.getRatingNodeByButtonId(buttonId)\n\n const ratingButton = this.cmsApi.getRatingButtonById(ratingNode, buttonId)\n const possibleOptions = ratingNode.content.buttons.map(\n button => button.text\n )\n const possibleValues = ratingNode.content.buttons.map(\n button => button.value\n )\n\n return {\n ...ratingButton,\n possibleOptions,\n possibleValues,\n }\n }\n\n setInShadowing(inShadowing: InShadowingConfig): void {\n this.inShadowing = inShadowing\n }\n}\n\nexport * from './action'\nexport { AGENT_RATING_PAYLOAD, EMPTY_PAYLOAD } from './constants'\nexport * from './content-fields'\nexport type { HtBotActionNode } from './content-fields/hubtype-fields'\nexport {\n getCommonFlowContentEventArgsForContentId,\n trackFlowContent,\n} from './tracking'\nexport {\n type BotonicPluginFlowBuilderOptions,\n type ContentFilter,\n FlowBuilderJSONVersion,\n type PayloadParamsBase,\n type RatingSubmittedInfo,\n} from './types'\nexport * from './webview'\n"],"names":["INPUT","PROVIDER","v7","uuidv7","FlowBuilderApi","EMPTY_PAYLOAD","FLOW_BUILDER_API_URL_PROD","SEPARATOR","SOURCE_INFO_SEPARATOR","HtNodeWithContentType","FlowFactory","CustomFunction","DEFAULT_FUNCTION_NAMES","FlowBuilderJSONVersion","getNextPayloadByUserInput","resolveGetAccessToken","inputHasTextOrTranscript","BotonicPluginFlowBuilder","request","checkUserTextInput","resolvedLocale","nextPayload","shouldUseReferral","cmsBotAction","payload","undefined","contentID","prevContents","node","id","startNode","contents","customFunctionResolver","targetId","flowFactory","content","console","payloadParams","JSON","flowId","buttonId","ratingNode","ratingButton","possibleOptions","button","possibleValues","inShadowing","options","customFunctions","AGENT_RATING_PAYLOAD","getCommonFlowContentEventArgsForContentId","trackFlowContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOsB;AAEa;AAEG;AAMlB;AAOoB;AACI;AACwB;AAUpD;AACwC;AAEM;AACN;AAIzC,MAAMiB,wBAAwBA;IA2C3C,eAAeC,OAAyB,EAAU;QAChD,IAAIA,QAAQ,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B,IAAI,CAAC,WAAW,GAAG;YACjB,eAAeD,QAAQ,WAAW,EAAE,iBAAiB;YACrD,mBAAmBA,QAAQ,WAAW,EAAE,qBAAqB;YAC7D,eAAeA,QAAQ,WAAW,EAAE,iBAAiB;QACvD;QACA,IAAI,CAAC,cAAc,GAAGA,QAAQ,cAAc,IAAI,EAAE;QAClD,IAAI,CAAC,0BAA0B,GAC7BA,QAAQ,0BAA0B,IAAI;QACxC,IAAI,CAAC,gCAAgC,GACnCA,QAAQ,gCAAgC,IAAI;IAChD;AA2LF;AAtOA,2EAA2E;AAsO1E;AAEuB;AACyC;AACjC;AAKb;AAOH;AACS"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type {\n BotContext,\n Plugin,\n ResolvedPlugins,\n Session,\n} from '@botonic/core'\nimport { v7 as uuidv7 } from 'uuid'\n\nimport { FlowBuilderApi } from './api'\nimport { BotContextManager } from './bot-context-manager'\nimport { FLOW_BUILDER_API_URL_PROD, SEPARATOR } from './constants'\nimport type { FlowContent } from './content-fields'\nimport {\n type HtFlowBuilderData,\n type HtNodeWithContent,\n HtNodeWithContentType,\n} from './content-fields/hubtype-fields'\nimport { FlowFactory } from './flow-factory'\nimport { CustomFunction, DEFAULT_FUNCTION_NAMES } from './functions'\nimport {\n type AiAgentFunction,\n type BotonicPluginFlowBuilderOptions,\n type ContentFilter,\n FlowBuilderJSONVersion,\n type InShadowingConfig,\n type PayloadParamsBase,\n type RatingSubmittedInfo,\n type TrackEventFunction,\n} from './types'\nimport type { SmartIntentsInferenceConfig } from './user-input/smart-intent'\nimport { resolveGetAccessToken } from './utils/authentication'\n\n// TODO: Create a proper service to wrap all calls and allow api versioning\n\nexport default class BotonicPluginFlowBuilder implements Plugin {\n public cmsApi: FlowBuilderApi\n private flow?: HtFlowBuilderData\n private functions: Record<any, any>\n private botContext: BotContext\n public getAccessToken: (session: Session) => string\n public trackEvent?: TrackEventFunction\n public getAiAgentResponse?: AiAgentFunction\n public smartIntentsConfig: SmartIntentsInferenceConfig\n public inShadowing: InShadowingConfig\n public contentFilters: ContentFilter[]\n\n // TODO: Rethink how we construct FlowBuilderApi to be simpler\n public jsonVersion: FlowBuilderJSONVersion\n public apiUrl: string\n public customRatingMessageEnabled: boolean\n public disableAIAgentInFirstInteraction: boolean\n\n constructor(options: BotonicPluginFlowBuilderOptions<ResolvedPlugins, any>) {\n this.apiUrl = options.apiUrl || FLOW_BUILDER_API_URL_PROD\n this.jsonVersion = options.jsonVersion || FlowBuilderJSONVersion.LATEST\n this.flow = options.flow\n this.getAccessToken = resolveGetAccessToken(options.getAccessToken)\n this.trackEvent = options.trackEvent\n this.getAiAgentResponse = options.getAiAgentResponse\n this.smartIntentsConfig = {\n ...options?.smartIntentsConfig,\n useLatest: this.jsonVersion === FlowBuilderJSONVersion.LATEST,\n }\n const customFunctions = options.customFunctions || {}\n this.functions = customFunctions\n this.inShadowing = {\n allowKeywords: options.inShadowing?.allowKeywords || false,\n allowSmartIntents: options.inShadowing?.allowSmartIntents || false,\n allowAiAgents: options.inShadowing?.allowAiAgents || false,\n }\n this.contentFilters = options.contentFilters || []\n this.customRatingMessageEnabled =\n options.customRatingMessageEnabled || false\n this.disableAIAgentInFirstInteraction =\n options.disableAIAgentInFirstInteraction || false\n }\n\n resolveFlowUrl(botContext: BotContext): string {\n if (botContext.session.is_test_integration) {\n return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${FlowBuilderJSONVersion.DRAFT}/`\n }\n return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${this.jsonVersion}/`\n }\n\n async pre(botContext: BotContext): Promise<void> {\n this.botContext = botContext\n this.cmsApi = await FlowBuilderApi.create({\n flowUrl: this.resolveFlowUrl(botContext),\n url: this.apiUrl,\n flow: this.flow,\n accessToken: this.getAccessToken(botContext.session),\n botContext: this.botContext,\n })\n\n const botContextManager = new BotContextManager(\n this.cmsApi,\n this.smartIntentsConfig\n )\n await botContextManager.prepareInputForRoutes(botContext)\n }\n\n post(botContext: BotContext): void {\n botContext.input.nluResolution = undefined\n delete botContext.session.user.system_locale_updated\n }\n\n async getContentsByContentID(\n contentID: string,\n prevContents?: FlowContent[]\n ): Promise<FlowContent[]> {\n const node = this.cmsApi.getNodeByContentID(contentID) as HtNodeWithContent\n return await this.getContentsByNode(node, prevContents)\n }\n\n getUUIDByContentID(contentID: string): string {\n const node = this.cmsApi.getNodeByContentID(contentID)\n return node.id\n }\n\n private async getContentsById(\n id: string,\n prevContents?: FlowContent[]\n ): Promise<FlowContent[]> {\n const node = this.cmsApi.getNodeById(id) as HtNodeWithContent\n return await this.getContentsByNode(node, prevContents)\n }\n\n async getStartContents(): Promise<FlowContent[]> {\n const startNode = this.cmsApi.getStartNode()\n this.botContext.session.flow_thread_id = uuidv7()\n return await this.getContentsByNode(startNode)\n }\n\n async getContentsByNode(\n node: HtNodeWithContent,\n prevContents?: FlowContent[]\n ): Promise<FlowContent[]> {\n const contents = prevContents || []\n const resolvedLocale = this.cmsApi.getResolvedLocale()\n\n if (\n node.type === HtNodeWithContentType.FUNCTION &&\n !DEFAULT_FUNCTION_NAMES.includes(node.content.action)\n ) {\n const customFunctionResolver = new CustomFunction(\n this.functions,\n this.botContext,\n resolvedLocale\n )\n const targetId = await customFunctionResolver.call(node)\n return this.getContentsById(targetId, contents)\n }\n\n const flowFactory = new FlowFactory(\n this.botContext,\n this.cmsApi,\n resolvedLocale\n )\n const content = await flowFactory.getFlowContent(node)\n if (content) {\n contents.push(content)\n }\n\n // If node is BOT_ACTION not add more contents to render, next nodes render after execute action\n if (node.type === HtNodeWithContentType.BOT_ACTION) {\n return contents\n }\n\n // TODO: prevent infinite recursive calls\n if (content?.followUp) {\n return this.getContentsById(content.followUp.id, contents)\n } else if (node.follow_up) {\n console.log('FOLLOWUP FROM NODE-------> OLD SYSTEM')\n return this.getContentsById(node.follow_up.id, contents)\n }\n\n return contents\n }\n\n getPayloadParams<T extends PayloadParamsBase>(payload: string): T {\n const payloadParams = JSON.parse(payload.split(SEPARATOR)[1] || '{}')\n return payloadParams\n }\n\n getFlowName(flowId: string): string {\n return this.cmsApi.getFlowName(flowId)\n }\n\n getRatingSubmittedInfo(payload: string): RatingSubmittedInfo {\n const buttonId = payload?.split(SEPARATOR)[1]\n const ratingNode = this.cmsApi.getRatingNodeByButtonId(buttonId)\n\n const ratingButton = this.cmsApi.getRatingButtonById(ratingNode, buttonId)\n const possibleOptions = ratingNode.content.buttons.map(\n button => button.text\n )\n const possibleValues = ratingNode.content.buttons.map(\n button => button.value\n )\n\n return {\n ...ratingButton,\n possibleOptions,\n possibleValues,\n }\n }\n\n setInShadowing(inShadowing: InShadowingConfig): void {\n this.inShadowing = inShadowing\n }\n}\n\nexport * from './action'\nexport { AGENT_RATING_PAYLOAD, EMPTY_PAYLOAD } from './constants'\nexport * from './content-fields'\nexport type { HtBotActionNode } from './content-fields/hubtype-fields'\nexport {\n getCommonFlowContentEventArgsForContentId,\n trackFlowContent,\n} from './tracking'\nexport {\n type BotonicPluginFlowBuilderOptions,\n type ContentFilter,\n FlowBuilderJSONVersion,\n type PayloadParamsBase,\n type RatingSubmittedInfo,\n} from './types'\nexport * from './webview'\n"],"names":["v7","uuidv7","FlowBuilderApi","BotContextManager","FLOW_BUILDER_API_URL_PROD","SEPARATOR","HtNodeWithContentType","FlowFactory","CustomFunction","DEFAULT_FUNCTION_NAMES","FlowBuilderJSONVersion","resolveGetAccessToken","BotonicPluginFlowBuilder","botContext","botContextManager","undefined","contentID","prevContents","node","id","startNode","contents","resolvedLocale","customFunctionResolver","targetId","flowFactory","content","console","payload","payloadParams","JSON","flowId","buttonId","ratingNode","ratingButton","possibleOptions","button","possibleValues","inShadowing","options","customFunctions","AGENT_RATING_PAYLOAD","EMPTY_PAYLOAD","getCommonFlowContentEventArgsForContentId","trackFlowContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAMmC;AAEG;AACmB;AACS;AAM1B;AACI;AACwB;AAUpD;AAE8C;AAI/C,MAAMY,wBAA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C;QACjB,IAAI,CAAC,WAAW,GAAG;YACjB,eAAeD,QAAQ,WAAW,EAAE,iBAAiB;YACrD,mBAAmBA,QAAQ,WAAW,EAAE,qBAAqB;YAC7D,eAAeA,QAAQ,WAAW,EAAE,iBAAiB;QACvD;QACA,IAAI,CAAC,cAAc,GAAGA,QAAQ,cAAc,IAAI,EAAE;QAClD,IAAI,CAAC,0BAA0B,GAC7BA,QAAQ,0BAA0B,IAAI;QACxC,IAAI,CAAC,gCAAgC,GACnCA,QAAQ,gCAAgC,IAAI;IAChD;AAuIF;AAlLA,2EAA2E;AAkL1E;AAEuB;AACyC;AACjC;AAKb;AAOH;AACS"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AiAgentArgs, BotContext, GuardrailRule, InferenceResponse,
|
|
1
|
+
import type { AiAgentArgs, BotContext, GuardrailRule, InferenceResponse, ResolvedPlugins } from '@botonic/core';
|
|
2
2
|
import type { FlowContent } from './content-fields/index.js';
|
|
3
3
|
import type { HtFlowBuilderData, HtRatingButton } from './content-fields/hubtype-fields/index.js';
|
|
4
4
|
import type { FlowBuilderContentMessage } from './structured-output/flow-builder-content.js';
|
|
@@ -31,7 +31,7 @@ export interface FlowBuilderApiOptions {
|
|
|
31
31
|
flowUrl: string;
|
|
32
32
|
flow?: HtFlowBuilderData;
|
|
33
33
|
accessToken: string;
|
|
34
|
-
|
|
34
|
+
botContext: BotContext;
|
|
35
35
|
}
|
|
36
36
|
export declare enum ProcessEnvNodeEnvs {
|
|
37
37
|
PRODUCTION = "production",
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n AiAgentArgs,\n BotContext,\n GuardrailRule,\n InferenceResponse,\n
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n AiAgentArgs,\n BotContext,\n GuardrailRule,\n InferenceResponse,\n ResolvedPlugins,\n} from '@botonic/core'\nimport type { FlowContent } from './content-fields'\nimport type {\n HtFlowBuilderData,\n HtRatingButton,\n} from './content-fields/hubtype-fields'\nimport type { FlowBuilderContentMessage } from './structured-output/flow-builder-content'\n\nexport interface InShadowingConfig {\n allowKeywords: boolean\n allowSmartIntents: boolean\n allowAiAgents: boolean\n}\n\nexport interface BotonicPluginFlowBuilderOptions<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> {\n apiUrl?: string\n jsonVersion?: FlowBuilderJSONVersion\n flow?: HtFlowBuilderData\n customFunctions?: Record<any, any>\n getAccessToken: () => string\n trackEvent?: TrackEventFunction<TPlugins, TExtraData>\n getAiAgentResponse?: AiAgentFunction<TPlugins, TExtraData>\n smartIntentsConfig?: { numSmartIntentsToUse: number }\n inShadowing?: Partial<InShadowingConfig>\n contentFilters?: ContentFilter<TPlugins, TExtraData>[]\n customRatingMessageEnabled?: boolean\n disableAIAgentInFirstInteraction?: boolean\n}\n\nexport type TrackEventFunction<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = (\n request: BotContext<TPlugins, TExtraData>,\n eventAction: string,\n args?: Record<string, any>\n) => Promise<void>\n\nexport type AiAgentFunction<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = (\n request: BotContext<TPlugins, TExtraData>,\n aiAgentArgs: AiAgentArgs\n) => Promise<InferenceResponse<FlowBuilderContentMessage>>\n\nexport type ContentFilter<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = (\n request: BotContext<TPlugins, TExtraData>,\n content: FlowContent\n) => Promise<FlowContent> | FlowContent\n\nexport interface FlowBuilderApiOptions {\n url: string\n flowUrl: string\n flow?: HtFlowBuilderData\n accessToken: string\n botContext: BotContext\n}\n\nexport enum ProcessEnvNodeEnvs {\n PRODUCTION = 'production',\n DEVELOPMENT = 'development',\n}\n\nexport enum FlowBuilderJSONVersion {\n DRAFT = 'draft',\n LATEST = 'latest',\n}\n\nexport interface SmartIntentResponse {\n data: {\n smart_intent_title: string\n text: string\n smart_intents_used: {\n title: string\n description: string\n }[]\n }\n}\n\nexport interface PayloadParamsBase {\n contentID: string\n followUpContentID?: string\n}\n\nexport interface RatingSubmittedInfo extends HtRatingButton {\n possibleOptions: string[]\n possibleValues: number[]\n}\n\nexport type { AiAgentArgs, GuardrailRule }\n"],"names":["ProcessEnvNodeEnvs","FlowBuilderJSONVersion"],"mappings":"AAuEO,IAAKA,wBAAkBA,0BAAlBA;;;WAAAA;MAGX;AAEM,IAAKC,4BAAsBA,0BAAtBA;;;WAAAA;MAGX"}
|
|
@@ -4,6 +4,7 @@ import { FlowImage } from "../content-fields/flow-image.js";
|
|
|
4
4
|
import { FlowText } from "../content-fields/flow-text.js";
|
|
5
5
|
import { FlowVideo } from "../content-fields/flow-video.js";
|
|
6
6
|
import { FlowWhatsappCtaUrlButtonNode } from "../content-fields/flow-whatsapp-cta-url-button.js";
|
|
7
|
+
import { FlowWhatsappRequestContactInfoNode } from "../content-fields/flow-whatsapp-request-contact-info.js";
|
|
7
8
|
import { FlowWhatsappTemplate } from "../content-fields/flow-whatsapp-template.js";
|
|
8
9
|
import { HtButtonStyle } from "../content-fields/hubtype-fields/index.js";
|
|
9
10
|
import { FlowWhatsappButtonList } from "../content-fields/whatsapp-button-list/flow-whatsapp-button-list.js";
|
|
@@ -25,6 +26,8 @@ import { FlowWhatsappButtonList } from "../content-fields/whatsapp-button-list/f
|
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
|
|
29
|
+
|
|
30
|
+
|
|
28
31
|
|
|
29
32
|
// biome-ignore lint/complexity/noStaticOnlyClass: namespace-like adapter with private static helpers
|
|
30
33
|
class HubtypeAssistantContent {
|
|
@@ -50,6 +53,9 @@ class HubtypeAssistantContent {
|
|
|
50
53
|
if (content instanceof FlowWhatsappTemplate) {
|
|
51
54
|
return HubtypeAssistantContent.formatWhatsappTemplateContent(content);
|
|
52
55
|
}
|
|
56
|
+
if (content instanceof FlowWhatsappRequestContactInfoNode) {
|
|
57
|
+
return HubtypeAssistantContent.formatRequestContactInfoContent(content);
|
|
58
|
+
}
|
|
53
59
|
return '';
|
|
54
60
|
}
|
|
55
61
|
static quickReplyLabel(button) {
|
|
@@ -180,6 +186,13 @@ class HubtypeAssistantContent {
|
|
|
180
186
|
const { name, language } = template.htWhatsappTemplate;
|
|
181
187
|
return `WhatsApp Template: ${name} (${language})`;
|
|
182
188
|
}
|
|
189
|
+
static formatRequestContactInfoContent(requestContactInfo) {
|
|
190
|
+
const body = requestContactInfo.text?.trim() ?? '';
|
|
191
|
+
if (!body) {
|
|
192
|
+
return '[WhatsApp Request Contact Info]';
|
|
193
|
+
}
|
|
194
|
+
return requestContactInfo.text;
|
|
195
|
+
}
|
|
183
196
|
}
|
|
184
197
|
|
|
185
198
|
export { HubtypeAssistantContent };
|