Snippet reference
Every option on the script tag and every method on window.DuggAI, in one place.
The script tag
<script
src="https://duggai.com/embed.js"
data-key="duggsupp_pk_XXXXXXXXXXXX"
defer
></script>embed.js is a tiny loader: it renders the launcher immediately and lazy-loads the full widget bundle the first time someone opens it (or you call open()), so it costs almost nothing on page load.
Data attributes
| Attribute | Default | Notes |
|---|---|---|
data-key | required | Your public widget key. Starts with duggsupp_pk_. Without it the loader refuses to load. |
data-stream | true | Set to "false" to disable streamed (SSE) replies — useful behind a strict CSP that blocks chunked responses. |
data-bundle | — | Set to "legacy" only if you hit a CDN cache mismatch; loads the older bundle filename. |
JavaScript API
The widget exposes window.DuggAI once loaded. The legacy window.DuggSupport alias still works — both names resolve to the same object.
identify(user)
Tag the conversation with the signed-in user.
window.DuggAI.identify({
id: "u_abc123",
email: "alice@example.com",
name: "Alice Smith",
// optional metadata, sent to the agent for context
traits: { plan: "pro", signupDate: "2025-04-12" },
});For production, use HMAC-signed identify so users can't spoof other accounts.
open() / close()
Open or close the bubble programmatically. Useful for "Need help?" buttons.
document
.querySelector("#help-button")
.addEventListener("click", () => window.DuggAI.open());setContext(ctx)
Set context that's included with the conversation so the agent knows where the user is and what they're doing.
window.DuggAI.setContext({
workspaceId: "ws_42",
framework: "next-15",
});isVerified()
Returns true once the server has confirmed a signed identify hash for this session (see Identifying users). Returnsfalse for anonymous or unverified sessions.
window.DuggAI immediately and queues any identify() / setContext() / open() / close() calls — they replay in order once the heavy bundle lands. So calling DuggAI.identify(…) right after the <script> tag is safe.