Docs

Widget JavaScript API

Once the widget script has loaded, it exposes window.Chatmefy (also available as window.ChatmefyWidget). Use it to control the chat from your own buttons and to send events.

Open and close the chat

your-page.js

// Open the chat, for example from a "Talk to us" button
window.Chatmefy.open();

// Close it
window.Chatmefy.close();

// Open if closed, close if open
window.Chatmefy.toggle();

Track events

Send your own events with optional properties. They are stored with the visitor and can trigger flows.

window.Chatmefy.track("pricing_viewed", { plan: "professional" });

Identify a visitor

If the visitor is signed in on your site, pass their ID and any traits you want your team to see.

window.Chatmefy.identify("user_4417", {
  name: "Emma Clarke",
  email: "emma.clarke@example.com"
});

Wait for the widget

The script loads asynchronously. Check that window.Chatmefy exists before calling it:

function openChat() {
  if (window.Chatmefy) window.Chatmefy.open();
}