Embedding overview
The demo is one way to run the assistant. The other is a tag in somebody else's claims system:
<script type="module" src="https://assistant.example.com/claimpilot-assistant.js"></script>
<claimpilot-assistant id="assistant" locale="en-GB" api="https://assistant.example.com"></claimpilot-assistant>
<script>
document.getElementById('assistant').claim = toClaimpilotClaim(theClaimOnScreen);
</script>
The host hands over the claim it is already displaying. Nothing is fetched, so there is no store to point at, no id to agree on, no second copy to keep in step, and no access decision to make twice: the host decided who could see the claim when it put it on the screen.
We integrate at the claim, not at the tools
The assistant has sixteen tools. All but the screen action are calculations over one document, not calls to a system. That leaves two ways to plug into a host:
| What the host builds | What it costs | |
|---|---|---|
| Integrate at the tools | sixteen endpoints matching our contracts | sixteen integration points per system, and every host reimplements our fraud checks and SLA maths slightly differently |
| Integrate at the claim | one mapping: give us the claim | one mapping per system; every tool, capability, prompt and the safety layer stay ours and identical everywhere |
We integrate at the claim. The Claim contract is the product's integration contract.
What makes the demo embeddable without a fork
- The contract is mostly optional. Eight fields are required; every other section has an empty default. A host maps what it has, and a capability with nothing to work from says so rather than inventing anything.
- The element renders into a shadow root (
frontend/src/embed/element.tsx). Isolation works both ways: our resets do not rearrange the host's page, and an unlayered host rule such asheader { background: #fff }cannot beat our utilities. Tailwind's@propertyregistrations are hoisted to the host document, because a shadow root ignores them and borders would quietly disappear. - Script order does not matter. A claim assigned before the element is defined lands as an own property that would shadow the accessor. The element takes it back on connect (the property-upgrade pattern), so hosts can load the script wherever suits them.
- Pointing at the screen is opt-in. With the
screen-actionsattribute anddata-panelregions, the assistant can highlight parts of the host's page. Without it,highlight_panelis never offered to the model, so it cannot claim to have highlighted anything. Anchors are looked up in the host document, so highlighting works from inside the shadow root. - Feedback goes to the host as well as to us. Each vote fires
claimpilot-feedback(bubbling, composed) with the vote, question and answer, so the host can file it against its own claim and user. We store the vote without the question and answer unless the element hasfeedback-content. - Docking means something different. In the app, the shell gives the docked panel a column and reflows. Embedded, there is no shell and the element's own box is 0×0, so the panel pins itself to the viewport and covers the right of the page (
DockPlacementoverlay). - Its own memory. The element keeps its open-or-docked state under its own
localStoragekey, so a handler who docked the demo on the same origin does not find a host page opening into a panel.
What a host does not get
- The Prompt Lab. There is no browser-held override to send, so prompts are whatever the deployment ships, and a change of tone is a release on our side.
- The claims list, claim screens, demo hints and generator. The host's product is the claim screen.
The pieces
| Where | What |
|---|---|
frontend/src/embed/element.tsx | The custom element: properties, attributes, shadow root, the feedback event |
frontend/src/embed/EmbeddedAssistant.tsx | The same ChatWidget, composed for a host: pinned region, overlay dock, embed feedback options |
frontend/src/embed/embed.css | The shadow-root stylesheet |
frontend/vite.embed.config.ts | The second build: one script, dist/claimpilot-assistant.js. npm run build runs both builds |
frontend/public/claimpanion.html | Claimpanion: a pretend claims system with its own markup, no framework and no build step, that prints its own integration on the page |
Read next
- Host integration guide: what a host developer does, in thirty minutes.
- Claim mapping: what to map, and what each section switches on.
- Access control:
ALLOWED_ORIGINSandEMBED_KEY. - Troubleshooting.
- Design notes: why it is shaped this way, and what comes next.