Feat: Integrar widget de chat de agentes
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m39s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 1m39s
- 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
This commit is contained in:
37
app/plugins/agents-widget.client.ts
Normal file
37
app/plugins/agents-widget.client.ts
Normal file
@@ -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))
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -39,6 +39,9 @@ export default defineNuxtConfig({
|
|||||||
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
||||||
{ name: 'mobile-web-app-capable', content: 'yes' },
|
{ name: 'mobile-web-app-capable', content: 'yes' },
|
||||||
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' }
|
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' }
|
||||||
|
],
|
||||||
|
script: [
|
||||||
|
{ src: 'https://gamdias.nucleoriofrio.com/widget.js', defer: true }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user