UNPKG

@botonic/plugin-flow-builder

Version:

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

51 lines 2.05 kB
import { __awaiter, __rest } from "tslib"; import { BotonicAction } from '@botonic/core'; import { EventAction } from '@botonic/shared'; import { getCommonFlowContentEventArgsForContentId, trackEvent, } from '../tracking'; import { ContentFieldsBase } from './content-fields-base'; export class FlowBotAction extends ContentFieldsBase { constructor() { super(...arguments); this.payload = ''; } static fromHubtypeCMS(cmsBotAction, cmsApi) { const newBotAction = new FlowBotAction(cmsBotAction.id); newBotAction.code = cmsBotAction.code; newBotAction.payload = cmsApi.createPayloadWithParams(cmsBotAction); newBotAction.followUp = cmsBotAction.follow_up; return newBotAction; } trackFlow(botonicContext) { return __awaiter(this, void 0, void 0, function* () { const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } = yield getCommonFlowContentEventArgsForContentId(botonicContext, this.id); const event = { action: EventAction.BotAction, flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId, flowNodeIsMeaningful: false, payload: this.payload, }; const { action } = event, eventArgs = __rest(event, ["action"]); yield trackEvent(botonicContext, action, eventArgs); }); } doBotAction(botonicContext) { botonicContext.session.botonicAction = `${BotonicAction.Redirect}:${this.payload}`; } processContent(botonicContext) { return __awaiter(this, void 0, void 0, function* () { this.doBotAction(botonicContext); yield this.trackFlow(botonicContext); return this.filterContent(botonicContext, this); }); } toBotonic() { return __awaiter(this, void 0, void 0, function* () { return; }); } } //# sourceMappingURL=flow-bot-action.js.map