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}

View File

@@ -1,12 +1,8 @@
import { Lang } from "@scandic-hotels/common/constants/language"
export const CHATBOT_SHOW_ROUTES = {
[Lang.en]: [
"/customer-service", // Customer service pages
"/scandic-friends", // My pages
"/hotels", // Hotel pages
],
[Lang.sv]: [],
[Lang.en]: ["/customer-service", "/scandic-friends", "/hotels"],
[Lang.sv]: ["/kundservice", "/scandic-friends", "/hotell"],
[Lang.no]: [],
[Lang.fi]: [],
[Lang.da]: [],
@@ -21,7 +17,11 @@ export const CHATBOT_HIDE_CONDITIONS = {
"/hotels/scandic-berlin-kurfurstendamm",
"/hotels/scandic-hamburg-emporio",
],
[Lang.sv]: [],
[Lang.sv]: [
"/hotell/scandic-berlin-potsdamer-platz",
"/hotell/scandic-berlin-kurfurstendamm",
"/hotell/scandic-hamburg-emporio",
],
[Lang.no]: [],
[Lang.fi]: [],
[Lang.da]: [],

View File

@@ -1,3 +1,4 @@
import { Lang } from "@scandic-hotels/common/constants/language"
import {
removeMultipleSlashes,
removeTrailingSlash,
@@ -5,8 +6,6 @@ import {
import { CHATBOT_HIDE_CONDITIONS, CHATBOT_SHOW_ROUTES } from "./constants"
import type { Lang } from "@scandic-hotels/common/constants/language"
export function shouldShowChatbot(
pathname: string,
searchParams: URLSearchParams | null,
@@ -51,3 +50,17 @@ export function shouldShowChatbot(
return true
}
export function getChatbotKey(lang: Lang) {
switch (lang) {
case Lang.sv:
return "6008f930-ad4f-4fd2-8d7e-b58e65afe123"
case Lang.no:
case Lang.da:
case Lang.fi:
case Lang.de:
case Lang.en:
default:
return "910bd27a-7472-43a1-bcfc-955b41adc3e7"
}
}