From e7cf999da2d27b963f657f3153688e07889352c5 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Wed, 10 Dec 2025 12:32:56 -0600 Subject: [PATCH] Feat: Integrar widget de chat de agentes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Agregar script externo del widget desde gamdias.nucleoriofrio.com - Crear plugin client-side para inicializar AgentsChatWidget - Configurar widget con tema dark y color WhatsApp (#25D366) - Usuario Ășnico whatsapp-user para todas las conversaciones --- app/plugins/agents-widget.client.ts | 37 +++++++++++++++++++++++++++++ nuxt.config.ts | 3 +++ 2 files changed, 40 insertions(+) create mode 100644 app/plugins/agents-widget.client.ts diff --git a/app/plugins/agents-widget.client.ts b/app/plugins/agents-widget.client.ts new file mode 100644 index 0000000..9a7c200 --- /dev/null +++ b/app/plugins/agents-widget.client.ts @@ -0,0 +1,37 @@ +declare global { + interface Window { + AgentsChatWidget?: { + init: (config: { + serverUrl: string + agentSlug: string + appId: string + externalUserId?: string + position?: 'bottom-right' | 'bottom-left' + theme?: 'dark' | 'light' + primaryColor?: string + }) => void + } + } +} + +export default defineNuxtPlugin(() => { + const initWidget = () => { + if (window.AgentsChatWidget) { + window.AgentsChatWidget.init({ + serverUrl: 'https://gamdias.nucleoriofrio.com', + agentSlug: 'whatsapp-agent', + appId: 'whatsapp-app', + externalUserId: 'whatsapp-user', + position: 'bottom-right', + theme: 'dark', + primaryColor: '#25D366' + }) + } + } + + if (document.readyState === 'complete') { + setTimeout(initWidget, 100) + } else { + window.addEventListener('load', () => setTimeout(initWidget, 100)) + } +}) diff --git a/nuxt.config.ts b/nuxt.config.ts index 8425bc2..50ae733 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -39,6 +39,9 @@ export default defineNuxtConfig({ { name: 'apple-mobile-web-app-capable', content: 'yes' }, { name: 'mobile-web-app-capable', content: 'yes' }, { name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' } + ], + script: [ + { src: 'https://gamdias.nucleoriofrio.com/widget.js', defer: true } ] } },