Script tag

Install Webchat with one script.

Paste this before </body>:

<script
  src="https://assistify.chat/widget/widget.js"
  data-widget-id="WIDGET_ID"
  async
></script>

Find your widget ID in the dashboard under Settings → Channels → Webchat → Install.

Allowed domains

Allowed domains, on the same Install page, lists the websites Webchat may load on. With no domain listed, Webchat loads on any website. Once you list one, a page on any other origin is refused and Webchat does not appear there. localhost, 127.0.0.1 and *.local always pass, so local development keeps working.

Pre-fill visitor identity

<script
  src="https://assistify.chat/widget/widget.js"
  data-widget-id="WIDGET_ID"
  data-user-email="[email protected]"
  data-user-name="Jane Doe"
  data-user-hash="HMAC_SHA256"
  async
></script>

Boot-time identity needs a valid data-user-hash:

  • Without a hash, the identity is ignored and the widget logs a console warning. A wrong hash is also ignored, with no warning in the browser.
  • A signed boot identity verifies a visitor who chatted anonymously before signing in, and moves a shared browser to the person who signed in. See Identity verification and Lifecycle.
  • A value the boot cannot accept, such as an invalid email or a relative avatar URL, makes the boot fail, and Webchat does not appear.
Attribute
data-user-emailEmail, up to 254 characters
data-user-external-idYour system's user ID, up to 256 characters. data-user-id is accepted too.
data-user-nameDisplay name, up to 256 characters
data-user-avatarAvatar URL, absolute http(s)
data-user-discord-idDiscord ID
data-user-discord-usernameDiscord username
data-user-discord-avatarDiscord avatar URL, absolute http(s)
data-user-hashHMAC signature
data-launcherfalse renders the panel without the floating launcher. See Panel-only.

Configuration on window

When you cannot set attributes on the tag, for example in a tag manager or a builder that only accepts a plain script, set the configuration on window instead:

<script>
  window.ASSISTIFY_CONFIG = { widgetId: 'WIDGET_ID' };
  window.ASSISTIFY_USER = {
    email:    '[email protected]',
    userHash: 'HMAC_SHA256_SIGNATURE',
  };
</script>
<script src="https://assistify.chat/widget/widget.js" async></script>

Set both globals before the widget script tag, so they already exist when the loader reads them. A value on window takes precedence over the matching attribute.

window.ASSISTIFY_CONFIG
widgetIdYour widget ID
launcherfalse for panel-only
window.ASSISTIFY_USER
emailEmail
externalIdYour system's user ID. id is accepted too.
nameDisplay name
avatarAvatar URL
discordId, discordUsername, discordAvatarDiscord identity
userHashHMAC signature

Boot identity follows the same rules as the attributes. Custom attributes are not recorded at boot: send them with identify().

Control Webchat from code

The runtime installs itself at window.Assistify once widget.js has run. With async, that happens after the rest of your page's scripts may already have run, so wait for the assistify:ready event on window before calling it:

window.addEventListener('assistify:ready', () => {
  window.Assistify.identify({ email: '[email protected]', userHash: '...' });
  window.Assistify.on('identified', ({ verified }) => console.log({ verified }));
});

Calls made after widget.js has run but before the runtime has booted are queued and replayed. See JavaScript API for the complete method list.

Logout

window.Assistify.reset();

reset() clears the session server-side and locally, including any identity attributes on the script tag and unsent message drafts. The next boot is anonymous. See JavaScript API → reset().

Defer the loader

The script tag loads Webchat as soon as the page does. To load it only after consent or behind a feature flag, use the SDK with autoload: false: widget.js stays off the page until you call load(), chat.open(), chat.close(), chat.toggle() or campaigns.show().

When your team replies to a visitor who has left, the reply email links to your website's home page, and Webchat opens the conversation there. Load Webchat on the home page for those links to work. Webchat removes its own parameters (assistify_resume, assistify_intent, assistify_campaign) from the address once it has read them.

Content Security Policy

script-src  https://assistify.chat;
connect-src https://assistify.chat wss://assistify.chat https://api.cloud.anewvision.fr;
img-src     https://assistify.chat https://api.cloud.anewvision.fr https://cdn.discordapp.com https://media.discordapp.net https://lh3.googleusercontent.com https://icons.duckduckgo.com https://i.ytimg.com https://cdn-cf-east.streamable.com data: blob:;
style-src   'unsafe-inline' https://assistify.chat;
font-src    https://assistify.chat;
frame-src   https://www.youtube-nocookie.com https://streamable.com;

What each addition covers:

  • img-src https://api.cloud.anewvision.fr covers message attachments, teammate and visitor avatars and uploaded widget assets, which are served from Assistify's file storage.
  • img-src blob: covers images the widget renders through object URLs, such as a freshly captured upload before it is stored.
  • img-src https://cdn.discordapp.com https://media.discordapp.net covers avatars taken from a Discord sign-in, for teammates and for visitors who sign in with Discord in Webchat, and images shared in Discord conversations.
  • img-src https://lh3.googleusercontent.com covers teammate avatars taken from a Google sign-in.
  • img-src https://icons.duckduckgo.com covers the icon shown next to links inside chat.
  • img-src https://i.ytimg.com https://cdn-cf-east.streamable.com covers the thumbnail of a shared video before a visitor clicks play.
  • Product cards show images from your store. Add your store's image host to img-src, for example https://cdn.shopify.com.
  • style-src 'unsafe-inline' is required: the widget renders inside its own iframes and injects its stylesheet there, and those frames inherit your page's policy.
  • style-src https://assistify.chat and font-src cover the custom-font option, which loads its stylesheet and font files through the Assistify font proxy, so font requests never go to Google.
  • connect-src https://api.cloud.anewvision.fr covers an uploaded notification sound. The widget decodes it through the Web Audio API, which fetches the file, so a sound is a connect-src request and not a media-src one.
  • frame-src https://www.youtube-nocookie.com https://streamable.com covers the inline player that opens when a visitor clicks a shared video.

If you load Webchat from another origin with the SDK's baseUrl, that origin replaces assistify.chat in every directive.

Tell your visitors

Your privacy policy should mention the chat. See Visitor recognition → Your privacy policy for the two notices to link.