Files
whatsappNucleo/app/plugins/agents-widget.client.ts
josedario87 cc62153393
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m0s
Fix: Usar UUID correcto del agente de WhatsApp
2025-12-10 12:57:01 -06:00

46 lines
1.3 KiB
TypeScript

export default defineNuxtPlugin(() => {
const createWidget = () => {
// Verificar que el custom element esté registrado
if (!customElements.get('chat-widget')) {
// Reintentar en 100ms si aún no está listo
setTimeout(createWidget, 100)
return
}
// Verificar que no exista ya
if (document.querySelector('chat-widget')) {
return
}
// Crear el widget flotante
const widget = document.createElement('chat-widget')
widget.setAttribute('api-url', 'https://gamdias.nucleoriofrio.com')
widget.setAttribute('agent-id', '70b046fe-0665-46b3-b896-f3c89776999a')
widget.setAttribute('app-id', 'whatsapp-app')
widget.setAttribute('user-id', 'whatsapp-user')
widget.setAttribute('title', 'Asistente WhatsApp')
// Estilo flotante en esquina inferior derecha
widget.style.cssText = `
position: fixed;
bottom: 20px;
right: 20px;
z-index: 9999;
width: 400px;
height: 600px;
max-height: 80vh;
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
border-radius: 12px;
overflow: hidden;
`
document.body.appendChild(widget)
}
if (document.readyState === 'complete') {
setTimeout(createWidget, 100)
} else {
window.addEventListener('load', () => setTimeout(createWidget, 100))
}
})