UNPKG

@botonic/plugin-flow-builder

Version:

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

46 lines 2.25 kB
import { __awaiter } from "tslib"; import { MessageType } from '@botonic/shared'; import { EMPTY_PAYLOAD } from '../constants'; import { inputHasTextOrTranscript } from '../utils'; import { getContentsByAiAgentFromUserInput } from './ai-agent-from-user-input'; import { getFlowBuilderActionContext } from './context'; import { getContentsByFallback } from './fallback'; import { getContentsByFirstInteraction } from './first-interaction'; import { getContentsByKnowledgeBase } from './knowledge-bases'; import { getContentsByPayload } from './payload'; export function getContents(botonicContext, contentID) { return __awaiter(this, void 0, void 0, function* () { var _a; const context = getFlowBuilderActionContext(botonicContext, contentID); if (botonicContext.session.isFirstInteraction) { return yield getContentsByFirstInteraction(context); } // TODO: We need to add MessageType.EventQueuePositionChanged for BotonicV2 in the backend // TODO: Add needed logic when we can define contents for multi locale queue position message if (botonicContext.input.type === MessageType.EventQueuePositionChanged) { return []; } if ((_a = botonicContext.input.payload) === null || _a === void 0 ? void 0 : _a.startsWith(EMPTY_PAYLOAD)) { botonicContext.input.payload = undefined; } if (botonicContext.input.payload || contentID) { const contentsByPayload = yield getContentsByPayload(context); if (contentsByPayload.length > 0) { return contentsByPayload; } return yield getContentsByFallback(context); } if (inputHasTextOrTranscript(botonicContext.input)) { const aiAgentContents = yield getContentsByAiAgentFromUserInput(context); if (aiAgentContents.length > 0) { return aiAgentContents; } const knowledgeBaseContents = yield getContentsByKnowledgeBase(context); if (knowledgeBaseContents.length > 0) { return knowledgeBaseContents; } } return yield getContentsByFallback(context); }); } //# sourceMappingURL=get-contents.js.map