UNPKG

@botonic/plugin-flow-builder

Version:

Use Flow Builder to show your contents

45 lines 1.91 kB
import { __awaiter } from "tslib"; import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; import { trackOneContent } from '../tracking'; import { ContentFieldsBase } from './content-fields-base'; import { FlowCarousel } from './flow-carousel'; import { FlowText } from './flow-text'; export class FlowAiAgent extends ContentFieldsBase { constructor() { super(...arguments); this.name = ''; this.instructions = ''; this.responses = []; } static fromHubtypeCMS(component) { const newAiAgent = new FlowAiAgent(component.id); newAiAgent.code = component.code; newAiAgent.name = component.content.name; newAiAgent.instructions = component.content.instructions; newAiAgent.activeTools = component.content.active_tools; newAiAgent.inputGuardrailRules = component.content.input_guardrail_rules || []; newAiAgent.sources = component.content.sources; newAiAgent.followUp = component.follow_up; return newAiAgent; } trackFlow(request) { return __awaiter(this, void 0, void 0, function* () { // We can call trackFlowContent here but the function no track events for AiAgent contents // Review how we can track here the ai agent event yield trackOneContent(request, this); }); } toBotonic(id, request) { return (_jsx(_Fragment, { children: this.responses.map((response) => { if (response.type === 'text' || response.type === 'textWithButtons') { return FlowText.fromAIAgent(id, response); } if (response.type === 'carousel') { return FlowCarousel.fromAIAgent(id, response, request); } return _jsx(_Fragment, {}); }) })); } } //# sourceMappingURL=flow-ai-agent.js.map