Interface Conversation
-
- All Superinterfaces:
ConversationDetails
public interface Conversation extends ConversationDetails
The Conversation provides an interface to interact with a user's conversation.To obtain the current conversation use
Smooch.getConversation()
, orSmooch.getConversationById(String, SmoochCallback)
to obtain other conversations that are not active.Smooch.init(Application, Settings, SmoochCallback)
must have been called prior to retrieving any conversation object.To send a message, use
sendMessage(Message)
with aMessage
object. Example:Smooch.getConversation().sendMessage(new Message("Hello World!"));
A conversation must be made active with
Smooch.loadConversation(String, SmoochCallback)
before executing any actions on it.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addMessage(Message message)
Adds a new message to the conversation without sending it.boolean
isSmoochShown()
Returnstrue
if the Smooch UI is currently shownvoid
loadCardSummary()
Loads billing info (if exists) to display last4 in credit form.void
markAllAsRead()
Marks all unread messages as read.void
postback(MessageAction action, SmoochCallback<java.lang.Void> callback)
Triggers MessageAction postback.void
processPayment(CreditCard creditCard, MessageAction action)
Processes a credit card payment.void
removeMessage(Message message)
Removes a failed or unsent message from the conversation.Message
retryMessage(Message message)
Retries a message that failed to send.void
sendMessage(Message message)
Adds a new message to the conversation.void
smoochHidden()
Notifies the delegate when Smooch Conversation is hiddenvoid
smoochShown()
Notifies the delegate when Smooch Conversation is shownvoid
startTyping()
Notify the server that the user is typing.void
stopTyping()
Notify the server that the user has finished typing.void
triggerAction(MessageAction action)
Triggers message action resulting from a click.void
uploadFile(Message fileMessage, SmoochCallback<Message> callback)
Uploads a user file to the conversation.void
uploadImage(Message imageMessage, SmoochCallback<Message> callback)
Uploads a user image to the conversation.-
Methods inherited from interface io.smooch.core.ConversationDetails
getBusinessLastRead, getDescription, getDisplayName, getIconUrl, getId, getLastRead, getLastUpdatedAt, getMessages, getMetadata, getParticipants, getUnreadCount
-
-
-
-
Method Detail
-
markAllAsRead
void markAllAsRead()
Marks all unread messages as read.Marks all unread messages as read, and notifies that the unread count changed.
-
sendMessage
void sendMessage(Message message)
Adds a new message to the conversation.For each message added using sendMessage, a notification will be fired indicating the success or failure status of the upload.
A conversation will be started automatically if this is the very first message and a conversation hasn't been started yet.
- Parameters:
message
- The message to send
-
retryMessage
Message retryMessage(Message message)
Retries a message that failed to send.The failed message will be removed from the message list, and a new message will be constructed with the same text as the failed message. A notification will be fired indicating the success or failure status of the upload.
- Parameters:
message
- The failed message- Returns:
- The sent message, or null if the message could not be sent
-
addMessage
void addMessage(Message message)
Adds a new message to the conversation without sending it.- Parameters:
message
- The message to add
-
removeMessage
void removeMessage(Message message)
Removes a failed or unsent message from the conversation.- Parameters:
message
- The message to remove
-
uploadImage
void uploadImage(Message imageMessage, SmoochCallback<Message> callback)
Uploads a user image to the conversation.For each image upload, provided
SmoochCallback
will be called with status code, error and the resulting message- Parameters:
imageMessage
- The imageMessage to uploadcallback
- The callback, to be called withSmoochCallback.Response
getData() of typeMessage
, null in case of error- See Also:
Message
,SmoochCallback
-
uploadFile
void uploadFile(Message fileMessage, SmoochCallback<Message> callback)
Uploads a user file to the conversation.For each file upload, provided
SmoochCallback
will be called with status code, error and the resulting message- Parameters:
fileMessage
- The fileMessage to uploadcallback
- The callback, to be called withSmoochCallback.Response
getData() of typeMessage
, null in case of error- See Also:
Message
,SmoochCallback
-
startTyping
void startTyping()
Notify the server that the user is typing. This method is called automatically when using the default ConversationFragment. Only call this method if your application implements its own conversation view.Typing updates are automatically throttled, so you may call this method as often as necessary. The typing stop event will automatically fire 10 seconds after the most recent call to this method.
- See Also:
stopTyping()
-
stopTyping
void stopTyping()
Notify the server that the user has finished typing. This method is called automatically when using the default ConversationFragment. Only call this method if your application implements its own conversation view.If the user was not flagged as typing recently, this method will result in a no-op.
- See Also:
startTyping()
-
processPayment
void processPayment(CreditCard creditCard, MessageAction action)
Processes a credit card payment.- Parameters:
creditCard
- The credit card objectaction
- The message action- See Also:
CreditCard
,MessageAction
-
triggerAction
void triggerAction(MessageAction action)
Triggers message action resulting from a click.- Parameters:
action
- The message action- See Also:
MessageAction
-
loadCardSummary
void loadCardSummary()
Loads billing info (if exists) to display last4 in credit form.
-
postback
void postback(MessageAction action, SmoochCallback<java.lang.Void> callback)
Triggers MessageAction postback.- See Also:
MessageAction
,SmoochCallback
-
smoochShown
void smoochShown()
Notifies the delegate when Smooch Conversation is shownUsed by the smooch-ui package to notify the Conversation.Delegate when Smooch is shown
-
smoochHidden
void smoochHidden()
Notifies the delegate when Smooch Conversation is hiddenUsed by the smooch-ui package to notify the Conversation.Delegate when Smooch is hidden
-
isSmoochShown
boolean isSmoochShown()
Returnstrue
if the Smooch UI is currently shown- Returns:
true
if the Smooch UI is currently shown,false
otherwise
-
-