feat(BOOK-577): Added chatbot functionality for SE

Approved-by: Bianca Widstam
This commit is contained in:
Erik Tiekstra
2025-11-24 14:18:35 +00:00
parent 091c1c3780
commit 2346daec25
3 changed files with 30 additions and 15 deletions

View File

@@ -4,7 +4,10 @@ import { usePathname, useSearchParams } from "next/navigation"
import Script from "next/script"
import { useEffect } from "react"
import { shouldShowChatbot } from "@/components/ChatbotScript/utils"
import {
getChatbotKey,
shouldShowChatbot,
} from "@/components/ChatbotScript/utils"
import useLang from "@/hooks/useLang"
interface ChatbotClientProps {
@@ -15,10 +18,9 @@ export function ChatbotClient({ liveLangs }: ChatbotClientProps) {
const lang = useLang()
const pathname = usePathname()
const searchParams = useSearchParams()
const currentLang = useLang()
const isLive = liveLangs.includes(currentLang)
const shouldShow =
isLive && shouldShowChatbot(pathname, searchParams, currentLang)
const isLive = liveLangs.includes(lang)
const shouldShow = isLive && shouldShowChatbot(pathname, searchParams, lang)
const chatbotKey = getChatbotKey(lang)
useEffect(() => {
window.kindlyOptions = {
@@ -53,7 +55,7 @@ export function ChatbotClient({ liveLangs }: ChatbotClientProps) {
<Script
id="kindly-chat"
src="https://chat.kindlycdn.com/kindly-chat.js"
data-bot-key="910bd27a-7472-43a1-bcfc-955b41adc3e7"
data-bot-key={chatbotKey}
data-shadow-dom
data-bubble-hidden={!shouldShow}
data-language={lang}