MaiGPT Mode Embedding
Embed a full ChatGPT-like MaiGPT conversation interface into your website or product, supporting both designated container and floating fullscreen layouts
MaiGPT mode provides a full ChatGPT-like conversation interface (sidebar conversation history, conversation search, settings panel), distinct from the existing "bottom-right chat bubble" (floating / sidebar). It is ideal as a primary functional area on a page or as a site-wide AI assistant entry point.
1. Two Layout Modes
The same configuration supports two layouts, determined by whether targetElement is present:
Mode A — Embed in Designated Container: MaiGPT is always visible within a designated
divon the page (ideal as the system's primary workspace)Mode B — Floating Button + Fullscreen: A bottom-right floating button that opens fullscreen when clicked (ideal as a site-wide AI assistant entry point)
Both behaviors are triggered by the same maigpt mode, differing only by the targetElement field.
2. Mode A: Embed in Designated Container
Embed Code
<!-- Prepare the container on the page and set its dimensions -->
<div id="maigpt-container" style="height: 720px;"></div>
<script>
window.maiagentChatbotConfig = {
webChatId: 'your-web-chat-id',
baseUrl: 'https://chat.maiagent.ai/web-chats',
enabledWindowModes: ['maigpt'],
targetElement: '#maigpt-container',
primaryColor: '#1890ff',
maigptTitle: 'Acme GPT',
}
</script>
<script
src="https://chat.maiagent.ai/js/embed.min.js"
defer>
</script>Actual embed result (MaiGPT embedded within an enterprise portal, maigptTitle set to the brand name):
Container Requirements
The container must have a defined height (the iframe fills the container at
100%; content is invisible when the container height is 0)targetElementaccepts a CSS selector string (e.g.,'#maigpt-container') or an HTMLElement objectIf the container is
position: static, the SDK automatically changes it toposition: relative— no action is typically neededThe iframe only occupies the container and does not affect other areas of the page
Important: When the selector cannot find the element, it falls back to fullscreen covering the entire page with no close button (the console will display a [maiagent] targetElement selector "..." not found, falling back to <body> warning).
Ensure: (1) the selector is spelled correctly; (2) the container exists in the DOM when the SDK loads (place the loader <script> after the container with defer; for SPA dynamically rendered pages, load the SDK only after the container is mounted).
3. Mode B: Floating Button + Fullscreen
Embed Code
Behavior Description
A floating button appears at the bottom-right of the page (color uses
primaryColor)Click the button → MaiGPT opens as a fullscreen iframe with a "×" close button in the top-right corner
Click "×" → fullscreen collapses back to the floating button
When collapsed, the iframe is only hidden, not destroyed → reopening preserves the original conversation state
Button Appearance Parameters (all optional, Mode B only)
primaryColor
#1890ff
Button background color, can be set to brand color
buttonSize
3rem
Button size
buttonRadius
50%
Button border radius
buttonPositionBottom
1rem
Distance from viewport bottom
buttonPositionRight
1rem
Distance from viewport right
buttonIcon
(built-in icon)
Custom button icon image URL
boxShadow
0.125rem 0.125rem 0.5rem #00000044
Button shadow
4. Complete Parameter Reference
webChatId
string
✅
WebChat ID
baseUrl
string
✅
Web Chat service URL, SaaS is https://chat.maiagent.ai/web-chats
enabledWindowModes
string[]
✅
Fixed as ['maigpt'] (first element determines the mode)
targetElement
string or HTMLElement
✖
Present → Mode A; absent → Mode B
maigptTitle
string
✖
Brand title in the top-left of the sidebar; defaults to MaiGPT if not set
primaryColor
string
✖
Interface primary color, can be adjusted to brand color
locale
string
✖
Interface language, see Locale below; when not specified, determined by the last remembered language or browser language
queryMetadata
object or string
✖
Query metadata attached to the conversation, see Knowledge Management Permissions Overview for details
Unknown fields in the configuration will not cause errors, but the console will display an [maiagent] Unknown config options: ... warning to help check for typos.
5. Locale
Supported Locale Values
zh-TW (Traditional Chinese), zh-CN (Simplified Chinese), en, ja, ko, th, vi-VN, id, fil-PH, ms-MY, km-KH, lo-LA, my-MM
Priority Order
localein config (always takes effect, highest priority)The language last used by the user in this browser (remembered)
Browser language
Default
zh-TW
6. Identify User (contactId)
To let the AI know "who is asking" (preserve conversation history across devices, personalized responses, invoke tools with user permissions), include contactId in the config:
The backend calls the Contact Credentials Sync API when the user logs in to obtain the
contactIdThe frontend adds
contactIdto the config:
contactId must be the value corresponding to the logged-in user. Without contactId, the session is anonymous: conversation history is retained per browser (persists after refreshing within the same browser), but cannot be shared across devices and cannot access personal data with user identity.
7. FAQ
Last updated
Was this helpful?
