Chat
Chats have become one of the most popular channels of communication and now you have the possibility to use it to get in touch with the visitors to your website. Users will see a small icon that displays the chat window in the bottom-right corner of your website. It’s a great way of providing your customers or potential customers with real-time assistance.
Configuration
- Log in to the Synerise application.
- Go to
Settings > Tracking Codes and create a new tracking code.
- Go to
Settings > Chats and add
mobilechat.snrbox.com
as a whitelist domain. - In the same Chats section, adjust the chat settings to your preferences.
Chat Options
The Chat
class is responsible for defining the appearance and options.
Parameter | Type | Default | Description |
---|---|---|---|
trackerKey | String |
null | A tracking code from the Tracking Codes section |
toolbarBackgroundColor | Integer |
#000 | Toolbar background color |
toolbarTitleColor | Integer |
#fff | Toolbar title color |
toolbarTitle | String |
‘Chat’ | Toolbar title |
closeButtonAlignment | Integer |
RelativeLayout.ALIGN_PARENT_LEFT | Close button alignment |
closeButtonText | String |
‘Close’ | Close button text |
errorText | String |
‘An unknown backend communication error has occurred. Try again in a moment.’ | Default error text |
errorTextColor | Integer |
#FF0000 | Error label color |
color
format should contain a reference to a resource ID.
setCloseButtonImage(Drawable drawable)
- Sets a close button image.
Public Interface
load()
- Starts loading chat data.
show()
- If the widget is loaded, the chat window is shown. Otherwise it shows loading indicator.
hide()
- Hides the chat window.
Listener
OnChatListener
is used to inform developers about the state of a chat.
onLoad()
- Called after the chat is loaded.onLoading()
- Called when the chat is loading its content.onError(Error error)
- Called when an error occurs while loading.
Sample Implementation
private void initializeChat() {
Chat chat = new Chat("5C89955F-9C9F-86A6-607D-211DED21F7BF");
chat.toolbarBackgroundColor = R.color.charcoal;
chat.toolbarTitleColor = R.color.white;
chat.toolbarTitle = "Chat Communicator";
chat.closeButtonAlignment = RelativeLayout.ALIGN_PARENT_LEFT;
chat.setCloseButtonImage(ContextCompat.getDrawable(Synerise.getApplicationContext(), R.drawable.ic_arrow_back));
chat.closeButtonText = "CloseButton";
chat.errorText = "Sorry for problems!";
chat.errorTextColor = R.color.amaranth;
chat.setChatListener(new OnChatListener() {
@Override
public void onLoad() {
chat.show();
}
@Override
public void onError(Error error) {
}
@Override
public void onLoading() {
}
});
chat.load();
}
private fun initializeChat() {
val chat = Chat("5C89955F-9C9F-86A6-607D-211DED21F7BF")
chat.toolbarBackgroundColor = R.color.charcoal
chat.toolbarTitleColor = R.color.white
chat.toolbarTitle = "Chat Communicator"
chat.closeButtonAlignment = RelativeLayout.ALIGN_PARENT_LEFT
chat.setCloseButtonImage(ContextCompat.getDrawable(Synerise.getApplicationContext(), R.drawable.ic_arrow_back))
chat.closeButtonText = "CloseButton"
chat.errorText = "Sorry for problems!"
chat.errorTextColor = R.color.amaranth
chat.setChatListener(object:OnChatListener() {
fun onLoad() {
chat.show()
}
fun onError(error:Error) {}
fun onLoading() {}
})
chat.load()
}