UNPKG

@botonic/plugin-flow-builder

Version:

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

52 lines 2.2 kB
import { __awaiter, __rest } from "tslib"; import { EventAction } from '@botonic/shared'; import { getCommonFlowContentEventArgsForContentId, trackEvent, } from '../tracking'; import { ContentFieldsBase } from './content-fields-base'; export class FlowGoToFlow extends ContentFieldsBase { constructor() { super(...arguments); this.flowTargetId = ''; this.flowTargetName = ''; this.targetId = ''; } static fromHubtypeCMS(component, cmsApi) { const newGoToFlow = new FlowGoToFlow(component.id); newGoToFlow.code = component.code; newGoToFlow.flowTargetId = component.content.flow_id; const targetId = cmsApi.getNodeByFlowId(component.content.flow_id).id; newGoToFlow.targetId = targetId; newGoToFlow.flowTargetName = cmsApi.getFlowName(component.content.flow_id); newGoToFlow.followUp = cmsApi.getNodeById(targetId); return newGoToFlow; } trackFlow(botonicContext) { return __awaiter(this, void 0, void 0, function* () { const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } = yield getCommonFlowContentEventArgsForContentId(botonicContext, this.id); const eventGoToFlow = { action: EventAction.RedirectFlow, flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId: flowNodeContentId || 'Go to flow', flowTargetId: this.flowTargetId, flowTargetName: this.flowTargetName, flowNodeIsMeaningful: false, }; const { action } = eventGoToFlow, eventArgs = __rest(eventGoToFlow, ["action"]); yield trackEvent(botonicContext, action, eventArgs); }); } processContent(botonicContext) { return __awaiter(this, void 0, void 0, function* () { yield this.trackFlow(botonicContext); return this.filterContent(botonicContext, this); }); } toBotonic() { return __awaiter(this, void 0, void 0, function* () { return; }); } } //# sourceMappingURL=flow-go-to-flow.js.map