Live Context

Live Context lets your website push per-visitor data into the chat at runtime, so the bot can greet visitors by name, reference their plan, show their order status, or answer any question that depends on who is asking — without them typing it.

The data flows from your site into the chat (not the other way around). Your authenticated page already knows who the user is; Live Context is how you tell the bot.

Typical uses

  • Personalized greetings — "Hi Jane, how can I help?" instead of "Hi there"
  • Order status — pass a list of recent orders so the bot can say "Your order #1234 shipped yesterday"
  • Plan awareness — pass the current plan so answers match their tier (Pro vs Free limits, etc.)
  • Skip the form — pass the visitor's email and phone so the widget doesn't ask for them again
  • Anything else — subscription status, usage quotas, recent activity, flags — whatever your app already has in memory

How it differs from the knowledge base

Knowledge Base Live Context
Uploaded once, indexed into vectors Pushed fresh on every chat
Same content for every visitor Per-visitor, unique each session
Best for stable content (policies, FAQ) Best for session-specific data (name, orders, plan)
You upload it from the dashboard Your app code sends it at runtime

You can and should use both together. The knowledge base teaches the bot about your company; Live Context teaches it about this visitor.

How to send it

Two entry points, both documented in the Widget JS API.

Option 1: Set before the script loads

<script>
  window.aiSupportWidgetData = {
    name: 'Jane Doe',
    email: '[email protected]',
    plan: 'Pro',
    orders: [
      { id: 'ORD-1234', status: 'shipped', eta: '2026-04-12' },
    ],
  };
</script>

<script async src="https://lxaira.com/api/widget/script?projectId=YOUR_ID"></script>

Use this when you render the user data server-side before the widget script runs.

Option 2: Set after the widget is loaded

window.aiSupportWidget.setUserData({
  name: 'Jane Doe',
  email: '[email protected]',
  plan: 'Pro',
});

Use this when user data arrives after page load (SPA hydration, auth state change, etc.). You can call setUserData as many times as you like; each call replaces the previous one.

What the bot sees

The data you pass is serialized and included in the system prompt, so the model can reference it directly. A minimal example:

setUserData({
  name: 'Jane',
  plan: 'Pro',
  renewal: '2026-06-15',
});

When Jane asks "when does my plan renew?", the bot answers "Your Pro plan renews on June 15, 2026."

Requirements and limits

  • The widget must be loaded from an allowed domain (Security). Untrusted origins are refused by the embed script before any data is sent.
  • Pass only what the visitor is already allowed to see. Don't pass other users' data, admin-only fields, or anything you wouldn't put on their account page.
  • Keep the payload reasonable. A few hundred fields is fine; hundreds of KB of JSON is not — it will waste the LLM's context window.
  • This is not a general-purpose remote fetch. The bot does not call URLs you add. If a record changes during the session, call setUserData again with the new values.

Security note

Live Context data leaves your page as a postMessage to the widget iframe. The iframe is loaded from your project on lxaira.com, and the data travels with the chat request. Treat Live Context like any data you put in a URL: don't pass secrets, don't pass fields you wouldn't log.

Where to read next

Live Context — Docs — Aira