> ## Documentation Index
> Fetch the complete documentation index at: https://docs.roserx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Starting a Chat with a Question

> Let visitors ask a question straight from your page, using suggested-question buttons, your own question box, or a link that carries the question.

Visitors don't have to open the widget first and then type. Your page can offer the question itself: the widget opens on the Chat tab and sends the question for them, exactly as if they had typed it.

There are three ways to do it:

* **Suggested-question buttons.** Add `data-roserx-question` to a button. Clicking it asks that question.
* **Your own question box.** Send whatever the visitor types into a field on your page with `window.RoseRx.open({ question })`.
* **Question links.** Add `?roserx_question=...` to your page's address, for example in an email or an ad, to open the chat with that question.

The wording of every question lives in your page, so you can change it whenever you like without touching the widget's settings.

## Before you start

* Your widget is **saved** and its status is **Active**.
* The RoseRx embed script is installed on the same page. See [Embedding Your Widget](https://docs.roserx.ai/guides/widgets/embedding.md).

> [!TIP]
>
> The **Embed** tab in the widget editor shows ready-to-copy examples under **Question box and suggested questions**. Each example already includes that widget's ID.

## Suggested-question buttons

Add the `data-roserx-question` attribute to a button, set to the question it should ask. Add `hidden` as well, so the button only appears once the widget is ready to answer.

```html theme={null}
<button type="button" hidden data-roserx-question="How should I store my medicine?">
  How should I store my medicine?
</button>

<button type="button" hidden data-roserx-question="What should I do if I miss a dose?">
  Missed a dose?
</button>
```

When a visitor clicks a button, the widget opens on the Chat tab and sends the attribute's text as their message. The button's label can be different from the question it sends, as in the second example.

* **Buttons stay hidden until the widget is ready.** The embed script removes `hidden` once the widget has loaded. If the widget cannot load, for example because it is inactive or the domain is not allowed, the buttons never appear, so visitors never see a button that does nothing.
* **Clicks inside the button count.** If your button contains an icon or a `<span>`, clicking those asks the question too.
* **The element's own click behavior is canceled.** A link with the attribute does not navigate anywhere.

If your site's CSS shows elements that have the `hidden` attribute, for example with a `display` rule on all buttons, add this rule so the buttons stay hidden until the widget is ready:

```css theme={null}
[data-roserx-question][hidden] { display: none !important; }
```

### Buttons your page adds later

The embed script reveals hidden buttons once, when the widget becomes ready. A button your page adds after that, for example from a single-page app or a modal, would stay hidden. For those buttons, leave out `hidden` and hide them with the `data-roserx-ready` CSS rule instead:

```html theme={null}
<style>
  html:not([data-roserx-ready]) .suggested-question { display: none !important; }
</style>

<button type="button" class="suggested-question" data-roserx-question="How should I store my medicine?">
  How should I store my medicine?
</button>
```

The embed script adds `data-roserx-ready` to the page's `<html>` element once the widget can take a question.

## Your own question box

If your page has its own "Ask a question" field, send what the visitor typed with `window.RoseRx.open()`:

```html theme={null}
<style>
  /* Hide the question box until the widget is ready. */
  html:not([data-roserx-ready]) .roserx-ask { display: none !important; }
</style>

<form class="roserx-ask" id="ask-form">
  <input type="text" id="ask-input" maxlength="2000" placeholder="Ask a question" />
  <button type="submit">Ask</button>
</form>

<script>
  document.querySelector("#ask-form").addEventListener("submit", function (event) {
    event.preventDefault();
    var input = document.querySelector("#ask-input");
    if (!input.value.trim()) return;
    if (window.RoseRx && window.RoseRx.open) {
      window.RoseRx.open({ question: input.value, triggerMethod: "text" });
      input.value = "";
    }
  });
</script>
```

| Option | What it does |
| - | - |
| `question` | The text to send as the visitor's message. Spaces at the start and end are removed. |
| `triggerMethod: "text"` | Records that the visitor typed the question into your own box. Leave it out when your code sends a fixed question, such as from a button. |
| `widget` | On a page with more than one widget, the ID of the widget that should answer. |

`open()` takes either a `question` or a `flow`, not both. If you pass both, the Appointment Finder starts and the question is ignored.

## Question links

Add `roserx_question` to the address of any page that has the widget. When someone follows the link, the widget opens with that question.

```text theme={null}
https://www.example.com/product?roserx_question=How%20should%20I%20store%20my%20medicine%3F
```

Use this in emails, ads, QR codes, or links from other sites. Encode the question for a URL, so spaces become `%20` and `?` becomes `%3F`.

### A link only sends questions your page offers

Anyone can write a link to your page, so a link is only allowed to send a question that your page itself offers. Otherwise the text is placed in the chat box, unsent, and the visitor chooses whether to press Send.

A question counts as offered when it exactly matches either:

* the `data-roserx-question` value of a suggested-question button on the page, or
* an entry in a hidden approved list on the page.

Use the approved list for questions you want links to send without showing a button for them:

```html theme={null}
<template data-roserx-questions>
  <li>How should I store my medicine?</li>
  <li>What should I do if I miss a dose?</li>
</template>
```

> [!NOTE]
>
> The match is exact, including capital letters and punctuation. Spaces at the start and end are ignored.

The `roserx_question` parameter is removed from the address bar as soon as the page loads, so the question is not kept in the visitor's address bar or recorded with the page URL. Other parameters, such as UTM tags, are left in place.

## How questions are handled

* **Sent exactly as written.** The question becomes the visitor's message, word for word. If the visitor already has a conversation in progress, the question is added to it.
* **Same safety checks as a typed message.** Guardrails and adverse event detection apply in the same way.
* **Long questions are never cut short.** A question longer than **2,000 characters** is placed in the chat box, unsent, for the visitor to review.
* **Questions asked mid-answer wait.** If the agent is still answering, or the Appointment Finder is starting, the question is placed in the chat box for the visitor to send.
* **HCP verification comes first.** On a widget with [HCP Verification](https://docs.roserx.ai/guides/widgets/hcp-verification.md), the question is held until the visitor is verified and then sent once. Reloading the page before verifying drops it.

> [!WARNING]
>
> If your agent starts its intake questions automatically when the chat opens, a question from your page can take the place of that automatic start, or be read as the answer to the first intake question. Avoid suggested questions on pages where the widget begins with intake.

## More than one widget on a page

Add `data-roserx-widget` to name the widget that should answer, in the same way as for [custom buttons](https://docs.roserx.ai/guides/widgets/custom-buttons.md#more-than-one-widget-on-a-page):

```html theme={null}
<button type="button" hidden
  data-roserx-question="How should I store Product A?"
  data-roserx-widget="WIDGET_ID_A">
  How should I store Product A?
</button>

<template data-roserx-questions data-roserx-widget="WIDGET_ID_A">
  <li>What should I do if I miss a dose of Product A?</li>
</template>
```

* **A button without `data-roserx-widget`** goes to the widget whose embed script loaded last.
* **A question link** also goes to the widget whose embed script loaded last. Buttons and approved lists that name a different widget do not count toward what the link may send.
* **`data-roserx-ready`** is set when the widget whose embed script loaded last is ready.

## Troubleshooting

> [accordion] My suggested-question buttons never appear
>
> * Confirm the RoseRx embed script is on the same page, the widget status is **Active**, and the page's domain is in the allowed list if domain restrictions are enabled. Buttons stay hidden when the widget cannot load.
> * 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 your page adds the buttons after it loads, see [Buttons your page adds later](#buttons-your-page-adds-later).

> [accordion] My buttons show before the widget is ready
>
> * Check each button has the `hidden` attribute.
> * Your site's CSS may be overriding `hidden`. Add `[data-roserx-question][hidden] { display: none !important; }`.

> [accordion] A link opens the chat but doesn't send the question
>
> * The question must exactly match a suggested-question button or an entry in the `<template data-roserx-questions>` list on that page, including capital letters and punctuation.
> * Check the question is URL-encoded in the link.
> * On a page with more than one widget, the link goes to the widget whose embed script loaded last. Check the button or list is not named for a different widget.

> [accordion] The question appears in the chat box instead of being sent
>
> * The question is longer than 2,000 characters, the agent was still answering, or the question came from a link the page has not approved. The visitor can press Send.

> [accordion] The console says window\.RoseRx is undefined
>
> * The embed script had not finished loading when your code ran. Guard the call with `if (window.RoseRx && window.RoseRx.open)`, and keep your question box hidden until `data-roserx-ready` is set.

## Next steps

> [card] [Custom Buttons](https://docs.roserx.ai/guides/widgets/custom-buttons.md)
>
> Open the widget, or the Appointment Finder, from your own buttons and links.

> [card] [Embedding Your Widget](https://docs.roserx.ai/guides/widgets/embedding.md)
>
> Install the embed script and set up domain restrictions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.