Skip to content
Docs

Choose how to install the chat

Every way to add the chat: a script tag, an element, the NPM package, React, your server and mobile apps.

Last updated

Every way of installing loads the same chat with the same deployment settings. Pick the one that fits where the chat goes. Copy the public key and deployment ID from the deployment's Install tab.

Where the chat goesUse
Any website, with no build step (HTML, WordPress, Shopify, Webflow, Wix)The script tag
A page that loads the chat later, such as after cookie consentThe script tag with a command queue
A tag you place yourself, in any page or frameworkThe <web-ai-chat> element
An app with a build step (Vite, webpack, Next.js, Nuxt, Angular)The NPM package
A React or Next.js appThe React kit, or the script tag
Your server, to sign in your users@helpai/elements/server
An iOS or Android app (React Native, Expo)The native chat, @helpai/elements/react-native

The script tag#

One tag in <head> or before </body>:

html
<script
  src="https://cdn.help.ai/sdk/js/elements/9.2.2/elements.js"
  data-public-key="agent_pk_..."
  data-ai-agent-deployment-id="..."
  defer
></script>

The tag works however your site adds it: with defer, async or type="module", written in the page or added by a tag manager, with a nonce for your Content Security Policy. It shows the chat bubble first and loads the chat window when a visitor opens it or the page is idle, all from the same version folder. Keep the version in the address and change it when you want a newer widget. See Add the chat widget to your website (opens another site).

The script tag with a command queue#

To start the chat from your own code, for example once a visitor accepts cookies, leave the attributes off and call HelpAI:

html
<script>
  window.HelpAI = window.HelpAI || function () { (HelpAI.q = HelpAI.q || []).push(arguments); };
  HelpAI('init', { publicKey: 'agent_pk_...', aiAgentDeploymentId: '...' });
</script>
<script src="https://cdn.help.ai/sdk/js/elements/9.2.2/elements.js" async></script>

HelpAI('ask', '...'), HelpAI.open() and every other command wait until the chat has loaded, so you can call them right away. See Load the widget after consent and Control the widget with JavaScript.

The <web-ai-chat> element#

Load the element once, then place it where you want it. Attributes override the deployment's settings for this page:

html
<script type="module" src="https://cdn.help.ai/sdk/js/elements/9.2.2/elements-web-component.esm.js"></script>
<web-ai-chat public-key="agent_pk_..." ai-agent-deployment-id="..." theme="host"></web-ai-chat>

With mode="inline" and a height, the chat sits inside your page instead of floating.

The NPM package#

bash
npm install @helpai/elements
js
import { init } from '@helpai/elements';

init({ publicKey: 'agent_pk_...', aiAgentDeploymentId: '...' });

The package is ES modules. Every bundler takes it, also from require() in CommonJS code, and Node.js 20.19 or later loads it with require() too. To use the element in a framework, import '@helpai/elements/web-component': it is safe in server rendering and registers <web-ai-chat> in the browser. TypeScript types come with the package.

React and Next.js#

The React kit adds the chat with one component and drives it with a hook:

tsx
import { HelpAI } from '@helpai/elements/react';

<HelpAI publicKey="agent_pk_..." aiAgentDeploymentId="..." theme="host" />

The script tag works in React too: add it once from a client component. See Add the widget to a React or Next.js app.

Your server#

To show signed-in users as themselves, your server signs a short token with the deployment's secret key:

js
import { signUserToken } from '@helpai/elements/server';

It runs on Node.js, Bun, Deno and edge functions. Never put the secret key in website or app code. See Log visitors in.

iOS and Android apps#

In any React Native app (bare React Native or Expo), add <HelpAIChat>: the chat drawn with the app's own native views, no WebView. Replies stream in with their cards, the agent's questions and approvals work in place, a person can take over, and the deployment's look and languages apply as on your website.

sh
npm install @helpai/elements @preact/signals-react react-native-svg
tsx
import { HelpAIChat } from '@helpai/elements/react-native';

export function SupportScreen() {
  return <HelpAIChat publicKey='agent_pk_…' aiAgentDeploymentId='…' style={{ flex: 1 }} />;
}

That is all it needs; add what your app wants:

  • storage keeps the conversation when the app restarts: any synchronous store, such as MMKV or Expo's key-value store.
  • fetch is optional: the chat streams on its own, or through Expo's fetch if you pass it.
  • onAction sees every action the visitor takes first (a link, a card's button, a suggestion, an approval…). Return true to handle it your way: open the link in your own screen or in-app browser, or ask for Face ID before an approval.
  • userToken logs a visitor in with a token your server signs, as on a website; onLoginRequested opens your app's own sign-in (a screen, a bottom sheet, a modal) when the visitor taps Log in.
  • onClose adds a close button for a chat shown in a modal or a sheet.
  • components and colors draw the chat with your own design system: your text, buttons and cards, or your own header and composer.
  • On a tablet the conversation centres in a readable column, and the composer stays above the keyboard in a screen, a modal or a sheet.
  • It needs React Native 0.86 or later.

To show the chat in a WebView instead, open the deployment's own page (<WebView source={{ uri: 'https://your-deployment.help.chat' }} />), or give the WebView a small page with the script tag and presentation: { mode: 'standalone' }; that page needs a baseUrl that is one of the deployment's Allowed websites. The WebView uses the phone's browser engine: iOS 16.2 or later, and Android with a current Chrome.

Browsers#

The chat works in Chrome and Edge 111 or later, Firefox 115 or later and Safari 16.2 or later (iOS 16.2). In an older browser it doesn't appear, your page keeps working, and the browser console says the browser is too old.

Was this helpful?

Still need help?