Learn how to create and manage dialogs.
createDialog()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
name | yes | A name of the dialog. Required only for group and public dialog types. Not needed for private dialog. |
occupantsIds | yes | A list of opponents IDs.- If the occupantsIds array is empty and type is not provided, the public dialog is created.- If the occupantsIds has a single user and type is not provided, the private dialog is created.- If the occupantsIds has more then one userId and type is not provided, a group dialog is created. |
type | no | A type of the dialog. Possible values: QB.chat.DIALOG\_TYPE.CHAT , QB.chat.DIALOG\_TYPE.GROUP\_CHAT or QB.chat.DIALOG\_TYPE.PUBLIC\_CHAT . By default, the public dialog is created. |
photo | no | A URL of the image. Can be a link to a file in Content module, Custom Objects module or just a web link. Must be a String. |
joinDialog()
method. If you’ve successfully joined the dialog, you can send/receive messages in real-time. See this section to learn how to send/receive messages.
join()
method is used with regard to the dialog type.
Capabilities | Public | Group | Private |
---|---|---|---|
Join | ✓ | ✓ | ✗ |
occupantsIds
array, in the dialog model.Your user ID is added to the occupantsIds
array if you create a dialog or you are added to the dialog by the other user. See this section to learn how to add/remove occupants to the group dialog.leaveDialog()
method. If the dialog is left, you can’t send/receive messages. To be able to receive/send messages, you need to join it.
leaveDialog()
method is used with regard to the dialog type.
Capabilities | Public | Group | Private |
---|---|---|---|
Leave | ✓ | ✓ | ✗ |
occupantsIds
array, in the dialog model. As a result, the dialog is removed from the list of dialogs and you won’t have access to the chat history.To remove a dialog for all users, use the deleteDialog()
method. See this section to learn how to delete the dialog completely for all users.chat
in their names, sorted by the QB.chat.DIALOGS_SORT.FIELD.LAST_MESSAGE_DATE_SENT
field in ascending order, and limited to 10 dialogs on the page.
getDialogs()
accepts one (optional) argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
filter | no | Specifies filtering criteria for the field. |
sort | no | Specifies sorting criteria for the field. |
skip | no | Skip N records in search results. Useful for pagination. Default (if not specified): 0. |
limit | no | Limit search results to N records. Useful for pagination. Default value: 100. |
Search operators | Applicable to types | Applicable to fields | Description |
---|---|---|---|
lt | number, string, date | last_message_date_sent, created_at, updated_at | Less Than operator. |
lte | number, string, date | last_message_date_sent, created_at, updated_at | Less Than or Equal to operator. |
gt | number, string, date | last_message_date_sent, created_at, updated_at | Greater Than operator. |
gte | number, string, date | last_message_date_sent, created_at, updated_at | Greater Than or Equal to operator. |
ne | number, string, date | _id, name, last_message_date_sent | Not Equal to operator. |
in | number, string, date | type, last_message_date_sent, name | IN array operator. |
nin | number, string, date | last_message_date_sent | IN array operator. |
all | number | occupants_ids | ALL are contained in array. |
ctn | string | name | All records that contain a particular substring. |
QB.chat.DIALOGS_SORT.FIELD.LAST_MESSAGE_DATE_SENT
field.
Sort options | Applicable to types | Applicable to fields | Description |
---|---|---|---|
ascending | All types | id, created_at, name, last_message_date_sent | Sort results in the ascending order by setting the ascending as true. |
descending | All types | id, created_at, name, last_message_date_sent | Sort results in the descending order by setting the ascending as false. |
getDialogs()
method. The request below will return the specified dialogs limited to 5 dialogs per page with 2 dialogs skipped at the beginning of the page.
Capabilities | Public dialog | Group dialog | Private dialog |
---|---|---|---|
Update a dialog name | Owner | Owner | ✗ |
Update a photo | Owner | Owner | ✗ |
Update custom parameters | Owner,Occupant | Owner,Occupant | Owner,Occupant |
addUsers
field to add occupants to the dialog. As a result, the occupant ID will be added to the occupantsIds
array.
updateDialog()
method accepts one argument of the object type that has the following fields:
Fields | Required | Description |
---|---|---|
dialogId | yes | ID of the dialog |
addUsers | yes | IDs of occupants to be added to the dialog. |
Capabilities | Public dialog | Group dialog | Private dialog |
---|---|---|---|
Add other users | ✗ | Owner,Occupant | ✗ |
removeUsers
field remove occupants from a group dialog. As a result, the occupant ID will be removed from the occupantsIds
array.
updateDialog()
method accepts one argument of the object type that has the following fields:
Fields | Required | Description |
---|---|---|
dialogId | yes | ID of the dialog |
removeUsers | yes | IDs of occupants to be removed from the dialog. |
Capabilities | Public dialog | Group dialog | Private dialog |
---|---|---|---|
Remove other users | ✗ | Owner | ✗ |
Remove yourself | ✗ | Owner,Occupant | ✗ |
deleteDialog()
method to delete a dialog for all users. When deleting a group dialog, all user IDs will be removed from the occupantsIds
array in the dialog model. You can also delete multiple dialogs in a single request.
To delete a dialog for yourself, just leave the dialog. See this section for more information.
Capabilities | Public | Group | Private |
---|---|---|---|
Delete a dialog for all users | Owner | Owner | Owner |