Corresponding Calls for Chat Buttons

Make sure your chats start correctly by aligning your calls when using buttons, direct-to-agent, and agent with fallback-to-button.

Keep in mind that the syntax for startChat also applies to startChatWithWindow, and the syntax for showWhenOnline also applies to showWhenOffline.

Use the following corresponding calls when you’re creating chats with a button, direct-to-agent, and agent with fallback-to-button:

Scenario Call to startChat (or startChatWithWindow) Call to showWhenOnline (or showWhenOffline) Call to addButtonEventHandler
Button startChat(String buttonId) showWhenOnline(String buttonId, Object element, (optional) String userId) addButtonEventHandler( String buttonId, Function callback)
Agent (no fallback) startChat(String buttonId, String userId, false) showWhenOnline(String userId, Object element) addButtonEventHandler( String userId, Function callback)
Agent (fallback to button) startChat(String buttonId, String userId, true) showWhenOnline(String buttonId, Object element, String userId) Use multiple handlers.