MCPcopy Create free account
hub / github.com/AnswerOverflow/AnswerOverflow / InKeepWidget

Function InKeepWidget

packages/ui/src/pages/inkeep.tsx:8–99  ·  view source on GitHub ↗
(props: { server: ServerPublic })

Source from the content-addressed store, hash-verified

6import { makeServerIconLink } from '../server-icon';
7
8export const InKeepWidget = (props: { server: ServerPublic }) => {
9 const widgetRef = useRef<HTMLDivElement>(null);
10 const [isVisible, setIsVisible] = useState(false);
11 const theme = useTheme();
12 useEffect(() => {
13 console.log('element', document.documentElement);
14 const observer = new IntersectionObserver(
15 (entries) => {
16 const [entry] = entries;
17 if (!entry?.isIntersecting) {
18 return;
19 }
20 // Load the script only when the widget is in view
21 const script = document.createElement('script', {});
22 script.type = 'module';
23 script.src = 'https://unpkg.com/@inkeep/uikit-js@0.3.5/dist/embed.js';
24 script.defer = true;
25 script.id = 'inkeep-embed-script';
26 document.body.appendChild(script);
27
28 script.onload = () => {
29 // Initialize the Inkeep widget after the script has loaded
30 // @ts-expect-error
31 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
32 window.Inkeep().embed({
33 componentType: 'EmbeddedChat', // required
34 targetElement: document.getElementById('ikp-embedded-chat-target'), // required
35 properties: {
36 // eslint-disable-next-line n/no-process-env
37 env: process.env.NEXT_PUBLIC_DEPLOYMENT_ENV === 'production',
38 shouldAutoFocusInput: false,
39 baseSettings: {
40 apiKey: '4f4da4a5733032ef8ff23e3b7906954877fd0ee54d58d1e0',
41 integrationId: 'clpbm8p9y002ns601vbbswj5i',
42 organizationId: 'clog94xy50001s601yapu7swn',
43 organizationDisplayName: 'Drizzle ORM',
44 primaryBrandColor: '#FFFFFF',
45 colorMode: {
46 forcedColorMode: theme.theme,
47 },
48 },
49 introMessage: `Hi, I'm {{botName}} \n\n I'm an AI assistant trained on documentation, help articles, and other content. \n\n Ask me anything about {{chatSubjectName}}.`,
50 style: { visibility: 'visible' },
51 modalSettings: {},
52 searchSettings: {},
53 aiChatSettings: {
54 botAvatarSrcUrl: makeServerIconLink(props.server, 128),
55 },
56 },
57 aiChatSettings: {
58 placeholder: 'Ask me anything',
59 },
60 });
61 setIsVisible(true);
62 };
63
64 // Stop observing after loading
65 if (widgetRef.current) observer.unobserve(widgetRef.current);

Callers

nothing calls this directly

Calls 1

makeServerIconLinkFunction · 0.90

Tested by

no test coverage detected