---
url: /v7.0/en-us/copilot-sdk-iframe.md
---
# iframe integration

Applies to HENGSHI SENSE 7.0. Use an iframe to reuse the complete ChatBI page in your portal. HENGSHI manages model execution, data permissions, and conversation data on the server. The customer owns login, iframe layout, and the host site's embedding policy.

## Embed ChatBI

```html
<iframe
  title="ChatBI"
  src="https://analytics.example.com/chatbi"
  style="width:100%;height:720px;border:0;">
</iframe>
```

Users need an established HENGSHI session and the corresponding data permissions. Select an application, data package, or measure subject in the embedded page before asking questions.

Use repeated `tag` URL parameters to scope history by source system. New conversations store the tags, and history lists and searches return only conversations that contain every supplied tag. Omitting `tag` preserves the default history behavior:

```html
<iframe
  title="ChatBI"
  src="https://analytics.example.com/chatbi?tag=business-system-a&amp;tag=read-only"
  style="width:100%;height:720px;border:0;">
</iframe>
```

Tags are immutable source metadata on conversation creation; they do not participate in authentication or permission checks. Pass at most five tags, each no longer than 64 characters, non-empty, and without leading or trailing whitespace.

Configure CSP, `X-Frame-Options`, and browser Cookie policy for the portal's embedding and login paths. The iframe normally calls HENGSHI APIs on the same origin; configure cross-origin parent SDK calls with [CORS](copilot-sdk.md#CORS-configuration).

## Parent-page collaboration

The iframe can collaborate with its parent through `postMessage`. Declare the relationship with these URL parameters:

| Parameter | Purpose |
| --- | --- |
| `agentHost=parent` | Send conversation requests to the Data Agent host registered by the parent |
| `agentHost=local` | Use the local Data Agent inside the iframe |
| `parentOrigin` | Full parent origin, for example `https://portal.example.com` |

Example:

```html
<iframe
  title="ChatBI"
  src="https://analytics.example.com/chatbi?agentHost=parent&amp;parentOrigin=https%3A%2F%2Fportal.example.com"
  style="width:100%;height:720px;border:0;">
</iframe>
```

After registering a Data Agent host, the parent can handle these events:

* `ui.open.request`: open the Data Agent panel in the parent;
* `conversation.turn.request`: receive an iframe conversation request and return `conversation.turn.result`;
* `dashboard.chart.insert.request`: receive a chart-insert request and return `dashboard.chart.insert.result`.

Messages use `type: "hengshi:data-agent-embed"` and `version: "1.0"`. Match each request and result with `requestId`. The conversation payload can carry `prompt`, `userConfig`, and host-defined context.

## Security configuration

Set an explicit `parentOrigin` for every iframe and maintain an allowlist of iframe sources in the host. Use the exact origin for cross-origin messages. Configure CSP, CORS, and Cookie policy together so that login state, message source, and data permissions remain aligned. Do not use a wildcard origin or put user credentials in a message payload.

Parent collaboration carries only the authorized question scope and context; HENGSHI's server-side permission model remains the authority for data access. The host can decide whether to show the Data Agent panel, accept chart insertion, and render returned results.

## Other options

Use the [data client SDK](copilot-sdk-client.md) to render and control the conversation UI, the [complete UI SDK](copilot-sdk-js.md) to embed a ready-made chat window, or the [HTTP API](copilot-sdk-api.md) for backend-only calls.
