onEventreceives usage events, such as a question asked, an answer delivered or a guide finished, for your analytics tool.onErrorreceives every problem the chat shows the user, with who can fix it and a reference for support.
Send events to your analytics
PassonEvent in the AgentProvider config. Each call receives one event, { name, properties }. Names follow Segment’s “Object Action” style, and properties are camelCase, so most analytics tools take them as they are.
moss_question_asked.
MossEvent is a union narrowed by name, so TypeScript knows each event’s properties:
window.mossSettings before the script loads:
How events are delivered
- Each event is delivered from a microtask, after Moss’s own work for it. Your handler never runs inside Moss’s code.
- If your handler throws, or returns a promise that rejects, Moss logs a warning and carries on. The chat is not affected.
- Moss reads your handler and
eventQueryTextwhen it delivers each event, so a new function you pass takes effect without remountingAgentProvider. - With Moss open in several tabs, guide events come from the tab the guide runs in.
Common properties
Every event carries these properties:Event catalog
MOSS_EVENT_NAMES, exported by the SDK, lists every name.
Details for some events:
Moss Question Asked:modeis'guide'while a guide is running.queryTextis present only if you opt in; see Question text.Moss Answer Delivered:latencyMsruns from the question being sent to the answer arriving.hasHighlightmeans the answer points at an element on the page;hasCitationmeans it cites help articles.messageIdis the answer’s message, the oneMoss Feedback Givenrates. It is absent when the answer adds no message, such as a highlight alone, or when its text waits for the user to take a step.Moss Plan Finished:completedwhen Moss reports the guide complete or the user finishes it.abandonedwhen the user exits, the conversation ends (a new chat, including oneaskMoss()starts or one Moss starts after inactivity), Moss replaces the guide with another, or a support ticket the user files from the guide goes out.Moss Feedback Given: from 0.17.0, withchrome.feedback.askWhatWentWrong, a thumbs-down the user explains is sent again for the same message with itsreason:'steps_mismatch','hard_to_follow','not_solved','wrong_answer','not_answered'or'other'. With it on, a thumbs-down on a finished guide’s “Goal Complete!” card that the user explains also fires this event, withrating: 'down'and thereason, for the guide’s last answer. The user’s comment is never sent to your page, and neither is the session rating.Moss Ticket Submitted:filedmeans youronSupportTicketconfirmed the ticket.failedmeans your callback reported a failure, or the submit was refused or not sent.unconfirmedmeans nothing confirmed the outcome, for example because your callback timed out or threw, so the ticket may exist. See Support ticket handoff.
Moss Error types
Question text
What a user types can contain personal or customer data, soMoss Question Asked leaves the text out unless you opt in with eventQueryText:
onError
onError is called for every problem the chat tells the user about: a turn that failed, an answer written without one of its tools, a request that never reached the server. It is new in 0.17.0.
onError is delivered like onEvent: from a microtask, with a handler that throws or rejects logged and ignored.
The error object (MossError)
In the chat, the user sees the same problem under the message: what went wrong, “Your admin can fix this in Moss.” or “This is a problem on Moss’s side and has been reported.” when they can’t fix it themselves, and the reference. The chat offers Retry when sending again can help, and Continue when a procedure stopped before it was done.
onError isn’t called when the chat can’t connect at all. Listen for Moss Error with a connection_* type for that.
Codes
Service is the name of the connected service, such as your support desk or an API connection.
sign_in_failed usually means your page’s token was refused: check getJwt and your token’s claims. See Authentication.
Stability of names
Event names and properties are a public contract. Renames and removals are announced in the release notes ahead of the release that makes them. New events and new optional properties can ship in any release, so a tracking plan should accept events and properties it doesn’t know yet.Common questions
How do I send Moss usage to Segment, Amplitude or Google Analytics? PassonEvent and forward each event to your tool’s track call. See Send events to your analytics.
Can I see what users asked?
Only if you opt in: set eventQueryText to 'include', or to a function that redacts the text first.
Does an error in my handler break the chat?
No. Moss catches it, logs a warning and carries on.
Why do I get no Moss Question Asked for Start guide or Next?
They aren’t questions. Guide progress is reported by the Moss Plan events.
How do I find out when users hit problems?
Pass onError. Each call says what failed, who can fix it and the reference to quote to support. For a chat that can’t connect at all, listen for Moss Error with a connection_* type.
Related
- Appearance:
chrome.feedbacksets what a rating asks for - Guides and navigation:
askMoss()and guide events - Support ticket handoff
- Types