Skip to main content
By default, visitors open the widget by clicking the RoseRx launch button. If your website already has its own buttons or links, such as a “Chat with us” link in your header or a “Talk to a doctor” button on a product page, you can make those open the widget too. There are two ways to do it:
  • An HTML attribute. Add data-roserx-open to an existing button or link. No JavaScript needed.
  • JavaScript. Call window.RoseRx.open() from your own code.

Before you start

  • Your widget is saved and its status is Active.
  • The RoseRx embed script is installed on the same page as your button. See Embedding Your Widget.
The Embed tab in the widget editor shows ready-to-copy examples of these attributes under Custom Button. Each example already includes that widget’s ID, so it also works on a page with more than one widget.
Add the data-roserx-open attribute to the element you want to open the chat.
When a visitor clicks it, the widget opens exactly as if they had clicked the RoseRx launch button.

Which elements it works on

The attribute works on any HTML element: <button>, <a>, <div>, <span>, <img> and so on.
  • Clicks inside the element count. If your button contains an icon or a <span>, clicking those opens the widget too.
  • Elements added later work. Buttons rendered after the page loads, for example by a single-page app, a modal, or a cookie banner, work without any extra setup.
  • The element’s own click behavior is canceled. A link with the attribute does not navigate anywhere, which is why href="#" is fine. A submit button inside a form does not submit the form.
For accessibility, use a <button> or an <a>. A <div> or <span> responds to mouse clicks and taps, but keyboard and screen-reader users cannot reach it unless you add tabindex="0", a role, and your own keyboard handling. A disabled button does not respond to clicks, so it will not open the widget.

Open straight into the Appointment Finder

If your agent uses the Appointment Finder, you can open the widget and start the Appointment Finder in one click. Set the attribute’s value to appointment-finder:
This only works when the widget’s assigned agent is set up for it:
  • The agent is a patient agent.
  • In the agent’s Workflows settings, the Sub-agent is set to Appointment Finder.
  • At least one care pathway, Telehealth or In-Person, is enabled under Care Workflows.
If any of these is missing, the button still opens the widget, but the Appointment Finder does not start. The browser console shows RoseRx: Appointment Finder is not enabled for this widget.
The Embed tab only shows the Appointment Finder example when the assigned agent meets these requirements. If you don’t see it, check the agent’s Workflows settings.

Option B: Open the widget with JavaScript

Use this when opening the chat is part of your own code, for example after a visitor completes a form or reaches a certain step on your page. The embed script adds these functions to the page:
The Appointment Finder option has the same requirements as the appointment-finder attribute value above. On a page with more than one widget, add the widget option to choose which widget opens. See More than one widget on a page.
window.RoseRx.open only exists once embed.js has loaded, so guard your call as shown above. If the widget is still starting up when you call open(), the request is held and carried out as soon as the widget is ready. If the widget cannot load at all, for example because it is inactive or the domain is not allowed, the call does nothing.

Hiding the default launch button

If you want visitors to open the widget only from your own buttons and links, add data-hide-button="true" to the RoseRx script tag:
The RoseRx launch button is no longer shown, but everything else keeps working: your custom buttons, the JavaScript functions, and conversations that continue across page loads.
With the launch button hidden, your own buttons are the only way to open the widget. Make sure every page that loads the embed script has at least one of them.

More than one widget on a page

You can embed several different widgets on the same page, for example one for each of your products. Add each widget’s embed script once, then add data-roserx-widget to each of your buttons, set to the ID of the widget it should open.
Each widget can have as many buttons as you need. From JavaScript, pass the widget ID in the widget option:
How a page with several widgets behaves:
  • One widget is open at a time. Opening a widget closes any other widget that is open.
  • Each widget keeps its own conversation. Visitors can switch between widgets without losing either chat.
  • A button without data-roserx-widget opens the widget whose embed script loaded last. On a page with one widget, that is the only widget, so the attribute is optional there. On a page with several widgets, always set it.
  • window.RoseRx.close() with no widget named closes whichever widget is open.
  • Your own user ID reaches every widget. One call to window.RoseRx.setExternalUserId() sets it for all the widgets on the page, including a widget whose embed script loads after the call. See Passing Your Own User ID.
A widget’s ID is the data-widget value in its embed code. The examples on the widget’s Embed tab already include it.
Two default launch buttons in the same position sit on top of each other. Hide them with data-hide-button="true" and use your own buttons, as in the example above, or give each widget a different Position under Button configuration in Customizing Your Widget.

Troubleshooting

  • Confirm the RoseRx embed script is on the same page as the button.
  • Confirm the widget status is Active, and that the page’s domain is in the allowed list if domain restrictions are enabled.
  • Check the attribute is spelled exactly data-roserx-open.
  • If the button has a data-roserx-widget attribute, check its value exactly matches the data-widget value in that widget’s embed code. If no widget on the page has that ID, nothing opens and the console shows RoseRx: No widget "WIDGET_ID" is on this page.
  • If the element is a <button>, check it isn’t disabled.
  • Open your browser’s developer console and check for error messages.
  • Check the attribute value, or the flow option, is exactly appointment-finder. Any other value opens the widget normally and logs RoseRx: Unknown widget flow. in the console.
  • Check the agent meets the requirements in Open straight into the Appointment Finder.
  • The embed script had not finished loading when your code ran. Guard the call with if (window.RoseRx && window.RoseRx.open), or use the data-roserx-open attribute instead, which needs no timing.
  • Add data-roserx-widget to the button, set to the ID of the widget it should open. Without it, the button opens the widget whose embed script loaded last.
  • For window.RoseRx.open(), pass the ID in the widget option.

Next steps

Embedding Your Widget

Install the embed script and set up domain restrictions.

Workflows

Set up the Appointment Finder and care pathways for your agent.