Example implementation for JavaScript render forms
Include the widget script in your template or via a JavaScript render form:
<!-- For production (CDN): -->
<link rel="stylesheet" href="https://your-cdn-url.com/widget.css">
<script src="https://your-cdn-url.com/widget.iife.js"></script>
<!-- For local testing: -->
<link rel="stylesheet" href="./dist/widget.css">
<script src="./dist/widget.iife.js"></script>
The widget bundles the Roboto font by default via @font-face declarations in src/font.css. The font files are embedded into widget.css during the build.
Option A: Use a bundled custom font (recommended)
src/fonts/src/font.css with your @font-face rulesfontFamily in the theme confignpm run build — fonts will be embedded into widget.css
// In src/font.css:
@font-face {
font-family: "YourFont";
src: url("./fonts/YourFont/YourFont-Regular.ttf") format("truetype");
font-weight: 400;
font-style: normal;
}
// In GENASSIST_CONFIG:
theme: { fontFamily: 'YourFont, sans-serif' }
Option B: Load fonts externally (e.g., Google Fonts)
If you prefer not to bundle fonts, load them via a <link> tag and reference them in the theme config:
<!-- Load font from Google Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap">
<script>
window.GENASSIST_CONFIG = {
// ...
theme: {
fontFamily: 'Inter, sans-serif'
}
};
</script>
@font-face rules in src/font.css to reduce the widget.css bundle size.
Here's the complete code you can paste into your JavaScript render form:
<!-- Root container for the widget -->
<div id="genassist-chat-root"></div>
<!-- Widget Configuration and Auto-initialization -->
<script async>
(function() {
'use strict';
window.GENASSIST_CONFIG = {
baseUrl: '_base_url_',
apiKey: '_apiKey_',
tenant: '',
headerTitle: 'GenAssist Demo',
mode: 'floating',
floatingConfig: { position: 'bottom-right' },
serverUnavailableMessage: 'Support is currently offline. Please try again later or contact us.',
noColorAnimation: true,
useWs: false,
useFiles: false,
usePoll: false,
};
})();
</script>
<!-- Widget Script and CSS -->
<script src="./dist/widget.iife.js"></script>
<link rel="stylesheet" href="_asset_widget.css_" async>
The widget should automatically appear in the bottom-right corner of this page. Update the configuration above with your API credentials to test.