Skip to main content
A guide is Moss walking a user through a task on your page, one step at a time, by highlighting the element to use next. This page covers what your users see during a guide, what ends one, and what you set up so a chat and a guide survive page loads. The most common setup: mount AgentProvider once near the root of your app, above your router, and turn on stability.afterReload so a guide step whose click loads a new page carries on there.

How a guide runs

  1. The offer. When Moss’s answer to a question comes with a plan of steps on the page, Moss offers a guide: the answer gets a Start guide button. chrome.guideOffer changes its label and icon; see Appearance.
  2. The start. The guide starts when the user clicks Start guide, or says yes in the chat. Moss shows the plan in the guide bar and highlights the first step’s element.
  3. Each step. Moss outlines the element to use and adds a numbered badge when a step has several targets. The user completes the step by using the highlighted element. A step with nothing to click shows Next with “Click Next when you’re ready.”
  4. Between steps. Moss waits for the page to settle, then reads it again and highlights the next step. The guide bar shows “Working…” meanwhile.
  5. The end. When every step is done, the guide bar shows “Goal Complete!” with a rating and Done.
An answer offers a guide only when two dashboard switches are on, both under Configure > Behavior: A new application has Enable Planning off, so turn it on to get guides.

What the user sees

The Appearance page has the details of each key.

Your own guide controls

useAgent() exposes the guide state and actions, so your page can show its own controls:
  • planPhase: 'offered' while a guide is offered, 'executing' while it runs, null when there is none, and undefined until Moss has reported one.
  • acceptGuideSuggestion() starts an offered guide, like Start guide.
  • continueGuide() moves to the next step, like Next.
See Hooks.

What ends a guide

closingChatEndsGuide

With the default false, a guide keeps running while the chat is closed. That suits a page that shows guide controls of its own while the chat is closed, such as FloatingActionBar. A reload brings the guide back. With true, closing the chat ends a running guide the way Exit guide does, however the chat is closed: the chat’s close button, AssistantButton, a data-moss-trigger element, or your code calling closeChat() or toggleChat(). The highlight comes off, a click on the step’s element sends nothing, and a reload doesn’t bring the guide back. Reopening the chat continues the conversation with no guide running. Set it to true if your page has no guide controls of its own: otherwise a user who closes the chat mid-guide is left with a highlight and nothing on screen that explains it.

Reloads, redirects and new tabs

Moss keeps its state in the browser, per origin: the chat session in localStorage, and the chat’s open or closed state and the window’s position in sessionStorage, which is per tab.

stability.afterReload

If the next page takes longer than pendingTTL to load Moss, for example behind a slow sign-in redirect, raise it.

Loading Moss on demand

Some apps mount Moss only when the user asks for it, from a help menu for example. Then a reload or a link to another page leaves Moss unmounted in the middle of a conversation or a guide. shouldStartMoss() tells you, as the page loads, whether Moss should be mounted to carry on.
mossConfig is the config you pass AgentProvider, with stability.afterReload.enabled: true. shouldStartMoss() returns true when:
  • the chat was open in this tab before the page changed;
  • a question asked with askMoss() in this tab is waiting;
  • a guide is running in this tab;
  • a guide step is on its way to this page after a reload or a guide navigation, or a guide step’s click opened this page in a new tab.
Rules:
  • Mount once, and leave it alone. When it returns true, mount AgentProvider without opening or toggling the chat: Moss reopens the chat and continues the guide by itself, and a toggle would close it. Later, open the chat of the Moss you mounted with openChat() instead of mounting again.
  • It needs stability.afterReload.enabled: true for guide steps to carry over.
  • If you set stability.afterReload.pendingTTL, pass the same value: shouldStartMoss({ pendingTTL }).
  • Call it in the browser. On a server, or anywhere without window, it returns false. With server rendering, call it after hydration.
  • It only reads. It reads browser storage that Moss writes, writes nothing and never throws. It returns false when storage can’t be read. Don’t write or clear Moss’s storage keys yourself.
  • Same origin only. Another host name has its own storage, so the check returns false there.

The @viamoss/moss-sdk/start entry point

Import shouldStartMoss() and askMoss() from @viamoss/moss-sdk/start. That entry contains no React and touches no DOM as it loads, so deciding whether to load Moss doesn’t load the SDK first. The package root exports both functions too. These functions are for the npm package. The CDN script mounts Moss on every page it loads on.

Opening Moss with a question

askMoss(question) starts a new chat, opens it, and sends the question as the user’s first message, whether or not Moss is mounted yet. Use it when your own help widget or assistant hands a question to Moss.
What Moss does with the question:
  • Any chat or guide in progress ends, the way the New chat button ends it, with no rating or “continue this chat” prompt first.
  • It is sent once, in the tab that asked. If the page reloads or navigates in that tab first, Moss on the next page sends it, within the wait. shouldStartMoss() returns true while it waits.
  • It is user text. Moss trims it, shows it as plain text, never as HTML, and sends it like a typed message.
  • A later call replaces a question that hasn’t been sent yet. If the user closes the chat or starts a new chat before it is sent, it is dropped.
  • With onEvent, it fires Moss Question Asked with source: 'host' as its request goes out. See Events.
  • Don’t toggle the chat on mount. Moss opens the chat for the question; a toggle would close it and drop the question.
  • Same window and origin. Call askMoss() in the same window and on the same origin as Moss. To tell tabs apart, it reads window.name, and names the window when it has no name.
askMoss() loads no React, mounts nothing and never throws.

FloatingActionBar

FloatingActionBar is an optional component that shows Moss at the bottom of the page while the chat is closed. It suits a guide the user follows with the chat closed.
How it behaves:
  • It is centered at the bottom of the browser window and hidden while the chat is open.
  • It peeks from the bottom edge, and shows in full on hover. A click keeps it shown; a click on the shown bar opens the chat.
  • It shows Moss’s latest answer, or “Have a question? Get a quick answer from our AI assistant!” before there is one.
  • It shows Guide me when a guide is offered, Next during a guide, and Done when the guide is complete.
  • It has no Exit control, so leave closingChatEndsGuide at false when you use it.
  • It renders in your page’s DOM, outside the widget’s shadow root. It is available in the npm package only.

Stability settings for guides

Before each turn, and after each guide step, Moss waits for the page to settle before it reads it. On a page that loads content in steps, this wait decides whether Moss sees the next step’s element. Tune it under stability. The full layer reference is in Advanced. The loading-indicators layer looks for [class*="skeleton" i], [class*="loading"], [class*="spinner" i], [class*="placeholder"], [aria-busy="true"], [data-loading="true"], .shimmer, .pulse and [class*="loader" i]. The placeholder guard runs whether or not the loading-indicators layer is on. It looks for [class*="skeleton" i], [data-testid*="skeleton" i], [class*="shimmer" i], .placeholder-glow, .placeholder-wave, [aria-busy="true"] and [data-loading="true"]. If you set loadingIndicators.selectors, the guard uses that list instead. After the guard times out, Moss reads the page anyway.
An element that always matches a loading selector, such as a permanent spinner or an element with “loading” in its class name, holds the wait until it times out on every turn. Add it to excludeSelectors.

Common questions

Why didn’t Moss offer a guide? Moss offers a guide only when its answer comes with a plan of steps on the page, and only when two switches under Configure > Behavior are both on: On-screen guidance in Core Features (on by default) and Enable Planning in Plan Progress Tracking (off by default). A new application needs Enable Planning turned on. How do I end a guide when the user closes the chat? Set closingChatEndsGuide: true. By default a guide keeps running, with its highlight, while the chat is closed. Moss loses the guide when a step loads a new page. How do I keep it? Set stability.afterReload.enabled: true, and make sure the page that loads mounts AgentProvider. If you mount Moss on demand, call shouldStartMoss() as each page loads. Moss starts closed in a new tab. Is that expected? Yes. Each tab keeps its own open or closed state, and a tab your page opens with window.open() starts closed with no guide. The exception is a tab opened by a guide step’s click, which continues the guide when stability.afterReload.enabled is on. How do I open Moss with a question from my own help menu? Call askMoss(question) from @viamoss/moss-sdk/start. It works whether or not Moss is mounted yet. Can users minimize the chat during a guide? From 0.17.0, with appearance.chrome.guide.minimize: true, in the floating layout. See Appearance.
  • Appearance: guide offer, highlight color, badges, Next placement, minimize
  • Sessions: timeouts and what happens when a user comes back
  • Events and errors: Moss Plan events
  • Hooks: openChat(), closeChat(), continueGuide()