Documentation — MxChat Triggers

MxChat Triggers

Turn any element on your site into a chat trigger. Click a button, link, or image and MxChat opens with a predefined message already sent — no extra clicks, no blank chat windows for the visitor to puzzle over.

Overview

MxChat Triggers is the bridge between your page CTAs and your chatbot. Instead of relying on the floating chat bubble for every conversation, you sprinkle trigger elements throughout the site — on pricing pages, in blog posts, inside hero sections — and each one opens the chat pre-loaded with the right opening message. "Talk to Sales" sends a sales prompt. "Get Support" sends a support prompt. The visitor lands mid-conversation instead of staring at an empty input box.

Triggers are wired in three ways: an HTML data-mxchat-trigger attribute you can drop on any element, an [mxchat_trigger] shortcode for posts and page builders, and a JavaScript API for event-driven custom flows. With the Multi-Bot add-on installed you can also route each trigger to a specific bot.

Setup

  1. Install MxChat (the free mxchat-basic plugin) and activate your MxChat Pro license.
  2. Upload the mxchat-trigger folder to /wp-content/plugins/ (or install via the WP admin) and activate it.
  3. Go to MxChat -> Triggers in the WordPress admin sidebar.
  4. Confirm the Chat Triggers toggle is on (it is by default).
  5. Add your first trigger to any page: paste <button data-mxchat-trigger="Hello, I have a question">Ask a Question</button> into a Custom HTML block, page builder widget, or theme template.

That is the entire install. There is no per-trigger config inside the plugin — triggers live where you place them in your content.

Settings

The admin page is mostly reference material. The only stored setting is the global on/off switch.

Chat Triggers (enabled)

Master toggle that loads (or skips) the frontend trigger script. Default: on. When off, every data-mxchat-trigger attribute and [mxchat_trigger] shortcode on the site stops firing — useful for temporarily disabling all chat CTAs without editing posts.

Bot Selection (Multi-Bot only)

When the Multi-Bot add-on is active, a Bot Selection panel appears listing every available bot and its bot_id. Each row has a one-click copy button so you can paste the ID straight into a data-mxchat-bot-id attribute or bot_id shortcode parameter. Nothing is saved here — it is a reference index.

The plugin does not currently include behavioral auto-pop settings (time-on-page, scroll depth, exit-intent). Trigger elements fire on click; auto-pop behaviors would be added at the theme or page-builder level using the JavaScript API below.

Features

  • Data-attribute triggers: Drop data-mxchat-trigger="Your message" on any HTML element and a click on that element opens MxChat with the message pre-sent. Works on buttons, links, images, divs — anything clickable.
  • Open-only mode: Use data-mxchat-open (no value) to open the chat without sending a message — useful when you want the floating widget hidden but still need a "Chat with us" CTA somewhere on the page.
  • JavaScript API: Programmatic control via window.mxchatOpenAndSend(message), window.mxchatOpen(), window.mxchatSendMessage(message), and window.mxchatIsReady(). Build your own behavioral triggers (scroll, idle, exit-intent) on top of these.
  • Shortcode integration: [mxchat_trigger message="..." text="..." class="..." bot_id="..." open_only="yes"] renders a ready-made button. Works in posts, pages, widgets, Elementor text editors, and any builder that supports shortcodes.
  • Multi-Bot targeting: When the Multi-Bot add-on is installed, add data-mxchat-bot-id="sales_bot" (or pass bot_id to the shortcode/JS API) to route the trigger to a specific bot — so "Talk to Sales" opens the sales bot and "Get Help" opens support.
  • Built-in button styles: Three ready-to-ship CSS classes — mxchat-btn-primary, mxchat-btn-secondary, mxchat-btn-gradient — that look right out of the box and inherit your MxChat brand colors.
  • Animation classes: mxchat-trigger-shake, mxchat-trigger-pulse, and mxchat-trigger-bounce add subtle attention-grabbing motion to high-conversion triggers without any custom CSS.
  • Page-builder compatible: Works inside Elementor (Advanced -> Attributes), Divi (Code module), Beaver Builder (HTML attributes), Bricks, Kadence Blocks, and any builder that accepts custom HTML attributes or shortcodes.
  • Custom DOM events: Fires mxchat:trigger:open and mxchat:trigger:message events you can listen for in your own analytics or marketing-automation scripts.

API & Integration

data-mxchat-trigger HTML attribute

The primary integration surface. Add it to any element:

<button data-mxchat-trigger="I want to learn about pricing">Get Pricing</button>
<a href="#" data-mxchat-trigger="I need help with my order">Contact Support</a>
<img src="banner.jpg" data-mxchat-trigger="Tell me more about this promo" alt="Promo banner">

Supporting attributes:

  • data-mxchat-open (no value) — opens the chat without sending a message.
  • data-mxchat-bot-id="bot_id" — routes the trigger to a specific bot (requires Multi-Bot add-on).

JavaScript API

For custom behavioral triggers — scroll depth, time-on-page, exit-intent — wire your own logic to these functions:

window.mxchatOpenAndSend('Your message');     // open + send
window.mxchatOpen();                          // open only
window.mxchatSendMessage('Your message');     // send (chat must already be open)
if (window.mxchatIsReady()) { /* chat loaded */ }

// Multi-Bot variants:
window.mxchatOpenAndSend('Hello', 'sales_bot');
window.mxchatOpen('support_bot');

Custom events

document.addEventListener('mxchat:trigger:open',    function (e) { /* e.detail.botId */ });
document.addEventListener('mxchat:trigger:message', function (e) { /* e.detail.message, e.detail.botId */ });

Shortcode

[mxchat_trigger message="Hello!" text="Chat with Us" class="my-btn" bot_id="sales_bot" open_only="no"]

Requirements

  • MxChat (mxchat-basic): Required. Declared via WordPress's Requires Plugins header; the plugin will not load without it.
  • MxChat Pro License: Required. Without an active license the admin page shows an upgrade notice and no frontend triggers fire. Activate at MxChat -> Activation, or see /pricing/.
  • WordPress: 5.0 or newer.
  • PHP: 7.4 or newer.
  • Multi-Bot add-on: Optional. Only needed if you want per-trigger bot targeting via data-mxchat-bot-id or the bot_id shortcode parameter.

Troubleshooting

Trigger element does nothing on click

Check, in order: (1) MxChat Pro license is active (MxChat -> Activation) — if it is not, the frontend script never loads. (2) The Chat Triggers toggle on MxChat -> Triggers is on. (3) View the page source and confirm the data-mxchat-trigger attribute survived your page builder's sanitization — some builders strip unknown data- attributes. (4) Open the browser console and run window.mxchatIsReady() — if it returns undefined, the MxChat core script is not loading on that page (theme conflict or chatbot disabled per-page).

Multi-Bot trigger opens the default bot instead of the target bot

Verify the Multi-Bot add-on is active and the bot_id exists in MxChat -> Triggers -> Bot Selection. Copy the ID directly from that panel — typos and stale IDs are the usual cause. Also confirm window.mxchatTriggers.multiBot is true in the console; if it is false, the Multi-Bot plugin is not loaded on the frontend.

Conflicts with other modal or popup plugins

Other modal plugins that intercept clicks (OptinMonster, popup makers, sticky bars) can swallow the click event before MxChat sees it. Add the trigger element outside the competing modal's wrapper, or raise the trigger handler priority by binding via the JavaScript API (element.addEventListener('click', () => window.mxchatOpenAndSend('...'))) instead of the data attribute.

Page-builder strips the data attribute

Elementor, Divi, and Beaver Builder all have an Attributes / Custom HTML field on each widget — use that field rather than typing the attribute into the Text mode of a rich-text editor, which can sanitize it away. As a fallback, drop a Custom HTML / Code block with the raw <button> markup.


Last reviewed by Sage on 2026-05-21. Spotted an issue? Open a ticket and we'll patch the doc.