UNPKG

@botonic/plugin-flow-builder

Version:

Botonic plugin for **Hubtype Flow Builder**: run and bridge flow-driven logic from bots on the **current** line.

69 lines 4.33 kB
import { __awaiter } from "tslib"; import { FlowAiAgent, FlowAiAgentRouter, FlowBotAction, FlowCaptureUserInput, FlowCarousel, FlowChannelConditional, FlowCountryConditional, FlowCustomConditional, FlowCustomConditionalV2, FlowGoToFlow, FlowHandoff, FlowImage, FlowKnowledgeBase, FlowQueueStatusConditional, FlowRating, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, FlowWhatsappTemplate, } from './content-fields'; import { HtNodeWithContentType, } from './content-fields/hubtype-fields'; export class FlowFactory { constructor(botonicContext, cmsApi, locale) { this.botonicContext = botonicContext; this.cmsApi = cmsApi; this.locale = locale; } getFlowContent(hubtypeContent) { return __awaiter(this, void 0, void 0, function* () { switch (hubtypeContent.type) { case HtNodeWithContentType.TEXT: return FlowText.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.IMAGE: return FlowImage.fromHubtypeCMS(hubtypeContent, this.locale); case HtNodeWithContentType.CAROUSEL: return FlowCarousel.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.VIDEO: return FlowVideo.fromHubtypeCMS(hubtypeContent, this.locale); case HtNodeWithContentType.WHATSAPP_BUTTON_LIST: return FlowWhatsappButtonList.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.WHATSAPP_CTA_URL_BUTTON: return FlowWhatsappCtaUrlButtonNode.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.WHATSAPP_TEMPLATE: return FlowWhatsappTemplate.fromHubtypeCMS(hubtypeContent, this.locale); case HtNodeWithContentType.HANDOFF: return FlowHandoff.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.KNOWLEDGE_BASE: return FlowKnowledgeBase.fromHubtypeCMS(hubtypeContent); case HtNodeWithContentType.AI_AGENT: return FlowAiAgent.fromHubtypeCMS(hubtypeContent); case HtNodeWithContentType.AI_AGENT_ROUTER: return FlowAiAgentRouter.fromHubtypeCMS(hubtypeContent, this.botonicContext); case HtNodeWithContentType.RATING: return FlowRating.fromHubtypeCMS(hubtypeContent, this.locale); case HtNodeWithContentType.BOT_ACTION: return FlowBotAction.fromHubtypeCMS(hubtypeContent, this.cmsApi); case HtNodeWithContentType.FUNCTION: return this.resolveFlowFunctionContent(hubtypeContent); case HtNodeWithContentType.GO_TO_FLOW: return FlowGoToFlow.fromHubtypeCMS(hubtypeContent, this.cmsApi); case HtNodeWithContentType.CAPTURE_USER_INPUT: return FlowCaptureUserInput.fromHubtypeCMS(hubtypeContent); case HtNodeWithContentType.CUSTOM_CONDITION: return FlowCustomConditionalV2.fromHubtypeCMS(hubtypeContent, this.botonicContext); default: return undefined; } }); } resolveFlowFunctionContent(hubtypeContent) { return __awaiter(this, void 0, void 0, function* () { switch (hubtypeContent.content.action) { case 'check-country': return FlowCountryConditional.fromHubtypeCMS(hubtypeContent, this.botonicContext); case 'get-channel-type': return FlowChannelConditional.fromHubtypeCMS(hubtypeContent, this.botonicContext); case 'check-queue-status': return FlowQueueStatusConditional.fromHubtypeCMS(hubtypeContent, this.locale, this.botonicContext); case 'check-bot-variable': return FlowCustomConditional.fromHubtypeCMS(hubtypeContent, this.botonicContext); default: return undefined; } }); } } //# sourceMappingURL=flow-factory.js.map