send
Sends message to the server and suspends until the message has been dispatched.
On success, returns the ID assigned to the sent message as a String. On failure, throws an exception (e.g., com.nice.cxonechat.exceptions.InvalidParameterException for an empty message, or com.nice.cxonechat.exceptions.CXoneException for server-side errors).
Note that messages with no text, attachments, or postback specified will throw com.nice.cxonechat.exceptions.InvalidParameterException.
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 attachments violate file restrictions (wrong type, too large, or uploads disabled), the error is first reported via Chat.stateFlow as a ChatStateEvent.RuntimeException, and then this method throws com.nice.cxonechat.exceptions.RuntimeChatException.AttachmentUploadError.
If any upload of any attachment fails by connection error during HTTP upload, the error is reported via Chat.stateFlow as a ChatStateEvent.RuntimeException with an instance of com.nice.cxonechat.exceptions.RuntimeChatException.AttachmentUploadError, and the attachment is skipped.
If any upload of any attachment fails by server error (returns but an empty body), then the attachment is skipped, and execution continues.
Return
The ID assigned to the sent message.
Parameters
Message to be sent.
Throws
if the message is empty, ie., has no attachment, message, or postback.
if attachments violate file restrictions (wrong type, too large, or uploads disabled).
if the message could not be enqueued to the WebSocket.
in case the com.nice.cxonechat.thread.ChatThread.canAddMoreMessages is false and application tries to send a new message to such thread.
Simplified method to send a simple user message to the agent.
Return
The ID assigned to the sent message.
Parameters
message to send to agent.
optional "postback" to send with the message.
See also
Simplified method to send an attachment to the agent.
Return
The ID assigned to the sent message.
Parameters
attachments to send.
optional message to send with attachments.
optional "postback" to send with attachments.