Remote API Tutorial
Change the chat behavior on each page using the Remote API
More on Userlike Widget Routing
You can take total control over the chat client's Webvisitor approach by using the Remote API. It enables you to configure the chat client for each individual page of your website. You are able to send 5 different events to the chat client to indicate which mode you want to run in. You have to hook a callback function which will be fired after the Userlike Widget Code has been loaded and the state machine is ready to accept your command.
Function | Description |
---|---|
userlike.userlikeRemoteApiModeNormal() | The chat will run in Normal Mode |
userlike.userlikeRemoteApiModeRegister() | The chat will run in Register Mode |
userlike.userlikeRemoteApiModeProactivePassive(timeout, message) | The chat will run in Proactive Mode |
userlike.userlikeRemoteApiModeProactivePassiveAndRegister(timeout, message) | The chat will run in Proactive Mode or Register Mode |
userlike.userlikeRemoteApiResetState() | Reset user state |
The events can be sent after you have been notified by the callback userlikeRemoteReady
. Your call will only have an effect once per page impression. It can be sent at any time after the callback. The ready callback will not be called if there is a running chat session and thus there is no need to configure the approach.
Normal Mode
This is the default chat mode. The chat button will be displayed based on your Chat Widget settings and a Webvisitor initiated chat is available.
Register Mode
This is the Register Mode. The chat button will be displayed based on your Chat Widget settings. A Webvisitor initiated chat is available and the Webvisitor is asked to fill out the registration form.
Proactive Mode
This is the Proactive Mode. The chat button will be displayed based on your Chat Widget settings. A proactive chat offer will be shown. You can pass a custom message and timeout. If you leave this out the default values will be used.
Mode Proactive & Register
This is the Proactive Mode. The chat button will be displayed based on your Chat Widget settings. A proactive chat offer will be shown. You can pass a custom message and timeout. If you leave this out the default values will be used. Furthermore, a Webvisitor initiated chat is available and the Webvisitor is asked to fill out the registration form.
Reset State
By default Userlike presents the proactive offer only once per browser session. Regardless the offer was canceled or accepted, no addtional proactive offer is triggered. To circumvent this you can reset the Webvisitors state to force a proactive offer.
Sample Implementation
Here is a pseudo sample code which combines 3 different chat modes using 2 distinct rules, based on your business logic.
- If the Webvisitor has a certain amount in his shopping cart, start a proactive chat session.
- If the Webvisitor is a returning user, start a proactive chat session.
- Otherwise just display the chat button.