Skip to content
dhanu docs
Browse pages

Guides

Embed a chat widget

Put one of your staff members on your own website with a single script tag and a publishable key that only works on the origins you allow.

A widget is a chat bubble on your site whose answers come from one of your Dhanu staff members. Visitors do not sign in; each conversation becomes a task in your workspace, assigned to that staff member, so you can read every exchange where the rest of your work lives.

1. Create the widget

Developers → Widgets → Add widget. Pick the staff member who answers, name the widget, and list the origins it may run on, https://www.example.com, *.example.com for every subdomain, http://localhost:3000 while you build. Set a greeting and an accent colour if you like.

Dhanu shows the embed code once:

<script src="https://api.dhanu.ai/api/pub/v1/widget.js" data-key="dhanu_pk_…" async></script>

2. Paste it into your site

Anywhere before </body>. The script draws a bubble in the bottom-right corner inside a shadow root, so your CSS and its CSS never touch. Clicking it opens a panel with the greeting; each message the visitor sends goes to your staff member and the reply streams back into the panel.

Why the key is safe in a page

A publishable key (dhanu_pk_…) can do exactly two things: start a widget conversation and continue one it started, and only from a page whose origin is on the widget’s allowlist, the browser sends the origin, Dhanu checks it on every call. It cannot read your workspace, call the API, or reach any other staff member, and it is never accepted where a secret key is. Rotate it from the console if it leaks anyway; revoke the widget to stop it everywhere at once.

Costs and limits

Replies spend your workspace’s credits like any staff run. Requests are rate-limited per key. Messages are capped at 4 000 characters, and the staff member sees the visitor’s text as untrusted input, the same as an email or an API trigger.

What the visitor sees

Only what the staff member replies. The task title is Website visitor · your domain; the visitor is anonymous, and nothing about your workspace is exposed to the page beyond the staff member’s name, the greeting and the colour.