UNPKG

plazbot

Version:

Official Plazbot SDK for creating AI agents for WhatsApp, portals, and developers.

39 lines (38 loc) 1.63 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { ContactCard } from './ContactCard'; import { EventCard } from './EventCard'; import { AvailabilityCard } from './AvailabilityCard'; import { ServiceResultCard } from './ServiceResultCard'; import { ActionCard } from './ActionCard'; import { GenericCard } from './GenericCard'; const actionIntents = ['tag', 'asign', 'stage', 'segmentation', 'solved', 'agentshutdown']; function matchesAny(intent, keywords) { const lower = intent.toLowerCase(); return keywords.some((k) => lower.includes(k)); } export function ToolResultRenderer({ action, customRenderers, style }) { const intent = action.intent ?? ''; // Custom renderer tiene prioridad if (customRenderers?.[intent]) { const Custom = customRenderers[intent]; return _jsx(Custom, { action: action }); } // Dispatch por intent if (matchesAny(intent, ['contact'])) { return _jsx(ContactCard, { action: action, style: style }); } if (matchesAny(intent, ['availability', 'slot', 'disponibilidad'])) { return _jsx(AvailabilityCard, { action: action, style: style }); } if (matchesAny(intent, ['event', 'appointment', 'cita', 'schedule', 'calendar'])) { return _jsx(EventCard, { action: action, style: style }); } if (matchesAny(intent, actionIntents)) { return _jsx(ActionCard, { action: action, style: style }); } if (matchesAny(intent, ['service_'])) { return _jsx(ServiceResultCard, { action: action, style: style }); } // Fallback return _jsx(GenericCard, { action: action, style: style }); }