Learn how to send and receive messages, mark messages as delivered or read, etc.
subscribeChatEvent()
method. As a result, the app will receive events associated with receiving a message, delivery receipts, and read receipts.
Argument | Required | Description |
---|---|---|
dialogId | yes | The ID of a dialog. |
messageBody | no | A message text. |
attachments | no | A list of attachments. |
properties | no | A list of properties. |
markable | no | A boolean parameter. A markable status of a message. |
dateSent | no | The date the message was sent. |
saveToHistory | no | A boolean parameter. Specifies if the message will be saved on the server. Set the saveToHistory as true to save the message on the server. |
join()
method before you start chatting in a dialog. Once the dialog is joined, you can receive/send messages. See this section to learn how to join the dialog.Argument | Required | Description |
---|---|---|
dialogId | yes | The ID of a dialog. |
body | no | A message text. |
saveToHistory | no | A boolean parameter. Specifies if the message will be saved on the server. Set the saveToHistory as true to save the message on the server. |
properties | no | Extra data. Specify any key-value pairs. In each pair, the key and value are both string values. |
getDialogMessages()
method. The request below will return messages for a specific dialog containing test value
in its name, sorted by the QBChatDialogSorts.LAST_MESSAGE_DATE_SENT
field in ascending order, limited to 50 messages on the page.
Argument | Required | Description |
---|---|---|
dialogId | yes | The ID of the dialog. |
sort | no | Specifies sorting criteria for the field. |
filter | no | Specifies filtering criteria for the field. |
limit | no | Limit search results to N records. Useful for pagination. Default value: 100. |
skip | no | Skip N records in search results. Useful for pagination. Default (if not specified): 0. |
markAsRead | no | A boolean parameter. If you want to mark all retrieved chat messages as a read, set the markAsRead parameter as true. If you decide not to mark chat messages as read, just set markAsRead parameter as false or omit the parameter. |
extendedRequest
dictionary.
Search operators | Applicable to types | Applicable to fields | Description |
---|---|---|---|
lt | Number, String, Date | date_sent, sender_id, recipient_id, updated_at | Less Than operator. |
lte | Number, String, Date | date_sent, sender_id, recipient_id, updated_at | Less Than or Equal to operator. |
gt | Number, String, Date | date_sent, sender_id, recipient_id, updated_at | Greater Than operator. |
gte | Number, String, Date | date_sent, sender_id, recipient_id, updated_at | Greater Than or Equal to operator. |
ne | Number, String, Date | _id, message, date_sent, sender_id, recipient_id | Not Equal to operator. |
in | Number, String, Date | date_sent, sender_id, recipient_id | IN array operator. |
nin | Number, String, Date | date_sent, sender_id, recipient_id | Not IN array operator. |
or | Number, String, Date | date_sent, sender_id, recipient_id | All records that contain a value 1 or value 2. |
ctn | String | message | All records that contain a particular substring. |
Sort options | Applicable to types | Description |
---|---|---|
ascending | All types | Sort results in the ascending order by setting the ascending as true. |
descending | All types | Sort results in the descending order by setting the ascending as false. |
login()
because the Stream Management is initialized while Chat login is performed.The Stream Management defines an extension for active management of a stream between a client and server, including features for stanza acknowledgments.QBChatEvents.MESSAGE_DELIVERED
event.
markMessageDelivered()
method to mark a message as delivered. As a result, the server will notify a sender about the delivery receipt.
markable
as true
using the sendMessage()
method if you want, as a sender, to receive message delivery receipts from other recipients. Thus, the markable
parameter enables the sender to request the delivery receipt. It also enables the recipient to confirm the message delivery. However, if markable
is false
or omitted, then you can notify a sender about the delivery receipt using the markMessageDelivered()
method.
QBChatEvents.MESSAGE_DELIVERED
event is received.
When a message is marked as delivered, the IDs of users who have received the message are stored in the message model, on the server. Thus, you can request a chat history from the server to get to know who received the message using the getDialogMessages()
method. See this section to learn how to retrieve chat history.QBChatEvents.MESSAGE_READ
event.
markMessageRead()
method to mark a message as read. As a result, the server will notify a sender about the read receipt.
getDialogMessages()
method. See this section to learn how to retrieve chat history.QBChatEvents.USER_IS_TYPING
event.
QBChatEvents.USER_STOPPED_TYPING
event.
sendIsTyping()
method. As a result, the server will notify a recipient about the event.
sendStoppedTyping()
method. As a result, the server will notify a recipient about the event.
QBChatEvents.RECEIVED_SYSTEM_MESSAGE
event. See this section to learn how to subscribe to message events.
System messages are also not shown in the dialog history and, consequently, are not stored on the server. This means that these messages will be delivered only to online users. Send system messages using the sendSystemMessage()
method.
Argument | Required | Description |
---|---|---|
recipientId | yes | ID of the recipient. |
properties | no | Extra data. Specify any key-value pairs. In each pair, the key and value are both string values. |
updateNotificationDialog()
method.
Argument | Required | Description |
---|---|---|
dialogId | yes | ID of the dialog. |
enabled | yes | The parameter for enable/disable notification for dialog |