public interface Conversation extends ConversationDetails
To obtain the current conversation use BrandMessenger.getConversation()
,
or BrandMessenger.getConversationById(String, BrandMessengerCallback)
to obtain other conversations that are
not active.
BrandMessenger.init(Application, Settings, BrandMessengerCallback)
must have been called prior to retrieving
any conversation object.
To send a message, use sendMessage(Message)
with a Message
object.
Example:
BrandMessenger.getConversation().sendMessage(new Message("Hello World!"));
A conversation must be made active with BrandMessenger.loadConversation(String, BrandMessengerCallback)
before executing any actions on it.
Modifier and Type | Method and Description |
---|---|
void |
addMessage(Message message)
Adds a new message to the conversation without sending it.
|
void |
brandMessengerHidden()
Notifies the delegate when BrandMessenger Conversation is hidden
|
void |
brandMessengerShown()
Notifies the delegate when BrandMessenger Conversation is shown
|
boolean |
isBrandMessengerShown()
Returns
true if the BrandMessenger UI is currently shown |
void |
loadCardSummary()
Loads billing info (if exists) to display last4 in credit form.
|
void |
markAllAsRead()
Marks all unread messages as read.
|
void |
postback(MessageAction action,
BrandMessengerCallback<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 |
startTyping()
Notify the server that the user is typing.
|
void |
stopTyping()
Notify the server that the user has finished typing.
|
void |
submitForm(java.lang.String id,
java.util.List<FormFieldDto> buildFormResponseFields,
<any> callback) |
void |
triggerAction(MessageAction action)
Triggers message action resulting from a click.
|
void |
updateMessageSubmitStatus(Message message) |
void |
uploadFile(Message fileMessage,
BrandMessengerCallback<Message> callback)
Uploads a user file to the conversation.
|
void |
uploadImage(Message imageMessage,
BrandMessengerCallback<Message> callback)
Uploads a user image to the conversation.
|
void |
validateFormField(MessageDto message,
FormFieldDto field,
java.lang.String input,
ValidationResponseState validationResponseState,
FormValidationListener validateFieldCallback) |
getBusinessLastRead, getDescription, getDisplayName, getIconUrl, getId, getLastRead, getLastUpdatedAt, getMessages, getMetadata, getParticipants, getUnreadCount
void markAllAsRead()
Marks all unread messages as read, and notifies that the unread count changed.
void sendMessage(Message message)
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.
message
- The message to sendMessage retryMessage(Message message)
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.
message
- The failed messagevoid addMessage(Message message)
message
- The message to addvoid removeMessage(Message message)
message
- The message to removevoid uploadImage(Message imageMessage, BrandMessengerCallback<Message> callback)
For each image upload, provided BrandMessengerCallback
will be called with status
code, error and the resulting message
imageMessage
- The imageMessage to uploadcallback
- The callback, to be called with BrandMessengerCallback.Response
getData()
of type Message
, null in case of errorMessage
,
BrandMessengerCallback
void uploadFile(Message fileMessage, BrandMessengerCallback<Message> callback)
For each file upload, provided BrandMessengerCallback
will be called with status
code, error and the resulting message
fileMessage
- The fileMessage to uploadcallback
- The callback, to be called with BrandMessengerCallback.Response
getData()
of type Message
, null in case of errorMessage
,
BrandMessengerCallback
void startTyping()
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.
stopTyping()
void stopTyping()
If the user was not flagged as typing recently, this method will result in a no-op.
startTyping()
void processPayment(CreditCard creditCard, MessageAction action)
creditCard
- The credit card objectaction
- The message actionCreditCard
,
MessageAction
void triggerAction(MessageAction action)
action
- The message actionMessageAction
void loadCardSummary()
void postback(MessageAction action, BrandMessengerCallback<java.lang.Void> callback)
MessageAction
,
BrandMessengerCallback
void brandMessengerShown()
Used by the brandMessenger-ui package to notify the Conversation.Delegate when BrandMessenger is shown
void brandMessengerHidden()
Used by the brandMessenger-ui package to notify the Conversation.Delegate when BrandMessenger is hidden
boolean isBrandMessengerShown()
true
if the BrandMessenger UI is currently showntrue
if the BrandMessenger UI is currently shown, false
otherwisevoid validateFormField(MessageDto message, FormFieldDto field, java.lang.String input, ValidationResponseState validationResponseState, FormValidationListener validateFieldCallback)
void submitForm(java.lang.String id, java.util.List<FormFieldDto> buildFormResponseFields, <any> callback)
void updateMessageSubmitStatus(Message message)