@botonic/plugin-flow-builder
Version:
Use Flow Builder to show your contents
49 lines • 2.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlowAiAgent = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const tracking_1 = require("../tracking");
const content_fields_base_1 = require("./content-fields-base");
const flow_carousel_1 = require("./flow-carousel");
const flow_text_1 = require("./flow-text");
class FlowAiAgent extends content_fields_base_1.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 tslib_1.__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 (0, tracking_1.trackOneContent)(request, this);
});
}
toBotonic(id, request) {
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: this.responses.map((response) => {
if (response.type === 'text' || response.type === 'textWithButtons') {
return flow_text_1.FlowText.fromAIAgent(id, response);
}
if (response.type === 'carousel') {
return flow_carousel_1.FlowCarousel.fromAIAgent(id, response, request);
}
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
}) }));
}
}
exports.FlowAiAgent = FlowAiAgent;
//# sourceMappingURL=flow-ai-agent.js.map