Widget Integration Guide
Learn how to integrate Myndy AI widget into your website
Widget Integration Guide
This guide will help you integrate the Myndy AI widget into your website to provide instant AI-powered assistance to your visitors.
Prerequisites
Before you begin, make sure you have:
- An active Myndy account
- A created AI agent
- Access to your website's HTML code
Installation Steps
Step 1: Get Your Widget Code
- Navigate to your agent dashboard
- Click on the "Widget" tab
- Copy the widget embed code provided
Step 2: Add Widget to Your Website
Add the following code snippet to your website, just before the closing </body> tag:
<script>
(function(w,d,s,o,f,js,fjs){
w['MyndyWidget']=o;w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
js.id = o; js.src = f; js.async = 1; fjs.parentNode.insertBefore(js, fjs);
}(window, document, 'script', 'mw', 'https://widget.myndy.ai/widget.js'));
mw('init', { agentId: 'YOUR_AGENT_ID' });
</script>Step 3: Configure Widget Settings
You can customize the widget appearance and behavior:
mw('init', {
agentId: 'YOUR_AGENT_ID',
position: 'bottom-right', // or 'bottom-left'
theme: 'light', // or 'dark'
primaryColor: '#007bff',
welcomeMessage: 'Hi! How can I help you today?'
});Customization Options
Position
bottom-right(default)bottom-lefttop-righttop-left
Theme
light- Light theme with white backgrounddark- Dark theme with dark background
Colors
Customize the widget colors to match your brand:
{
primaryColor: '#007bff',
textColor: '#333333',
backgroundColor: '#ffffff'
}Advanced Features
Custom Triggers
You can trigger the widget programmatically:
// Open the widget
mw('open');
// Close the widget
mw('close');
// Send a message
mw('sendMessage', 'Hello!');Event Listeners
Listen to widget events:
mw('on', 'open', function() {
console.log('Widget opened');
});
mw('on', 'close', function() {
console.log('Widget closed');
});
mw('on', 'message', function(message) {
console.log('Message received:', message);
});Troubleshooting
Widget Not Appearing
- Check if the script is loaded correctly
- Verify your agent ID is correct
- Ensure there are no JavaScript errors in the console
Widget Not Responding
- Check your internet connection
- Verify your agent is active and published
- Check the browser console for errors
Support
If you need help with widget integration, please contact our support team or visit the support page.