document.addEventListener("DOMContentLoaded", () => {
const inkeepScript = document.createElement("script");
inkeepScript.src = "https://unpkg.com/@inkeep/uikit-js@0.3.18/dist/embed.js";
inkeepScript.type = "module";
inkeepScript.defer = true;
document.head.appendChild(inkeepScript);
const inkeepDiv = document.createElement("div");
inkeepDiv.id = "inkeepSearchBar";
const headerElement = document.querySelector("#navbar-collapse");
if (headerElement) {
headerElement.appendChild(inkeepDiv);
}
const addInkeepWidget = (componentType, targetElementId) => {
const inkeepWidget = Inkeep().embed({
componentType,
...(componentType !== "ChatButton"
? { targetElement: targetElementId }
: {}),
colorModeSync: {
observedElement: document.documentElement,
isDarkModeCallback: (el) => {
const currentTheme = el.getAttribute("data-color-mode");
return currentTheme === "dracula" || currentTheme === "dark";
},
colorModeAttribute: "data-color-mode-scheme",
},
properties: {
baseSettings: {
apiKey: "INKEEP_API_KEY",
integrationId: "INKEEP_INTEGRATION_ID",
organizationId: "INKEEP_ORGANIZATION_ID",
primaryBrandColor: "#26D6FF",
organizationDisplayName: "Inkeep",
theme: {
},
},
modalSettings: {
},
searchSettings: {
},
aiChatSettings: {
botAvatarSrcUrl: "https://mydomain.com/mylogo",
quickQuestions: [
"Example question 1?",
"Example question 2?",
"Example question 3?",
],
},
},
});
};
inkeepScript.addEventListener("load", () => {
const widgetContainer = document.getElementById("inkeepSearchBar");
addInkeepWidget("ChatButton");
widgetContainer && addInkeepWidget("SearchBar", "#inkeepSearchBar");
});
});