Skip to content

Commit

Permalink
cookbook integration (#1912)
Browse files Browse the repository at this point in the history
  • Loading branch information
owenwahlgren authored Oct 16, 2024
1 parent 78b579b commit 288f294
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function Layout({ children }: { children: ReactNode }) {
<RootProvider>{children}</RootProvider>
<Analytics />
<SpeedInsights />
<Chatbot websiteId="84b0d351-622f-46b4-80c9-f1d9850e34b6" projectName="AvaGPT" projectColor="#e84142" projectLogo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANEAAADQCAYAAACZZoRKAAAQHUlEQVR4nO2dPVBc1xXHrySMrQ9LJClWnZhBPaSWZqTZnYncmZjUARVxZqIGuZBKk6SyC3lTOEVSiE0d2aizMgOBmbg29GICnbZwImRJthVpyJzlPHjsfbv7Pu7Huff9fzMM6D1WLLA/zrnn3nvuif39fQXs0222ZpRSE0qp5P0kvyl+f6nkk9hSSj3ljzf5453krbG2uqM9AhgFEhmGZZlhMa5XFMQUWywVSbZO7xtrq0/dfOn4gUQV6DZbEyzKDL+/FtDT301Jtd5YW93UPgPkAhIVpNtskSyzLM10UE9+OHuJUJCqGJBoBBxtZlPiXBj+iGigSLXCQq3U5HsuBSTKoE+c9/XPqB17LNRyY211ve4/jH4gUQpO1RaUUvPaTZCQRKg2Kn8H1F4ijjqLLI/vKlpobHB0Wq7zD6G2EnEpehFRxwiU7rU5OtWudF47iThlWwqsHB0SHfr51inVq41E3WZrgSNPTGVpydRGpugl4sjThjzeiF6maCVC2iYOkmkxxjFTdBJ1m61JlgcFA3nscfFhKaZvKiqJus3WEo976rKqIFR2OSpFsRIiCok4dVvGPE9wPGSZgh4vBS0RT5QuY2lO0Oxx4aEd6jcRrETdZmuWBULqFge0+mEhxKgUnEQcfdooHERJkFEpKIl4qc4Kxj7R85CjUhDl8JPaFaFw5e0bCFQLaIy7wwUj8Yi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4/Vrdw2CFYihaJDLAQZfdIELVFCt9m6zjJhrBQWD7kPQnDRJ00UEiVwBW8RKZ54dlkeY03lfRKVROpApEk+SxaFB3lQ6tbmFSnREJ1ECZzi0S/rmnYT+KBj4mhHiUQrUQLL1EarLm90uHAQ9LhnGNFLlNBtthZ4vASZ3BC9PAm1kSgBaZ51aiNPQu0kSuAlRIsoQBhhj1PmdoxjnlHUVqIEnrBd5CMIMc9UDFplsCxtk5xrai9RGk71FhCdhrLLi4DbdUrZhgGJMuDoNMtvWFJ0kK6tcNQRvzXBNZBoBH1CXa/Raogk4qzHsrLAFpCoIJzyJULFVC6naLOevEnsZSAVSFQBjlIk0wy/D6lsTpFmE9JUBxIZhkvn9DbJYk0KqPpRp5ydlDSbdSxF2wISOYLlmmDBJliuSf7qVUQjQRIhNvnjneQNFTTLKKX+D7rIQEhQx22LAAAAAElFTkSuQmCC" />
<Chatbot />
</body>
</PHProvider>
</html>
Expand Down
42 changes: 16 additions & 26 deletions components/chatbot.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
"use client";
import React, { useEffect } from 'react';

interface KapaWidgetProps {
websiteId: string;
projectName: string;
projectColor: string;
projectLogo: string;
}

const Chatbot: React.FC<KapaWidgetProps> = ({ websiteId, projectName, projectColor, projectLogo }) => {
const COOKBOOK_API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2NmJlNDZhZDZkMjk4YjBkZjY5OWExMTgiLCJpYXQiOjE3MjM3NDU5NjUsImV4cCI6MjAzOTMyMTk2NX0.YRFXnhY4r8Z3it93zRzBenOL3oBPtD96tGYYl-USX2o"
const Chatbot: React.FC = () => {
useEffect(() => {
const script = document.createElement("script");
script.src = "https://widget.kapa.ai/kapa-widget.bundle.js";
script.setAttribute("data-website-id", websiteId);
script.setAttribute("data-project-name", projectName);
script.setAttribute("data-project-color", projectColor);
script.setAttribute("data-project-logo", projectLogo);
script.setAttribute("data-user-analytics-fingerprint-enabled", "true");
script.async = true;
document.head.appendChild(script);

return () => {
if (document.head.contains(script)) {
document.head.removeChild(script);
if (typeof document !== 'undefined') {
let script = document.getElementById('__cookbook-script') as HTMLScriptElement | null;
if (!script) {
script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/@cookbookdev/docsbot/dist/standalone/index.cjs.js';
script.id = '__cookbook-script';
script.async = true;
document.body.appendChild(script);
}
};
}, [websiteId, projectName, projectColor, projectLogo]);
}
}, []);

return null;
return (
<div id="__cookbook" data-api-key={COOKBOOK_API_KEY} />
);
};

export default Chatbot;

export default Chatbot;

0 comments on commit 288f294

Please sign in to comment.