MCPcopy Create free account
hub / github.com/devs-in-tech/DevsInTech / AlanAIComponent

Function AlanAIComponent

src/pages/alan.js:5–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3const AlanAIProjectKey = `${process.env.NEXT_PUBLIC_ALAN_AI_CHATBOT}/stage`;
4
5function AlanAIComponent() {
6 useEffect(() => {
7 // Load Alan AI script asynchronously when the component mounts on the client side
8 // const additionalStyles = `
9 // .alanBtn-root {
10 // right: 2rem !important;
11 // bottom: 2rem !important;
12 // }
13 // `;
14
15 // const styleTag = document.createElement("style");
16 // styleTag.innerHTML = additionalStyles;
17 // document.head.appendChild(styleTag);
18
19 // Initialize Alan AI and handle commands once the script is loaded
20 /* global alanBtn */
21 const alanBtnInstance = alanBtn({
22 key: AlanAIProjectKey,
23 onCommand: function (commandData) {
24 if (commandData && commandData.command === "openURL") {
25 if (commandData.target === "_blank") {
26 window.open(
27 commandData.url,
28 "_newtab" + Math.floor(Math.random() * 999999)
29 );
30 } else {
31 window.location.href = commandData.url;
32 }
33 }
34 },
35 });
36
37 // Clean up the Alan AI instance when the component unmounts
38 return () => {
39 alanBtnInstance.deactivate();
40 };
41 }, []);
42
43 return (
44 <div
45 id="alan-btn"
46 className="fixed cursor-pointer bg-[#13161B] bottom-16 left-10 p-4"
47 ></div>
48 ); // This div will serve as the mount point for the Alan AI button
49}
50
51export default AlanAIComponent;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected