The widget runs in a sandboxed iframe and cannot change your site’s URL directly. When a customer taps a Navigation card, the iframe sends a postMessage to the host page. You must register a listener on the host page to handle that intent.

Embed the widget (iframe + optional listener)

Navigation deeplinks only work when both parts are on your page:
  1. The iframe: loads the chat UI from Chatropic.
  2. A host script: defines setupChatropicNavigationListener and wires it to your router or location.assign.
The Embed tab on Deploy > Chat widget currently copies the iframe setup only. If you are using Navigation cards, add the listener below manually in your host app.

Full embed example

Use the iframe src from the Embed tab on Deploy > Chat widget. Current web snippets use https://chatropic.com/embed/key/{publishable-key}.
If you paste only the iframe without the listener script, Navigation cards will appear in chat but clicks will not navigate your site. This applies to both the website widget and inline panel snippets.

Website widget (floating launcher)

The snippet from Copy website widget code on the Embed tab includes setupChatropicLauncherHostListener and embed wake scripts. The iframe src includes mode=launcher. When integrating manually, register one navigation listener per page. A single listener handles navigation messages from either embed layout.

setupChatropicLauncherHostListener

The website widget posts chatropic:launcher-state messages when chat opens or closes on mobile. The host listener resizes the iframe between a compact closed footprint and full viewport when open. Paste this from the copied website widget snippet rather than hand-rolling iframe sizing on mobile.
If you paste only the launcher iframe without the host scripts, Navigation cards will not navigate your site and mobile chat may not expand correctly.

setupChatropicNavigationListener

This is the function integrators install on the host page (the page that contains the iframe, not inside the iframe).

What it does

  1. Subscribes to window.message on the host page.
  2. Accepts messages only when event.origin === widgetOrigin.
  3. Handles messages where event.data.type === "chatropic:navigate".
  4. Validates event.data.path is a relative URL (starts with /, no javascript: or https://).
  5. Calls your onNavigate(path) callback, or falls back to window.location.assign(path).

Message protocol

When the user clicks a Navigation card inside the iframe, the widget posts to window.parent:
Only relative paths from your tenant’s navigation route registry are ever sent.

SPA integration

Pass a custom onNavigate callback instead of relying on location.assign:

Reuse the listener on multiple pages

Define the function once in a shared bundle or layout, then call setupChatropicNavigationListener on every page that embeds the iframe:

Security

UI payload shape

Sync responses and agent:done events may include:
The default web embed renders this automatically. On mobile, the React Native SDK delivers the same payload through onNavigate; see React Native SDKOn mobile, the React Native SDK delivers the same payload through onNavigate; see React Native SDK.

Click analytics (optional)

The widget dispatches chatropic:nav-card-clicked on the iframe window when the user taps the card. Listen from host instrumentation if needed:

Web embed

Copy website widget or inline panel snippets from Deploy, Chat widget.

Navigation routes

Configure destinations for the agent.