chathq.ai logo
chathq.ai

Embed code

After publishing your widget, use this snippet on your site. Place it before the closing </body> tag.

Publishable key

The widget uses a publishable key (not a secret API key). Get it from Workspace Settings → Publishable Keys. The publishable key is safe to include in your frontend code—it is designed for client-side use.

HTML snippet

<script>
window.ChatHQ = window.ChatHQ || {};
window.ChatHQ.workspace = 'YOUR_WORKSPACE_ID';
window.ChatHQ.bot = 'YOUR_BOT_ID';
window.ChatHQ.publishableKey = 'YOUR_PUBLISHABLE_KEY';
window.ChatHQ.position = 'bottom-right';
</script>
<script src="https://cdn.chathq.ai/widget.js" async></script>

Replace:

  • YOUR_WORKSPACE_ID — Your workspace ID
  • YOUR_BOT_ID — Your assistant/bot ID
  • YOUR_PUBLISHABLE_KEY — Your publishable key from Workspace Settings → Publishable Keys

Allowed domains

The widget loads only on domains you add to Allowed domains in workspace settings. Our backend validates the request origin. If the domain is not allowlisted, the widget will not work.

Note:

Add every domain where you embed the widget (e.g. example.com, www.example.com, staging URLs).

Important:

Use the publishable key, not a secret API key. The publishable key is safe for frontend use. Never expose secret keys in client-side code.

Was this article helpful?

Build AI assistants you can actually rely on

Turn your company's knowledge into assistants your team and customers can rely on.