Class ZopimChat
- java.lang.Object
-
- com.zopim.android.sdk.api.ZopimChat
-
- All Implemented Interfaces:
- Chat, ChatApi, ChatApiCommands
public class ZopimChat extends java.lang.Object implements Chat
Definition for initialization and configuration of the chat.Firstly, to initialize the chat call
ZopimChat.init(String)with the correct account key obtained at your Zopim account configuration page.A global chat configuration can be provided at initialization which will apply to all chat sessions that get started. Additionally, each chat session can be configured separately during chat start
ZopimChat#start(android.support.v4.app.FragmentActivity). Starting a chat will provide an instance ofChatused for chat communication. That chat is the bound to the lifecycle of the activity that was used to start the chat.- See Also:
- Getting Started,
Chat
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classZopimChat.DefaultConfigConfiguration class for global chat configurationstatic classZopimChat.SessionConfigConfiguration class for session chat configuration
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description booleanemailTranscript(java.lang.String email)Emails the current chat transcriptvoidendChat()Ends the current chat.ChatConfiggetConfig()Gets chat config for the current chat session as configured viaZopimChatApistatic DataSourcegetDataSource()Deprecated.useZopimChatApi.getDataSource()insteadstatic java.lang.LonggetInitializationTimeout()Deprecated.useZopimChatApi.getInitializationTimeout()insteadstatic java.lang.LonggetReconnectTimeout()Deprecated.useZopimChatApi.getReconnectTimeout()insteadbooleanhasEnded()Tells if this chat session has ended and can not be continued.static ZopimChat.DefaultConfiginit(java.lang.String accountKey)Initiates chat and returnsZopimChat.DefaultConfigglobal configuration builder to be used for configuring the global chat settings.voidresend(java.lang.String messageId)Re-sends the visitor message.voidresetTimeout()Resets chat timeout.static Chatresume(FragmentActivity activity)Attempts to resume the existing chat if possible.voidsend(java.io.File file)Sends the file to the current chat log.voidsend(java.lang.String message)Sends the visitor message.voidsendChatComment(java.lang.String comment)Sets a comment to the current chat session.voidsendChatRating(ChatLog.Rating rating)Sets rating for the current chat session.booleansendOfflineMessage(java.lang.String name, java.lang.String email, java.lang.String message)Sends email to agents defined in the dashboard for this account.voidsetDepartment(java.lang.String department)Sets a department to the current chat session.voidsetEmail(java.lang.String email)Sets the email for the user in the current chat session.voidsetName(java.lang.String name)Sets the name for the user in the current chat session.voidsetPhoneNumber(java.lang.String phoneNumber)Sets phone number information for the user that is in the current chat session.static voidsetVisitorInfo(VisitorInfo visitorInfo)Configures the globalVisitorInfostatic Chatstart(FragmentActivity activity)Starts the chat with global configuration.static voidtrackEvent(java.lang.String description)Leaves an event trace.
-
-
-
Method Detail
-
init
public static ZopimChat.DefaultConfig init(java.lang.String accountKey)
Initiates chat and returnsZopimChat.DefaultConfigglobal configuration builder to be used for configuring the global chat settings. This configuration will apply to all new instances of a chat session unless a new session configuration is provided when starting the new chat.- Parameters:
accountKey- Your account key obtained from the Zopim widget config page. Will configure chat to use your Zopim instance.- Returns:
- configuration builder for setting the global chat configuration
-
start
public static Chat start(FragmentActivity activity)
Starts the chat with global configuration. Chat needs to be previously initialized.- Parameters:
activity- that holds the chat session- Returns:
- chat session instance
-
resume
public static Chat resume(FragmentActivity activity)
Attempts to resume the existing chat if possible. Chat needs to be previously initialized.Resuming a chat will be possible if the previous chat was not ended via
ZopimChat.endChat()or expired. Chat timeout time, defined hereChatSession.DEFAULT_CHAT_SESSION_TIMEOUTis the time that expired after the last message exchange. If resuming was successful it will restore chat configuration from the server. If chat can not be resumed this will still return the chat instance but it won't be able to chat because it has endedZopimChat.hasEnded().Resumed chat might not be immediately ready to communicate, check
ZopimChatApi.canCommunicate().- Parameters:
activity- that holds the chat session- Returns:
- chat session instance
-
trackEvent
public static void trackEvent(java.lang.String description)
Leaves an event trace.It is possible to track event prior chat session being started. Tracked events will be sent as soon as chat session is connected and any further event after that point will be sent immediately.
- Parameters:
description- of the event
-
getDataSource
@Deprecated public static DataSource getDataSource()
Deprecated. useZopimChatApi.getDataSource()insteadGets chat data source defined inDataSourceandPathDataSourceData source provides subscription to data update broadcasts. It also enables to get current state of a data path.
- Returns:
- data source
-
setVisitorInfo
public static void setVisitorInfo(VisitorInfo visitorInfo)
Configures the globalVisitorInfoVisitor info can be set at any point, but the changes will take effect at next chat session start
- Parameters:
visitorInfo- visitor data fromVisitorInfo
-
getReconnectTimeout
@Deprecated public static java.lang.Long getReconnectTimeout()
Deprecated. useZopimChatApi.getReconnectTimeout()insteadGets reconnect timeout that was configured viaZopimChatApi.DefaultConfig.reconnectTimeoutIf timeout was not configured it will return theChatSession.DEFAULT_RECONNECT_TIMEOUT- Returns:
- reconnect timeout
-
getInitializationTimeout
@Deprecated public static java.lang.Long getInitializationTimeout()
Deprecated. useZopimChatApi.getInitializationTimeout()insteadGets initialization timeout that was configured viaZopimChatApi.DefaultConfig.initializationTimeoutIf timeout was not configured it will return theChatSession.DEFAULT_CHAT_INITIALIZATION_TIMEOUT- Returns:
- initialization timeout
-
getConfig
public ChatConfig getConfig()
Description copied from interface:ChatApiGets chat config for the current chat session as configured viaZopimChatApiIt will reflect
ZopimChatApi.DefaultConfigconfiguration values unless overridden viaZopimChatApi.SessionConfigat chat start.
-
hasEnded
public boolean hasEnded()
Description copied from interface:ChatApiTells if this chat session has ended and can not be continued.
-
resetTimeout
public void resetTimeout()
Description copied from interface:ChatApiResets chat timeout. This will offset the timeout by the value configured viaZopimChatApi.DefaultConfig.sessionTimeout(long).- Specified by:
resetTimeoutin interfaceChatApi
-
send
public void send(java.lang.String message)
Description copied from interface:ChatApiCommandsSends the visitor message.This message will appear in the agent dashboard in an active chat queue.
- Specified by:
sendin interfaceChatApiCommands- Parameters:
message- to be sent- See Also:
- Agent Visitor List
-
send
public void send(java.io.File file)
Description copied from interface:ChatApiCommandsSends the file to the current chat log. Successful file send will trigger a chat log update with information about the file being uploaded.File must pass validation check and upload requirements defined in Zopim attachments page
A successful file upload will be visible in the agent dashboard.
- Specified by:
sendin interfaceChatApiCommands- Parameters:
file- to send- See Also:
ChatLogObserver, Agent Dashboard
-
resend
public void resend(java.lang.String messageId)
Description copied from interface:ChatApiCommandsRe-sends the visitor message.This message will appear in the agent dashboard.
- Specified by:
resendin interfaceChatApiCommands- Parameters:
messageId- id of the message to resend- See Also:
- Agent Visitor List
-
sendOfflineMessage
public boolean sendOfflineMessage(java.lang.String name, java.lang.String email, java.lang.String message)Description copied from interface:ChatApiCommandsSends email to agents defined in the dashboard for this account.Email must be provided in order for the agent to be able to respond.
- Specified by:
sendOfflineMessagein interfaceChatApiCommands- Parameters:
name- of the visitoremail- of the visitormessage- inquiry- Returns:
- true if was able to send, false otherwise
-
sendChatRating
public void sendChatRating(ChatLog.Rating rating)
Description copied from interface:ChatApiCommandsSets rating for the current chat session.This will appear as a response to the chat rating questionnaire sent by an agent to the visitor.
- Specified by:
sendChatRatingin interfaceChatApiCommands- Parameters:
rating- to set
-
sendChatComment
public void sendChatComment(java.lang.String comment)
Description copied from interface:ChatApiCommandsSets a comment to the current chat session.- Specified by:
sendChatCommentin interfaceChatApiCommands- Parameters:
comment- to set
-
emailTranscript
public boolean emailTranscript(java.lang.String email)
Description copied from interface:ChatApiCommandsEmails the current chat transcriptIt will send an email to the provided address with the current chat log
- Specified by:
emailTranscriptin interfaceChatApiCommands- Parameters:
email- address to send the transcript to- Returns:
- true if email was sent, false otherwise
-
endChat
public void endChat()
Description copied from interface:ChatApiCommandsEnds the current chat. This will update the connection status to closed.- Specified by:
endChatin interfaceChatApiCommands
-
setDepartment
public void setDepartment(java.lang.String department)
Description copied from interface:ChatApiCommandsSets a department to the current chat session.Configuring a department in the chat will deliver the chat to the right group of agents supporting that department's inquiries. This information will be visible in the agent dashboard.
Provided department should be one of the departments available in this account. The list of available departments will be available in
LivechatDepartmentsPathafter initialization is completeChatService.onChatInitialized(). Setting a non defined department will have no effect.- Specified by:
setDepartmentin interfaceChatApiCommands- Parameters:
department- visitor is chatting with- See Also:
- Departments Dashboard
-
setPhoneNumber
public void setPhoneNumber(java.lang.String phoneNumber)
Description copied from interface:ChatApiCommandsSets phone number information for the user that is in the current chat session.This information will be visible in the agent dashboard.
- Specified by:
setPhoneNumberin interfaceChatApiCommands- Parameters:
phoneNumber- of the visitor- See Also:
- Agent Dashboard
-
setName
public void setName(java.lang.String name)
Description copied from interface:ChatApiCommandsSets the name for the user in the current chat session.This information will be visible in the agent dashboard.
- Specified by:
setNamein interfaceChatApiCommands- Parameters:
name- of the visitor- See Also:
- Agent Dashboard
-
setEmail
public void setEmail(java.lang.String email)
Description copied from interface:ChatApiCommandsSets the email for the user in the current chat session.This information will be visible in the agent dashboard.
- Specified by:
setEmailin interfaceChatApiCommands- Parameters:
email- of the visitor- See Also:
- Agent Dashboard
-
-