SMflowAll guides

Website chat widget

Install and customise the SMFlow chat widget on your website.

What does website live chat give me?
  • Install
  • WordPress
  • Identify visitors
  • Theme
  • Position
  • Colour, welcome, quick questions
  • Your own button
  • Allowed domains

1. Install

Paste the snippet below just before the closing </body> tag on every page of your site. The chat launcher appears in the corner.

<script src="https://smflow.io/widget.js" data-business-id="YOUR_BUSINESS_ID" defer></script>

data-business-id is your business ID. Copy the ready-made snippet from the dashboard under Channels → Website chat; it already contains your ID.

WordPress, without code

  1. Copy the snippet from the dashboard (Channels → Website chat).
  2. In WordPress go to Plugins → Add New, search for WPCode, install and activate it.
  3. Open Code Snippets → Header & Footer.
  4. Paste the snippet into the Footer box and save.
  5. If you run a caching plugin (WP Rocket, LiteSpeed Cache), clear the cache.
  6. Open your site; the chat launcher is in the bottom corner.

We recommend adding your site to allowed domains as well.

2. Identify visitors

If the visitor is signed in to your site, pass their details so the inbox shows a name and an email or phone number instead of an anonymous session.

  • Email or phone: at least one is required.
  • Without hash the visitor is labelled "unverified" (anyone can claim any email).
  • With hash the visitor is "verified": the identity has been signed by your server.

Order matters: the smflowSettings script must come before the widget script.

<!-- This script must come BEFORE the widget script -->
<script>
  window.smflowSettings = {
    // Email or phone: at least one is required.
    email: 'CURRENT_USER_EMAIL', // optional
    phone: 'CURRENT_USER_PHONE', // optional
    name:  'CURRENT_USER_NAME',
    // hash is optional; with it the visitor is marked "verified".
    hash:  'COMPUTED_ON_YOUR_SERVER',
  }
</script>
<script src="https://smflow.io/widget.js" data-business-id="YOUR_BUSINESS_ID" defer></script>

hash is HMAC-SHA256(identifier, widget_secret) as lowercase hex, where identifier is the email if present, otherwise the phone. The widget secret is in the dashboard under Channels → Website chat.

// Node.js: build the hash on YOUR server. Never ship the widget secret to the browser.
const crypto = require('crypto')

const WIDGET_SECRET = process.env.WIDGET_SECRET // from the SMFlow dashboard

// Rule: if you have an email, hash the EMAIL; only without an email, hash the phone.
// The server verifies in exactly this order.
const email = 'user@example.com' // or ''
const phone = '447700900000'     // or ''
const identifier = email || phone

const hash = crypto
  .createHmac('sha256', WIDGET_SECRET)
  .update(identifier) // the same string you send in smflowSettings
  .digest('hex')      // lowercase hex

3. Theme

Three modes: dark, light and auto. Auto follows the visitor's system preference. Set it in the dashboard.

4. Position

The launcher sits in the right or left corner. Set it in the dashboard.

5. Brand colour, welcome message, quick questions

  • Brand colour: the launcher and bubble colour.
  • Welcome message: shown when the chat opens.
  • Quick questions: suggested buttons that start a conversation.

All three are set in the dashboard; no code change needed.

6. Your own button

The round floating launcher is only the default. Hide it and open the chat from any button or link on your site.

Simplest, no JavaScript: add the data-avalagent-open attribute to any element.

<!-- Any element: button, link, icon, menu item -->
<button data-avalagent-open>Chat with us</button>

<!-- Hide our floating launcher if you only want your own button -->
<script src="https://smflow.io/widget.js"
        data-business-id="YOUR_BUSINESS_ID"
        data-hide-launcher="true" defer></script>

The attribute also works on elements rendered later (React, Vue, any framework).

If you prefer code, these methods are available on window.AvalAgent:

// window.AvalAgent does not exist until the widget script has loaded.
// Listen for this event instead of polling:
window.addEventListener('avalagent:ready', function () {
  AvalAgent.open()          // open the chat
  AvalAgent.close()         // close it
  AvalAgent.toggle()        // open / close
  AvalAgent.isOpen()        // true / false
  AvalAgent.hideLauncher()  // hide our round launcher
  AvalAgent.showLauncher()  // bring it back
})

The widget loads with defer, so your code may run before it. Listen for avalagent:ready instead of polling.

Hiding our launcher: turn off "Show floating launcher" in the dashboard to hide it everywhere, or use data-hide-launcher="true" on the script tag or AvalAgent.hideLauncher() for specific pages.

7. Allowed domains

Restrict the widget to your own sites. One domain per line, without https://; subdomains of a listed domain are allowed automatically.

example.com
my-other-store.com
Privacy PolicyTerms of Servicesmflow.io