Home / Docs / Web Chat Widget
Setup Guide · Web Chat

Embed the chat widget on your website

Drop the MsgHub chat widget on any website in under 5 minutes. AI answers from your knowledge base, escalates to humans when needed, and feeds every conversation into the same inbox as your WhatsApp and Instagram chats.

~15 min Beginner-friendly Copy & paste — no coding Last updated: 2026-05-14

Overview

The MsgHub chat widget is a small JavaScript snippet you embed on your website. Visitors click the chat bubble, the AI answers using a chatbot flow you've wired up (with AI Reply / KB Lookup nodes), and unresolved conversations escalate to a human agent in the Inbox.

Four steps to get live:

  1. Configure the Chat Widget in MsgHub Settings.
  2. Get an API key from the API Keys page.
  3. Install the snippet on your website (HTML / WordPress / Shopify / Wix / Squarespace).
  4. Wire the connected chatbot flow + test end-to-end.

One widget per tenant. The widget configuration lives in Settings and applies wherever you embed the snippet — there's no per-site widget instance to create. If you need different widgets per site, you'd need separate tenants.

Prerequisites

Part 1 · Configure the Chat Widget

1

Open Chat Widget settings

  1. Login to https://app.msghub.info.
  2. Click Settings at the bottom of the left sidebar.
  3. Scroll to the Chat Widget section (subtitle: "Floating lead-capture widget for your website").
  4. Tick the Enabled checkbox at the top of the section.

Part 2 · Customise the look and feel

2

Heading, subtitle, colour, logo

  1. Heading — short headline shown at the top of the open chat. Default: "Chat with us".
  2. Subtitle — secondary line, e.g. "We typically reply within minutes".
  3. Button color — pick a hex code or use the colour picker. Defines the chat bubble background.
  4. Widget logo — paste an image URL or click the upload button. Shown in the widget header.
3

Position and timing

  • Position dropdown — Bottom Right (default) or Bottom Left. No horizontal offset setting.
  • Show delay (seconds) — how long after page load before the chat bubble appears. 0 = immediately. Useful to avoid distracting visitors during the first few seconds.
4

Pre-chat fields

Under Fields to show, tick which contact details you want from the visitor before they can chat:

  • Name
  • Phone
  • Email

Leave all unticked for fully anonymous chat (best for engagement). Tick what you need for lead capture.

Mandatory pre-chat forms reduce chat starts by ~50%. If lead capture matters more than engagement, tick fields. If conversion matters more, leave all unticked and ask for contact details mid-conversation through the AI flow.

Click Save at the bottom of the Settings page.

Part 3 · Get the install snippet

5

Generate an API key

The widget authenticates with a tenant API key (format mh_live_…).

  1. Sidebar → API Keys (it's a top-level sidebar item, not nested under Settings).
  2. Click + New API Key.
  3. Name it e.g. "Website widget".
  4. Tick scope contacts:write (creates contacts from chat) and messages:send (lets the widget trigger flows).
  5. Click Create. Copy the key immediately — shown only once.
6

Copy the embed snippet

In Settings → Chat Widget, scroll to the Embed snippet box at the bottom of the section. The snippet looks like:

<script>
  window.MsgHub = {
    apiUrl: "https://app.msghub.info",
    apiKey: "mh_live_YOUR_API_KEY"
  };
</script>
<script src="https://app.msghub.info/api/v1/widget.js" async></script>

Replace mh_live_YOUR_API_KEY with the key you generated in Step 5. Widget config (heading, colour, position, etc.) is fetched from MsgHub at runtime — when you change settings, they take effect immediately without re-embedding.

Install on plain HTML / custom site

  1. Open your website's main HTML template.
  2. Paste the snippet just before the closing </body> tag.
  3. Save and deploy.

Install on WordPress

Option A · MsgHub WordPress plugin (recommended): see the dedicated WordPress plugin install guide — paste your tenant API key in the plugin settings.

Option B · Manual snippet:

  1. WordPress admin → AppearanceTheme File Editorfooter.php.
  2. Paste the snippet before <?php wp_footer(); ?>.
  3. Save. If your theme uses a child theme, edit there instead so updates don't overwrite.

Install on Shopify

  1. Shopify admin → Online StoreThemesEdit code on your active theme.
  2. Open layout/theme.liquid.
  3. Paste the snippet just before the closing </body> tag.
  4. Save.

Install on Wix

  1. Wix Dashboard → SettingsCustom Code.
  2. Click Add Custom Code.
  3. Paste the snippet, name it "MsgHub Widget".
  4. Choose Add Code to Pages: All pages, place in Body — end.
  5. Apply.

Install on Squarespace

  1. Home menu → SettingsAdvancedCode Injection.
  2. Paste the snippet in the Footer field.
  3. Save.

Part 4 · Wire to a chatbot flow

7

Connect the widget to a chatbot flow

The widget itself doesn't have AI controls — AI lives in the Chatbot Flows sidebar item, and you wire the widget channel to a specific flow.

  1. Sidebar → Chatbot Flows.
  2. Open the flow you want to handle web-chat traffic, or create a new one with AI Reply / KB Lookup nodes (see AI Training).
  3. In the flow's settings, set the trigger channel to include Web Chat.
  4. Make sure the flow is Active.

Now incoming web-chat messages route through this flow. If the AI Reply node's confidence is low, the flow can hand off to a human via the Assign Agent node.

Part 5 · Test it end-to-end

8

Visit your live site

  1. Open your website in incognito / private mode (so you appear as a fresh visitor, not yourself).
  2. You should see the chat bubble in the corner. Click it.
  3. The welcome message and quick-reply chips appear.
  4. Type a real question your customers would ask. The AI should answer from your KB within ~3 seconds.
  5. Check MsgHub Inbox → the conversation should appear under the Web Chat channel.

Advanced configuration

Identify logged-in users automatically

If your visitor is already logged in to your site, call MsgHub.identify() after the script loads to create / update their contact record:

<script>
  window.MsgHub = {
    apiUrl: "https://app.msghub.info",
    apiKey: "mh_live_…"
  };
</script>
<script src="https://app.msghub.info/api/v1/widget.js" async></script>

<script>
  // Identify is queued if widget hasn't finished loading yet
  MsgHub.identify({
    phone: '+919812345678',
    email: '[email protected]',
    name:  'Riya Mehta'
  });
</script>

Phone or email is required. The widget creates a contact in MsgHub and links the chat to that record.

Track events from your site

Fire custom events tied to a contact — useful for triggering chatbot flows on specific actions (cart abandoned, viewed pricing, etc.):

MsgHub.track('cart.abandoned', { phone: '+919812345678' });

Don't want the widget on every page?

The widget script is global — once embedded, it runs on every page that loads the snippet. To exclude it on a specific page (checkout, thank-you), simply don't include the script tag on that page's template.

Troubleshooting common issues

Widget doesn't appear on the site

Widget appears but visitor messages don't reach the inbox

Widget styles look broken

Frequently asked questions

Do I need a developer to install the chat widget?

No. The widget is a 4-line script tag. WordPress users can paste it in Theme File Editor or use the MsgHub plugin. Shopify users paste it in theme.liquid. Wix and Squarespace have custom-code panels. Plain HTML sites paste once before </body>. Total install time under 5 minutes.

Does the widget slow down my website?

No. The script loads asynchronously and weighs ~24 KB gzipped. It does not block page rendering, and the chat UI only loads when the user clicks the bubble. Lighthouse performance impact is negligible.

Can I have multiple widgets — one per website?

One widget per tenant. The Chat Widget configuration in Settings applies wherever you embed the snippet. If you run multiple brand sites with different chat designs, you'd need separate MsgHub tenants. The same snippet can be embedded on multiple sites — they share the same widget design and inbox.

Will the widget conflict with WhatsApp or live-chat plugins I already have?

Visually they may overlap if positioned in the same corner — change MsgHub's widget to the opposite corner, or remove the other plugin. Technically the MsgHub widget runs in an isolated iframe and does not interfere with other JavaScript on the page.

Can visitors chat anonymously?

By default, yes — anyone can start chatting immediately. You can optionally enable a pre-chat form requiring name/email/phone before the conversation starts. Most businesses leave it anonymous to maximise engagement and ask for contact details mid-conversation once the visitor is engaged.

What happens after a visitor closes the browser tab?

If they shared an email or phone, the conversation continues whenever they return. If anonymous, a cookie persists for 30 days so a return visit picks up the same thread. Pure anonymous one-time visitors get a fresh thread on each visit.

Can the chat widget collect leads into my CRM?

Yes. Every visitor who shares contact info becomes a Contact in MsgHub. You can also push to external CRMs (HubSpot, Zoho, custom) via Settings → Integrations. Webhook events fire on every new conversation and contact creation.

What's next

Train the AI on your business
If you haven't trained the knowledge base yet, the widget will route every chat to a human agent. 45 minutes of training fixes that.
Add WhatsApp to your inbox
Web chat customers often want to continue on WhatsApp later. Wire both channels for one unified history.
Need design help with the widget?
We'll match the widget to your brand and pre-fill quick replies for your top 5 customer questions.