PAI Chat·Chat widget
Embedding the chat widget
Drop the chat widget onto any website with a single script tag. In the browser the widget can resolve its chatbot automatically from the host it runs on, so end users never handle API keys.
Install
Add the loader script before </body>, then call PaiWidget.init with your supportBotId (the chatbot id). The widget mounts a launcher and handles the chat session and streaming for you.
HTML
<!-- Paste just before </body> -->
<script src="https://supportbot-widget.paicloud.ai" async></script>
<script>
window.PaiWidget?.init({
supportBotId: "YOUR_CHATBOT_ID",
});
</script>How the chatbot is resolved
For browser embeds the chatbot is resolved on the server in this order:
- an explicit
x-chatbot-id(what the widget sends from thesupportBotIdyou pass toPaiWidget.init); - the request's referer host matched against the chatbot's registered domain — so a widget served from a registered site resolves without an id;
- a configured default chatbot as a final fallback.
public
Register your site's domain on the chatbot to enable referer-based resolution. Passing
supportBotId to PaiWidget.init is still recommended — it is unambiguous and works even before a domain is registered.Pinning the chatbot explicitly
When one site hosts more than one chatbot, or the domain is not registered, always pin the id:
HTML
<script src="https://supportbot-widget.paicloud.ai" async></script>
<script>
window.PaiWidget?.init({
supportBotId: "YOUR_CHATBOT_ID",
});
</script>shield
Implicit resolution is for browser widgets only. Server-to-server calls do not have a trusted referer — they must send
x-chatbot-id (and x-api-key) explicitly. Never ship an API key in front-end code; the widget authenticates as the chatbot, not as a key holder.See Chatbots & organisations for the scoping model and Streaming responses for how replies arrive.