From 79461feeef4b07b8acc3bfabcbd7f21423a4ee3e Mon Sep 17 00:00:00 2001 From: Stefano Rosanelli Date: Wed, 27 Nov 2024 15:35:12 +0100 Subject: [PATCH] Add chatbot iframe page to embed in external apps/websites (#29) * chore: initial chatbot iframe page * feat: use uuid in path + avoid login check * chore: typo + unused vars * feat: adding Layout control * feat: adding ChatZone component * fix: define page meta missing on iframe * feat: iframe chatbot full screen + prettier fix * feat: add iframe visibility settings via `brevia_app.public_iframe` * Fix: Eslint and Embedded Chatbar fixed on bottom * fix: prettier * Fix: adding scrolling chat when embedded * fix: prettier * fix: position absolute disappeared * feat: adding auto scroll on submit and response * fix: prettier + eslint --------- Co-authored-by: Davide Rovai --- app.vue | 12 +- components/ChatZone.vue | 267 +++++++++++++++++++++++++++ components/Form/ChatbotAdvanced.vue | 19 ++ layouts/default.vue | 13 ++ layouts/iframe.vue | 12 ++ middleware/auth.global.ts | 2 +- pages/chatbot-iframe/[uuid].vue | 50 +++++ pages/chatbot/[id].vue | 246 ++---------------------- server/api/brevia/collections.get.ts | 7 +- 9 files changed, 384 insertions(+), 244 deletions(-) create mode 100644 components/ChatZone.vue create mode 100644 layouts/default.vue create mode 100644 layouts/iframe.vue create mode 100644 pages/chatbot-iframe/[uuid].vue diff --git a/app.vue b/app.vue index 87e70a3..1519f2c 100644 --- a/app.vue +++ b/app.vue @@ -1,15 +1,8 @@ diff --git a/server/api/brevia/collections.get.ts b/server/api/brevia/collections.get.ts index 1e51223..4773d38 100644 --- a/server/api/brevia/collections.get.ts +++ b/server/api/brevia/collections.get.ts @@ -1,7 +1,12 @@ export default defineEventHandler(async (event) => { const query = getQuery(event); + let url = '/collections'; + if (query.uuid) { + url += `/${query.uuid}`; + delete query.uuid; + } try { - const response: any = await $fetch(apiUrl('/collections'), { + const response: any = await $fetch(apiUrl(url), { headers: authorizationHeaders(), query, });