JavaScript Widget
Install the chat widget with the complete code generated in Channels.
The JavaScript widget adds a floating chat bubble to your website. Its generated embed code has two script tags; copy both from your agent's Channels page.
Quick Setup
- Open your agent's Channels → Website embed page
- Select Chat widget and enable the channel
- Copy the complete generated code, including both script tags
- Paste it into your website before
</body> - Save and refresh your website
The first tag prepares the Agentkit command queue. The second loads the widget with your agent ID and configured script URL. Keep both tags and their values together.
Widget Configuration
Position
The widget appears in the bottom-right corner by default. Change position in Design settings.
Colors
Widget colors match your agent's theme settings. Customize in Design tab.
Mobile
The widget is fully responsive and works on mobile devices automatically.
File Attachments
Visitors can attach documents, spreadsheets, images, and text files directly from the widget. Attachments are used only as temporary conversation context and are not added to your agent's training sources.
Supported uploads include PDF, Word, Excel, HTML, TXT, Markdown, JSON, CSV, PNG, JPG, WEBP, and GIF files. Visitors can attach up to 3 files per message, with a 10MB limit per file. PDFs are parsed up to the first 20 pages to keep responses fast and reliable.
Data Attributes
The widget uses data attributes for configuration:
| Attribute | Description | Default |
|---|---|---|
data-chatbot | Required. Your agent's ID (included in your embed code) | - |
Placement
Where to Add the Code
Paste both generated script tags before </body>:
<!DOCTYPE html> <html> <head> <!-- Your head content --> </head> <body> <!-- Your website content --> <!-- Paste both script tags from Channels > Website embed here --> </body> </html>
Single Page Applications
For SPAs, add the complete generated code to your main HTML template or index file.
Multiple Pages
Add the same generated code to every page where you want the widget, or place it in a shared layout template.
Testing Your Installation
After adding the code:
- Visit your website in a browser
- Look for the chat bubble (bottom-right by default)
- Click to open the chat
- Send a test message
- Verify the response is correct
Troubleshooting
Widget not appearing:
- Check that both generated script tags appear before
</body>in the rendered page source - Verify the agent ID is correct
- Clear browser cache
- Check browser console for errors
Wrong position:
- Check Design settings
- Look for CSS conflicts
Not responding:
- Ensure training content exists
- Check plan message limits
- Test in Playground first
Domain Restrictions
If you've configured allowed domains:
- Widget only loads on approved domains
- Other sites see no widget (no error shown)
Performance
The widget is optimized for minimal impact:
- Loads asynchronously (
asyncattribute) - Small bundle size
- No render blocking
- Lazy loads chat interface
Styling Conflicts
The widget uses isolated styles and shouldn't conflict with your site. If you see issues:
- Check for global CSS selectors
- Look for
!importantrules - Contact support if problems persist
Removing the Widget
To remove:
- Remove both generated script tags from your HTML
- Clear any caches
- The widget disappears immediately
Next Steps
- Customize appearance in Design settings
- Set up domain restrictions
- Add suggested messages