Deployments

Embedded Widget

Add your deployed agent to any website using a single script tag.

February 15, 2026
5 min read

Use the widget script to embed a hosted chat UI on your own site.

Script

<script src="https://your-affinitybots-domain.com/widget/agent.js" data-deployment-key="dep_live_xxx"></script>

Optional Attributes

  • data-external-user-id: Pass your own user ID for continuity.
  • data-position: bottom-right (default) or bottom-left.
  • data-title: Custom widget title.

Origin Security

The page origin must be in the deployment allowlist. Otherwise calls are rejected.

Notes

  • The widget stores thread and anonymous external user identifiers in browser local storage.
  • Rotating the deployment public key invalidates previously embedded keys.