This guide will walk you through integrating the Mingleego chatbot into a React project. React is a popular JavaScript library for building user interfaces, developed by Facebook. This guide works with React projects created using Create React App, Vite, or other React build tools.
Note for Complete Beginners: If you don't have a React project yet, you'll need to create one first. This guide assumes you already have a React project set up. To create a new React project, follow one of these official guides:
Both guides include detailed instructions on how to compile and run your project, so make sure to complete the project creation process before proceeding with the chatbot integration steps below.
What you're doing: You need to get the chatbot script file and put it in the right location in your React project.
Download the Script File:
mingleego-chatbot-script.js or similar)
Find Your React Project's Public Directory:
public (it should be at the root level of your project, same level as src, node_modules, etc.)Copy the Script File:
Copy the downloaded mingleego-chatbot-script.js file
Paste it directly into the public folder
Your file structure should now look like this:
your-react-project/
├── public/
│ ├── mingleego-chatbot-script.js ← Your chatbot script goes here
│ └── index.html
├── src/
├── node_modules/
└── package.json
Important: Make sure the file is directly inside the public folder, not in a subfolder. The exact name of your script file might be different (like mingleego-web-chat-bot.js or something similar) - that's fine, just remember the exact filename because you'll need it in the next step.
What you're doing: You need to tell your React app to load the chatbot script when the page loads. This is done in the main HTML file.
Locate the index.html File:
index.html filepublic folderFind the <head> Section:
index.html, you'll see HTML code<head> (it should be near the top, after <!DOCTYPE html> and <html>)<head> section contains metadata about your page and usually has tags like <title>, <meta>, and possibly other <script> tagsAdd the Script Tag:
Inside the <head> section, add this line:
1
Important: Replace mingleego-chatbot-script.js with the actual name of your script file (the one you copied to the public folder)
The / at the beginning means "start from the root of the public folder"
The defer attribute tells the browser to load the script after the HTML is parsed (this is good for performance)
What Your index.html Should Look Like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Troubleshooting: If your script file has a different name (like mingleego-web-chat-bot.js), make sure the src attribute matches exactly, including capitalization. File names are case-sensitive on some systems.
What you're doing: Now you need to actually place the chatbot on your page. There are several approaches depending on your project complexity.
App.jsx (chatbot on all pages)This is the standard approach for most simple React projects:
Locate Your App.jsx or App.js File:
src folderApp.jsx (or App.js if you're not using JSX extension)Add the Chatbot Element:
Inside your component's return statement, add <mingleego-webchat></mingleego-webchat>
You can place it anywhere in your JSX - typically at the end, just before the closing </div> tag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Important Notes:
<mingleego-webchat> element is a custom HTML element (also called a Web Component) that the chatbot script creates<mingleego-webchat></mingleego-webchat>index.html outside React root (recommended for apps with sidebars, modals, or navigation)If your React app has complex UI elements like sidebars, modal dialogs, toast notifications, or navigation with high z-index values, placing the chatbot inside the React component tree can cause it to appear visually but be unclickable — it gets buried under other elements.
The solution is to place <mingleego-webchat> directly in index.html, outside of <div id="root"> where React renders:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Why this works: When <mingleego-webchat> is inside <div id="root">, it shares the same stacking context as the rest of your app. Other elements like a sidebar with z-index: 1001 or a modal overlay can cover the chatbot button even if it's visually floating in the corner. Placing it outside <div id="root"> puts the chatbot at the same level as the React app itself — no conflicts possible.
When to use this approach:
z-index higher than 1000Use this option when you want the chatbot to appear only on certain pages, not on every page of your site.
How it works in plain terms: React's createPortal is a way to say "render this element at the very top of the page's HTML, not inside my component". The chatbot will appear when the user opens that specific page and disappear automatically when they navigate away — you don't need to write any cleanup code.
1. Find the page file where you want the chatbot
Your React project's pages are usually inside the src/pages/ folder (sometimes src/views/ or src/screens/). For example:
your-react-project/
├── public/
│ └── mingleego-chatbot-script.js
├── src/
│ ├── pages/
│ │ ├── HomePage.jsx ← no chatbot here
│ │ ├── ContactPage.jsx ← we want chatbot here ✅
│ │ └── AboutPage.jsx ← no chatbot here
│ └── App.jsx
└── index.html
Open the file where you want the chatbot to appear (e.g. ContactPage.jsx) in your code editor.
2. Add the import line at the top of the file
At the very top of the file, you will see other import lines. Add this line together with them:
1
3. Add the chatbot element inside the component's return
Find the return ( statement in the file. It contains the page's HTML structure. Add the chatbot at the end, just before the last closing tag:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
What <> </> means: These empty tags (called a Fragment) let you return multiple elements from a component without adding an extra <div> to the page. If your existing code already has <> </> or <React.Fragment>, just add the createPortal block inside it.
4. Repeat for other pages if needed
If you want the chatbot on multiple specific pages, repeat steps 1–3 for each page file. Each page manages its own copy — the chatbot appears when that page is open and is removed when the user leaves.
Important: Do not add the chatbot to App.jsx if you are using this option, otherwise it will appear on all pages.
.tsx / .ts)TypeScript is a stricter version of JavaScript that checks your code for errors before it runs. When you write <mingleego-webchat> in a .tsx file, TypeScript will show a red error because it doesn't know what that element is. You need to tell TypeScript about it by creating a special declaration file.
Note: If you used Option B (placing the element in index.html), you can skip Option D entirely — index.html is plain HTML and TypeScript does not check it.
1. Create the types folder (if it doesn't exist)
In your src/ folder, create a subfolder called types:
your-react-project/
├── src/
│ ├── types/ ← create this folder
│ │ └── (empty)
│ ├── pages/
│ └── App.tsx
2. Create the declaration file
Inside src/types/, create a new file called custom-elements.d.ts (the .d.ts extension means it's a TypeScript declaration file — a file that only describes types, contains no real code):
src/
└── types/
└── custom-elements.d.ts ← create this file
Open the file and paste this content exactly as-is:
1 2 3 4 5 6 7 8
What this does: It tells TypeScript "the HTML element called mingleego-webchat is valid and it accepts standard HTML attributes". You never need to edit this file again.
3. Use the element normally in any .tsx file
After saving the declaration file, the red error will disappear and you can use the element in any page:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Tip: If TypeScript still shows an error after creating the file, try restarting your code editor (VS Code). Sometimes it needs a restart to pick up new declaration files.
What you're doing: Now you need to start your React app and make sure everything works correctly.
Start Your Development Server:
cd command:
1
npm run devnpm startnpm start first, and if that doesn't work, try npm run devOpen Your App in the Browser:
Verify the Chatbot Appears:
![]()

Common Issues and Solutions:
Problem: The chatbot doesn't appear at all
index.html exactly matches the file name in your public folder (check for typos and capitalization)<head> section, not the <body>Problem: The chatbot button is visible but cannot be clicked
z-index than the chatbot and cover it even if it looks clickable<mingleego-webchat> out of the React component tree. Place it directly in index.html after <div id="root"> but before </body> (see Option B above). This puts the chatbot at the document root level, outside any React stacking contextProblem: The chatbot appears but doesn't respond to messages
Problem: The chatbot appears in the wrong place or looks broken
Build for Production (Optional):
npm run build (or npm run build:prod depending on your setup)public folder will automatically be included in the build
Choose the right approach based on your project:
| Your situation | Recommended approach |
|---|---|
| Simple React app, chatbot on all pages | Option A — add to App.jsx |
| Complex app with sidebar / modals / high z-index elements | Option B — place in index.html outside <div id="root"> |
| Chatbot only on specific pages | Option C — use createPortal in the page component |
| TypeScript project | Add type declaration file + use any option above |
To recap, integrating the Mingleego chatbot into your React project involves:
public folder<script> tag in your index.html file's <head> section<mingleego-webchat></mingleego-webchat> element using the approach that fits your projectOnce these steps are complete, your chatbot should be live and ready to interact with your website visitors!