Skip to main content
The Standalone AI Chat Widget lets you embed the Nexudus AI assistant on any external website — your company homepage, a landing page, a blog, or any third-party site — with a single <script> tag. This is the same AI assistant that powers the chat experience inside your members portal, but designed to work on sites where the portal is not available.
AI chat widget floating button and open chat modal on an external website

When to use the standalone widget

Use the standalone widget when you want to offer AI-powered conversations on pages outside the members portal: The widget provides the same capabilities as the portal chat — answering questions about your location, rooms, membership plans, and day passes, as well as helping visitors book tours and resources.
The standalone widget shares the same conversation data with the portal. Conversations started on your external website appear in the AI Conversations list alongside portal conversations, so you get a unified view of all AI interactions.

How it works

The widget is a single JavaScript file that loads asynchronously. Once loaded, it:
  1. Reads configuration from data-* attributes on the <script> tag
  2. Creates a floating action button in the corner of the screen
  3. Attaches a chat modal using Shadow DOM (completely isolated from your site’s styles)
  4. Communicates with the Nexudus AI API to process messages and return responses
No HTML elements are required on your page — the widget self-initialises and appends everything it needs to document.body.

Adding the widget to your website

Step 1: Get your API base URL

The widget needs to know which Nexudus account to connect to. Your API base URL follows this format:
Where {webAddress} is the Domain value shown in your Nexudus dashboard:
  1. Log in to dashboard.nexudus.com
  2. Go to Settings > Website
  3. Find the Domain field — this is your webAddress
Settings > Website page showing the Domain field
For example, if your Domain is myworkspace, your API base URL is:

Step 2: Add the script tag

Place the following script tag before the closing </body> tag on your website:
Replace myworkspace with your actual Domain value from the step above.

Step 3: Test the widget

Open your website in a browser. You should see a floating chat button in the bottom corner. Click it to open the chat modal and send a test message.
If you don’t see the button, check your browser console for errors. The most common issue is a missing or incorrect data-api-base value.

Configuration parameters

All configuration is passed through data-* attributes on the <script> tag. The only required attribute is data-api-base.

Configuration examples

Left position with custom colors:
Auto-open on page load with a greeting:
Dark theme with custom portal URL:

Controlling the widget with JavaScript

After the widget loads, it exposes a window.nxAiChat object that lets you control it programmatically from your website’s JavaScript.

Available methods

Examples

Open the chat when a user clicks a button on your page:
Close the chat after a certain action:
Start a fresh conversation:
Remove the widget entirely (e.g. on logout):
Set an authentication token after user login:
The setToken method is only useful if your website has its own authentication system and you want to pass the user’s session to the Nexudus API. For most use cases, the widget works fine without a token.

Listening to widget events

The widget emits events during its lifecycle. You can subscribe to these events using nxAiChat.on() and unsubscribe with nxAiChat.off().

Available events

Examples

Track when a booking is confirmed:
Log all AI responses for debugging:
Track chat open/close events:
Handle errors gracefully:
Unsubscribe from an event:

Style isolation

The widget uses Shadow DOM to mount its UI, which means:
  • Your website’s CSS does not affect the widget’s appearance
  • The widget’s CSS does not leak into your website
  • The widget inherits the host page’s font family and base font size for a cohesive look
Colors like the button background and text are controlled via the data-primary-color and data-text-color attributes. The widget adapts to these values using CSS custom properties.
If you need to override additional styles, you can target the shadow host element (#nxai-root) and pass custom properties into the shadow root. However, this is rarely necessary — the built-in configuration options cover most use cases.

Session persistence

The widget stores conversation history in the browser’s localStorage, keyed by your data-api-base URL. This means:
  • If a visitor closes the chat and returns later, their conversation history is restored
  • Sessions expire after 7 days — older conversations are automatically discarded
  • The “New chat” button in the chat header clears the session and starts fresh

Geolocation

When data-geolocation="true" (the default), the widget will request the visitor’s browser location on their first message. This allows the AI to calculate distances when presenting rooms, locations, and offices. If the visitor denies the location permission, the widget continues to work normally — distance information is simply omitted from the AI’s responses.

Accessibility

The widget follows accessibility best practices:
  • All interactive elements have proper ARIA roles and labels
  • Focus is trapped inside the modal when it’s open
  • Escape closes the modal, Enter sends a message
  • An aria-live="polite" region announces new AI messages to screen readers
  • The widget respects prefers-reduced-motion — the typewriter animation is skipped for users who prefer reduced motion

Size and performance

  • The minified bundle is approximately 15–25KB gzipped
  • The widget loads asynchronously and does not block page rendering
  • No external dependencies — everything is contained in a single file
  • The AI API is only called when the user sends a message

Troubleshooting

Comparison with portal chat