Widget Control
Programmatically open, close, hide, and show the chat widget.
Event Handling
Listen to user interactions and create custom integrations.
Customizing your user experience with the Remark SDK
The Remark SDK can also be used to control the state of the chat widget. You may wish, for example, to temporarily close the chat widget when displaying full-screen promotions or open the chat widget when a customer clicks on a certain call-to-action on your site. You can open, close, hide, and show the chat widget using one of the options in the following code.Opening the widget with options
In addition to simply opening the widget, you can pass options to control its initial state and behavior.This is helpful when you want to start the chat from a specific context, prefill a message, or automatically send a greeting.
Available options
- from – A string identifier for where or why the widget was opened (for example,
homepage,checkout, orcategory-page). Useful for analytics, tracking, or routing the conversation. - message – A string to prefill in the chat input. When paired with
mode: 'send', this message will be sent automatically. - mode – Controls message handling. Use
'send'to send immediately or omit to just prefill the input.
Listening for Remark Events
The remark-chat-widget element fires a number of “remark” namespaced events. To listen to any of them, place an event listener on the remark-chat-widget element, or anywhere higher on the DOM. On the element directlyListen to all Remark Events
To listen to all the events, you can use thewindow.remark.events.listenAll function. It takes a callback, called with every remark event. The payload received by the callback is an object:
- with an
event__typekey, one of the remark events listed below - any other details payload the event has with it
listenAll returns an object with an unsubscribe function. Calling that unsubscribe function will stop the callback from being called again.
List of Remark Events
| Event | Description |
|---|---|
remark:session-initialized | The Remark client has initialized, with basic information for our widgets |
remark:open-widget | Remark chat widget has opened |
remark:close-chat-from-header | Customer has closed the chat window via the chat header button |
remark:mute-chat | Fires when chat mutes or unmutes |
remark:dismiss-floating-prompts | Customer has closed the floating prompts on the activator |
remark:dismiss-unread-message | Customer has dismissed the unread message on the activator |
remark:finding-expert | Customer is waiting to be paired with an expert |
remark:send-message | Customer has sent a message |
remark:select-landing-prompt | Customer has selected a suggested question on the landing screen |
remark:view-expert-profile | Customer is viewing the expert profile |
remark:close-expert-profile | Customer has closed the expert profile |
remark:view-expert-gallery | Customer is viewing the expert’s gallery |
remark:submit-email | When the customer has submitted their email |
remark:submit-name | Customer has chosen to input their name |
remark:skip-name | Customer has chosen to skip inputting their name |
remark:skip-email | Customer has chosen to skip inputting their email |
remark:skip-phone | Customer has chosen to skip inputting their phone number |
remark:submit-nps | Customer has submitted a Customer Feedback Survey |
remark:edit-nps | Customer has edited a Customer Feedback Survey |
remark:cancel-nps | Customer has canceled editing a Customer Feedback Survey |