Skip to main content

better_messages_live_chat_button

Live chat button shortcode

Universal button for starting a new conversation or continuing an existing one (matched by unique_tag) with any user on your website. This is the recommended shortcode for adding chat buttons — it supersedes better_messages_pm_button and better_messages_mini_chat_button.

Behavior depends on plugin settings and visitor state:

  • Logged-in user: opens a mini chat when Mini Chats is enabled, otherwise opens the full chat page.
  • Guest visitor with Guest Chat enabled: shows the guest authorization modal, then opens the chat as above.
  • Guest visitor with Guest Chat disabled: redirects to the WordPress login page.

To target an AI chat bot, set user_id to the bot's negative user ID (shown in WP Admin → Better Messages → AI Chat Bots → edit bot → Bot User ID).

AttributeWhats it forDefault
textSets button text label"Live Chat"
user_id

Set User ID with whom conversation will be started

Post author of WordPress Post/Page
typeType of html element, can be button on linkbutton
subject

Set subject for conversation
If conversation already exists it will be ignored

None
target

HTML a target attribute

None
unique_tag

This will be usefully if you want to create unique conversations between buyers and seller, when they're discussing different products.


For example set unique_tag to product_123 to create or open additional unique conversation between 2 members based on the tag.

None
class

Sets additional class to button html element.
Useful for additional CSS styling.

None
[better_messages_live_chat_button type="button" unique_tag="product_chat_15" text="Product Chat" user_id="5" subject="Product Chat Subject"]

Examples

Author bio "Live Chat" button

[better_messages_live_chat_button text="Live Chat with me"]

Defaults to the post author. Drop into a bio box.

Marketplace per-product chat button

[better_messages_live_chat_button user_id="42" unique_tag="product_15" text="Ask vendor about this product" subject="Question about product 15"]

Each product gets a unique conversation with the vendor — buyers can have separate threads per product purchase context.

AI chat bot launcher

[better_messages_live_chat_button user_id="-3" text="Chat with our AI"]

Replace -3 with the negative bot ID from WP Admin → Better Messages → AI Chat Bots. Clicking starts a conversation with the bot.

[better_messages_live_chat_button type="link" text="Contact" target="_blank"]

Renders as a plain <a> tag opening in a new tab.

Frequently asked questions

How is this different from the legacy shortcodes?

It auto-decides based on plugin settings (mini-chat vs full page), handles guests properly, supports AI bots via negative user IDs, and is the actively-maintained shortcode. The legacy ones (pm_button, mini_chat_button) are deprecated.

What is the unique_tag attribute for?

Creates a separate conversation thread per tag, even between the same two users. Useful for marketplace per-product chats, per-order support, per-asset coaching, etc.

Does this work for guests?

Yes — if Guest Chat is enabled, the button shows the guest auth modal first. If Guest Chat is disabled, the button redirects to login.

Can I target an AI bot?

Yes — set user_id to the bot's negative user ID (from the bot's settings page). Clicking opens a conversation with the bot.

What if I want the button styled like my theme's primary button?

Use the class attribute: class="btn btn-primary" (or your theme's button class names). The button inherits theme styles.

See also