send
Sends a message and optionally notifies the client about the message being processed or sent.
If the message has been processed but not sent within a reasonable amount of time, the client is permitted to retry.
Execution (processing) of a given message is immediately moved to a background thread, though listener will always be invoked on a foreground thread.
Note that messages with no test, attachments, or postback specified will be silently ignored.
If you are supplying attachments for upload, then be aware of the following.
If attachment misses file name, the file is named to "document" upon being sent to the server. Please take care to provide localized file names if you want to display them to the user.
The upload of files is performed at most once before subsequent processing of the message and sending it to the server. If the file call succeeds, it's cached internally to avoid doubling uploads. Therefore, subsequent calls (if the primary were to fail) are much faster. Also, if the user tries to send the same attachment again, it will not be uploaded again instead it's referenced by the origin upload. This cache is active as long as the ChatBuilder instance remains the same. Reinitializing the Chat doesn't clear the cache.
If any upload of any attachment fails by connection error, listener will not be invoked for even processing triggers. The error is passed to the ChatStateListener.onChatRuntimeException as an instance of com.nice.cxonechat.exceptions.RuntimeChatException.AttachmentUploadError with information about the failed attachment upload.
If any upload of any attachment fails by server error (returns but an empty body), then the attachment is skipped, and execution continues.
Parameters
Message to be sent.
listener to be notified when the message has been sent.
Throws
if the message is empty, ie., has no attachment, message, or postback.
Simplified method to send a simple user message to the agent.
Parameters
message to send to agent.
optional "postback" to send with attachments.
listener to be invoked when the message has been sent
See also
Simplified method to send an attachment to the agent.
Parameters
attachments to send.
optional message to send with attachments.
optional "postback" to send with attachments.
listener to be invoked when the message has been sent