sg-chatbot-ui v0.0.14
Here's the revised README format with your requested changes:
SG Chatbot UI Integration
Follow these steps to set up the SG Chatbot UI in a React.js or Next.js project.
Step 1: Install the Package
npm install sg-chatbot-ui
React.js Setup
Import and Define Custom Elements
Add the following lines in yourApp.js
file:import { defineCustomElements } from 'sg-chatbot-ui/loader'; defineCustomElements(window);
Use the Custom Element
Add the<chatbot-ui>
component at the bottom ofApp.js
:<chatbot-ui></chatbot-ui>
Set Server URL
In your.env
file, add the server URL and update it with your current base URL:REACT_APP_SERVER_URL=https://sentientgeeks.com
Next.js Setup
Import and Define Custom Elements in app route or
InApp.js
, import and define the custom elements conditionally within auseEffect
hook:import { useEffect } from 'react'; import { defineCustomElements } from 'sg-chatbot-ui/loader'; useEffect(() => { if (typeof window !== "undefined") { defineCustomElements(window); } }, []);
Import and Define Custom Elements in page route
InApp.js
, import and define the custom elements conditionally within auseEffect
hook:import { useEffect } from 'react'; useEffect(() => { if (typeof window !== "undefined") { import("sg-chatbot-ui/loader").then((module) => { module.defineCustomElements(window); }); } }, []);
Declare Custom Element in TypeScript
Inside thesrc
folder, create a file namedglobal.d.ts
to declare thechatbot-ui
component:declare namespace JSX { interface IntrinsicElements { "chatbot-ui": React.DetailedHTMLProps< React.HTMLAttributes<HTMLElement>, HTMLElement >; } }
Use the Custom Element
Add the<chatbot-ui>
component at the bottom ofpage.tsx
:<chatbot-ui></chatbot-ui>
Set Server URL
In your.env
file, add the server URL and update it with your current base URL:NEXT_PUBLIC_SERVER_URL=https://sentientgeeks.com
With these steps, you should have the SG Chatbot UI integrated and ready to use in your application!