Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
trahulprabhu38 committed Oct 19, 2024
1 parent bd83a25 commit 48adfcf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
17 changes: 17 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,24 @@
/>
</head>
<body>

<div id="root"></div>

<script>
window.embeddedChatbotConfig = {
chatbotId: "rL36bLvnKl-LBrT-vmYpR",
domain: "www.chatbase.co"
}
</script>

<script
src="https://www.chatbase.co/embed.min.js"
chatbotId="rL36bLvnKl-LBrT-vmYpR"
domain="www.chatbase.co"
defer>

</script>

<script type="module" src="/src/main.jsx"></script>
</body>
</html>
30 changes: 30 additions & 0 deletions frontend/src/chatbot.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import{ useEffect } from 'react';

const Chatbot = () => {
useEffect(() => {
// Set the chatbot config
window.embeddedChatbotConfig = {
chatbotId: "rL36bLvnKl-LBrT-vmYpR",
domain: "www.chatbase.co",
};

// Create the script element to load the chatbot
const script = document.createElement('script');
script.src = "https://www.chatbase.co/embed.min.js";
script.setAttribute("chatbotId", "rL36bLvnKl-LBrT-vmYpR");
script.setAttribute("domain", "www.chatbase.co");
script.defer = true;

// Append the script to the document body
document.body.appendChild(script);

// Cleanup the script when the component unmounts
return () => {
document.body.removeChild(script);
};
}, []);

return <div id="chatbot" />;
};

export default Chatbot;

0 comments on commit 48adfcf

Please sign in to comment.