public interface

ChatClient

com.salesforce.android.chat.core.ChatClient

Class Overview

ChatClient enables the interaction with the Chat Session. Receiving an instance of ChatClient via the createClient(Context) method means that the Chat Session has been created and the calls made to your ChatClient instance will impact the session, or retrieve information pertinent to the session.

Supported Behavior:

  • Sending a chat message to the agent
  • Scrubbing chat message text in accordance with Sensitive Data Rules as configured in your Salesforce Org
  • Informing the agent that the user is typing
  • Ending the chat session

Events supported by AgentListener:

  • Information about the agent when they have joined the session
  • Chat message received from the agent
  • When the agent starts and stops typing

Events supported by SessionStateListener

  • The current and previous session state
  • When the session has ended

Summary

Public Methods
abstract ChatClient addAgentListener(AgentListener agentListener)
Register an AgentListener with this ChatClient to receive chat messages and information about the agent.
abstract ChatClient addChatBotListener(ChatBotListener chatBotListener)
Register a ChatBotListener with this ChatClient to receive menus from a Chat Bot.
abstract ChatClient addFileTransferRequestListener(FileTransferRequestListener fileTransferRequestListener)
Register a FileTransferRequestListener with this ChatClient to receive File Transfer Requests from an agent.
abstract ChatClient addQueueListener(QueueListener queueListener)
Register a QueueListener with this ChatClient to receive queue position updates for the chat session.
abstract ChatClient addSessionInfoListener(SessionInfoListener sessionInfoListener)
Register a SessionInfoListener with this ChatClient to receive session information.
abstract ChatClient addSessionStateListener(SessionStateListener sessionStateListener)
Register a SessionStateListener with this ChatClient to receive state changes for the chat session.
abstract void endChatSession()
End the chat session.
abstract ChatSessionState getCurrentSessionState()
Returns the current state of the chat session.
abstract ChatClient removeAgentListener(AgentListener agentListener)
Unregister an AgentListener from this ChatClient instance.
abstract ChatClient removeChatBotListener(ChatBotListener chatBotListener)
Unregister a ChatBotListener from this ChatClient instance.
abstract ChatClient removeFileTransferRequestListener(FileTransferRequestListener fileTransferRequestListener)
Unregister a FileTransferRequestListener from this ChatClient instance
abstract ChatClient removeQueueListener(QueueListener queueListener)
Unregister a QueueListener from this ChatClient instance.
abstract ChatClient removeSessionInfoListener(SessionInfoListener sessionInfoListener)
Unregister a SessionInfoListener from this ChatClient instance.
abstract ChatClient removeSessionStateListener(SessionStateListener sessionStateListener)
Unregister a SessionStateListener from this ChatClient instance.
abstract Async<Void> sendButtonSelection(ChatWindowButtonMenu.Button button)
Inform the Chat Bot of a button selection by providing the button as received via onChatButtonMenuReceived(ChatWindowButtonMenu).
abstract Async<Void> sendButtonSelection(int buttonIndex)
Inform the Chat Bot of a button selection by providing the button index and label as received via onChatButtonMenuReceived(ChatWindowButtonMenu).
abstract Async<ChatSentMessageReceipt> sendChatMessage(String message)
Send a message to the agent.
abstract Async<Void> sendFooterMenuSelection(ChatFooterMenu.MenuItem menuItem)
Inform the Chat Bot of a footer menu selection by providing the menu item as received via onChatFooterMenuReceived(ChatFooterMenu).
abstract Async<Void> sendFooterMenuSelection(int itemIndex, String dialogId)
Inform the Chat Bot of a footer menu selection by providing the menu item index and dialog ID of the selected item.
abstract Async<Void> sendMenuSelection(ChatWindowMenu.MenuItem menuItem)
Inform the Chat Bot of a menu selection by providing the menu item as received via onChatMenuReceived(ChatWindowMenu).
abstract Async<Void> sendMenuSelection(int itemIndex)
Inform the Chat Bot of a menu selection by providing the menu item index of the selected item.
abstract Async<Void> sendSneakPeekMessage(String sneakPeekMessage)
Send a message preview to the agent.
abstract Async<Void> setIsUserTyping(boolean isUserTyping)
Inform the agent whether or not the user is currently typing.

Public Methods

public abstract ChatClient addAgentListener (AgentListener agentListener)

Register an AgentListener with this ChatClient to receive chat messages and information about the agent.

Parameters
agentListener An AgentListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient addChatBotListener (ChatBotListener chatBotListener)

Register a ChatBotListener with this ChatClient to receive menus from a Chat Bot.

Parameters
chatBotListener A ChatBotListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient addFileTransferRequestListener (FileTransferRequestListener fileTransferRequestListener)

Register a FileTransferRequestListener with this ChatClient to receive File Transfer Requests from an agent.

Parameters
fileTransferRequestListener A FileTransferRequestListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient addQueueListener (QueueListener queueListener)

Register a QueueListener with this ChatClient to receive queue position updates for the chat session.

Parameters
queueListener A QueueListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient addSessionInfoListener (SessionInfoListener sessionInfoListener)

Register a SessionInfoListener with this ChatClient to receive session information.

Parameters
sessionInfoListener A SessionInfoListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient addSessionStateListener (SessionStateListener sessionStateListener)

Register a SessionStateListener with this ChatClient to receive state changes for the chat session.

Parameters
sessionStateListener A SessionStateListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract void endChatSession ()

End the chat session. This will terminate the ChatService.

As a result, any SessionStateListener instances you have registered with this ChatClient will be notified with an ChatEndReason of EndedByClient.

public abstract ChatSessionState getCurrentSessionState ()

Returns the current state of the chat session.

Returns
  • Current session state.
See Also

public abstract ChatClient removeAgentListener (AgentListener agentListener)

Unregister an AgentListener from this ChatClient instance.

Parameters
agentListener An AgentListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient removeChatBotListener (ChatBotListener chatBotListener)

Unregister a ChatBotListener from this ChatClient instance.

Parameters
chatBotListener A ChatBotListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient removeFileTransferRequestListener (FileTransferRequestListener fileTransferRequestListener)

Unregister a FileTransferRequestListener from this ChatClient instance

Parameters
fileTransferRequestListener A FileTransferRequestListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient removeQueueListener (QueueListener queueListener)

Unregister a QueueListener from this ChatClient instance.

Parameters
queueListener A QueueListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient removeSessionInfoListener (SessionInfoListener sessionInfoListener)

Unregister a SessionInfoListener from this ChatClient instance.

Parameters
sessionInfoListener A SessionInfoListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract ChatClient removeSessionStateListener (SessionStateListener sessionStateListener)

Unregister a SessionStateListener from this ChatClient instance.

Parameters
sessionStateListener A SessionStateListener instance
Returns
  • A reference to this ChatClient instance for syntax chaining

public abstract Async<Void> sendButtonSelection (ChatWindowButtonMenu.Button button)

Inform the Chat Bot of a button selection by providing the button as received via onChatButtonMenuReceived(ChatWindowButtonMenu).

Parameters
button The selected button.
Returns
  • Asynchronous receipt of the button selection delivery

public abstract Async<Void> sendButtonSelection (int buttonIndex)

Inform the Chat Bot of a button selection by providing the button index and label as received via onChatButtonMenuReceived(ChatWindowButtonMenu).

Parameters
buttonIndex The selected button
Returns
  • Asynchronous receipt of the button selection delivery

public abstract Async<ChatSentMessageReceipt> sendChatMessage (String message)

Send a message to the agent. This will also scrub the message text of any sensitive data in accordance with your Salesforce Org's Sensitive Data Rules.

This method returns an Async instance so you can handle the status of the message delivery asynchronously and have a complete record of any Sensitive Data Rule scrubbing that has occurred on the message text.

Provide a com.salesforce.android.service.common.utilities.control.Async.CompletionHandler to the Async instance to handle successful delivery of the message. Delivery errors can be handled by providing a com.salesforce.android.service.common.utilities.control.Async.ErrorHandler.

Parameters
message The message text to send
Returns
  • Asynchronous receipt of the message delivery

public abstract Async<Void> sendFooterMenuSelection (ChatFooterMenu.MenuItem menuItem)

Inform the Chat Bot of a footer menu selection by providing the menu item as received via onChatFooterMenuReceived(ChatFooterMenu).

Parameters
menuItem The selected menu item.
Returns
  • Asynchronous receipt of the footer menu selection delivery

public abstract Async<Void> sendFooterMenuSelection (int itemIndex, String dialogId)

Inform the Chat Bot of a footer menu selection by providing the menu item index and dialog ID of the selected item. Available footer menu items are provided via onChatFooterMenuReceived(ChatFooterMenu).

Parameters
itemIndex The index of the selected footer menu item
dialogId The dialog ID of the selected footer menu item from getDialogId()
Returns
  • Asynchronous receipt of the footer menu selection delivery

public abstract Async<Void> sendMenuSelection (ChatWindowMenu.MenuItem menuItem)

Inform the Chat Bot of a menu selection by providing the menu item as received via onChatMenuReceived(ChatWindowMenu).

Parameters
menuItem The selected menu item.
Returns
  • Asynchronous receipt of the menu selection delivery

public abstract Async<Void> sendMenuSelection (int itemIndex)

Inform the Chat Bot of a menu selection by providing the menu item index of the selected item. Menu items are provided via onChatMenuReceived(ChatWindowMenu).

Parameters
itemIndex The index of the selected menu item.
Returns
  • Asynchronous receipt of the menu selection delivery

public abstract Async<Void> sendSneakPeekMessage (String sneakPeekMessage)

Send a message preview to the agent.

This API expects an entire message String to be passed in with each keystroke, and is an alternative to notifying the agent that the user is typing; this means you do not need to call setIsUserTyping(boolean) if you intend to use Sneak Peek during the Chat session.

Sneak Peek is intended for use when an agent is associated with a Live agent Configuration that has Sneak Peek enabled. You will be notified of this state via the onAgentJoined(AgentInformation) callback, in which case isSneakPeekEnabled() will return true.

Parameters
sneakPeekMessage A preview message intended for the agent
Returns
  • Asynchronous receipt of the sneak peek message delivery

public abstract Async<Void> setIsUserTyping (boolean isUserTyping)

Inform the agent whether or not the user is currently typing. This method does not offer a timeout feature if you pass in a value of TRUE, so be sure to call this method again with FALSE when you have determined that the user has finished typing.

This method returns an Async instance so you can handle the status of the message delivery asynchronously. Provide a com.salesforce.android.service.common.utilities.control.Async.CompletionHandler to the Async instance to handle successful delivery of the message. Delivery errors can be handled by providing a com.salesforce.android.service.common.utilities.control.Async.ErrorHandler.

Parameters
isUserTyping Whether or not the user is currently typing
Returns
  • Asynchronous receipt of the typing status delivery