跳转到内容

WebChat Embedding

The Greentic WebChat widget can be embedded in your website in three ways, each suited to different use cases:

Embed TypeBest ForIntegration Effort
Fullpage LinkDedicated support pages, standalone chat portalsMinimal — just a link
Inline IframeEmbedding chat in a specific area of a pageLow — one <iframe> tag
Chat BubblePersistent chat button on every page, customer support overlaysMedium — script tag + configuration

All three types are auto-generated as embed snippets when the greentic.cap.webchat.embed.v1 capability is enabled. You can find the generated snippets in assets/webchat-gui/embed/{tenant}.html after running the wizard or setup.

The simplest option. The WebChat provider serves a fullpage chat UI at a dedicated path. You just link to it.

<!-- Link to the fullpage WebChat -->
<a href="https://your-domain.com/webchat/gui/demo/default">
Open Support Chat
</a>

The fullpage view uses the tenant’s skin files (colors, logo, title) from assets/webchat-gui/skins/{tenant}/fullpage/. You can customize index.html and page.css there.

Embed the chat in a specific area of your page using an <iframe>. This gives you control over sizing and placement while keeping the chat isolated.

<!-- Inline iframe embedding -->
<iframe
src="https://your-domain.com/webchat/gui/demo/default"
width="400"
height="600"
style="border: 1px solid #e0e0e0; border-radius: 8px;"
allow="microphone; camera"
title="Support Chat"
></iframe>

For responsive layouts, wrap the iframe in a container:

<div style="width: 100%; max-width: 480px; height: 70vh; min-height: 400px;">
<iframe
src="https://your-domain.com/webchat/gui/demo/default"
style="width: 100%; height: 100%; border: none; border-radius: 8px;"
allow="microphone; camera"
title="Support Chat"
></iframe>
</div>

The chat bubble places a floating button on your page. When clicked, it opens a chat overlay. This is the most common choice for customer-facing websites where you want chat available on every page.

<script>
window.greenticChatConfig = {
baseUrl: 'https://your-domain.com',
tenant: 'demo',
team: 'default'
};
</script>
<script src="https://your-domain.com/v1/web/webchat/demo/embed.js" defer></script>
<script>
window.greenticChatConfig = {
baseUrl: 'https://your-domain.com',
tenant: 'demo',
team: 'default',
// Appearance
title: 'Acme Support',
subtitle: 'We usually reply within minutes',
logo: 'https://example.com/logo.png',
primaryColor: '#E63946',
backgroundColor: '#F1FAEE',
position: 'bottom-right',
offsetX: 20,
offsetY: 20,
bubbleSize: 60,
bubbleIcon: 'chat',
zIndex: 9999,
// Behavior
startOpen: false,
greetingMessage: 'Hello! How can we help you today?',
greetingDelay: 3000,
showUnreadBadge: true,
persistSession: true,
// Size
width: 400,
height: 600,
mobileFullscreen: true
};
</script>
<script src="https://your-domain.com/v1/web/webchat/demo/embed.js" defer></script>

The window.greenticChatConfig object accepts the following options before the embed script loads:

OptionTypeDescription
baseUrlstringBase URL of the Greentic runtime (e.g., https://your-domain.com)
tenantstringTenant identifier
teamstringTeam identifier
OptionTypeDefaultDescription
titlestringFrom skin.jsonChat window title displayed in the header
subtitlestringundefinedSubtitle text below the title
logostringFrom skin.jsonURL of the logo image shown in the header
primaryColorstringFrom skin.jsonPrimary accent color (hex, e.g., #0078D4)
backgroundColorstring#ffffffChat window background color
positionstringbottom-rightBubble position: bottom-right or bottom-left
offsetXnumber20Horizontal offset from the edge in pixels
offsetYnumber20Vertical offset from the bottom in pixels
bubbleSizenumber60Diameter of the floating bubble button in pixels
bubbleIconstringchatIcon inside the bubble: chat, help, support, or a custom SVG URL
zIndexnumber9999CSS z-index for the chat overlay and bubble
OptionTypeDefaultDescription
startOpenbooleanfalseOpen the chat window immediately on page load
greetingMessagestringundefinedProactive greeting shown in a tooltip above the bubble
greetingDelaynumber3000Delay in milliseconds before showing the greeting
showUnreadBadgebooleantrueShow unread message count badge on the bubble
persistSessionbooleantruePersist chat session across page navigations using localStorage
OptionTypeDefaultDescription
widthnumber400Width of the chat window in pixels
heightnumber600Height of the chat window in pixels
mobileFullscreenbooleantrueUse fullscreen mode on mobile devices (viewport width < 768px)

When options like title, primaryColor, or logo are not explicitly provided in window.greenticChatConfig, the embed script automatically loads defaults from the tenant’s skin.json file. This means your chat bubble inherits your brand configuration without duplicating it in the embed code.

assets/webchat-gui/skins/demo/skin.json
{
"title": "Acme Support",
"logo": "/assets/webchat-gui/skins/demo/logo.png",
"primaryColor": "#E63946",
"backgroundColor": "#F1FAEE"
}

The resolution order is:

  1. Explicit options in window.greenticChatConfig (highest priority)
  2. Values from the tenant’s skin.json
  3. Built-in defaults from the pack

After initialization, the greenticChat object exposes methods to control the chat bubble programmatically:

// Open the chat window
greenticChat.open();
// Close the chat window
greenticChat.close();
// Toggle open/close
greenticChat.toggle();
// Check if the chat window is open
const isOpen = greenticChat.isOpen();
// Destroy the widget and clean up
greenticChat.destroy();
<button onclick="greenticChat.open()">
Need help? Chat with us
</button>
setTimeout(() => {
if (!greenticChat.isOpen()) {
greenticChat.open();
}
}, 10000); // Open after 10 seconds
document.getElementById('my-chat-button').addEventListener('click', () => {
greenticChat.toggle();
});

The chat bubble adapts to mobile devices automatically:

  • Viewport < 768px: When mobileFullscreen is true (default), the chat window opens in fullscreen mode, covering the entire viewport. A back/close button replaces the header close icon.
  • Viewport >= 768px: The chat window opens as a floating panel next to the bubble, sized according to width and height.
  • Orientation changes: The widget detects orientation changes and re-renders at the correct size.
  • Touch interactions: The bubble button responds to touch events with appropriate hit targets (minimum 44x44px following accessibility guidelines).

When the greentic.cap.webchat.embed.v1 capability is enabled, running gtc wizard or gtc setup generates ready-to-use embed snippets at:

assets/webchat-gui/embed/{tenant}.html

The generated file contains all three embed types with pre-filled configuration:

Fullpage link snippet
<!-- Fullpage Link -->
<a href="https://your-domain.com/webchat/gui/demo/default">
Open Support Chat
</a>

These snippets use the public_base_url from your provider configuration. If you use ngrok or Cloudflare Tunnel, gtc start replaces the URL automatically.