Conversations
Channelize.io supports 4 types of conversations: 1-to-1
, Private Groups
, Public Groups
& Open Conversations
.
- Private 1-to-1: To create a private 1-to-1 conversation, set the property
type
to private andisGroup
to false. This group will have only 2 members. - Private Group: To create a private group conversation, set the property
type
to private andisGroup
to true. Only group admin can add/remove members in the group. You have to be a member to send/receive messages. - Public Group: To create a public group conversation, set the property
type
to public andisGroup
to true. The users have to join the conversation before sending the message and the users can freely join the conversation themselves. - Open Conversation: To create a open Conversation, set the property
type
to open andisGroup
to true. We don't need to specify members for Open Conversation as the users can send/receive messages by watching only.
This table contains all conversations types and their permissions:
Feature | Private 1-to-1 | Private Group | Public Group | Open Conversation |
---|---|---|---|---|
Conversation access | Conversation Members | Conversation Members | All Application Users | All Application Users |
Add/Remove Members | No One | The Conversation admin can add and remove members. | The Conversation admin can add and remove members. | The Conversation admin can add and remove members. |
Join Conversation | No One | No One | The members can join the Conversation anytime. | No One |
Leave Conversation | No One | The Conversation admin and members can leave the Conversation. | The Conversation admin and members can leave the Conversation. | The Conversation admin and members can leave the Conversation. |
Start/Stop Watching | No One | Conversation Members | Conversation Members | All Application Users |
Send Message | Conversation Members | Conversation Members and Watchers | Conversation Members and Watchers | Conversation Members and Watchers |
Delete Messages (Own Copy) | Conversation Members | Conversation Members | No One | No One |
Delete Messages for Everyone | Message owner can delete the message. | Message owner can delete the message. | Message owner can delete the message. | Message owner can delete the message. |
Add/Remove Reactions | Conversation members can add/remove a reaction on received messages. | Conversation members can add/remove a reaction on received messages. | Conversation members can add/remove a reaction on received messages. | Conversation members and watchers can add/remove a reaction on received messages. |
This section contains what all conversations related actions can be performed using JavaScript SDK.
List Conversations
Retrieve the list of conversations of a user.
let conversationListQuery = channelize.Conversation.createConversationListQuery();
// string - Represents the comma separated ids of conversation. (Default: null)
conversationListQuery.ids = '0558701b-3c7b-45a1-80c3-8af7f0e98l659';
// string - Represents the comma separated custom types of conversation. (Default: null)
conversationListQuery.customTypes = 'messaging';
// string - Represents the name of conversation. (Default: null)
conversationListQuery.search = 'Test_group';
// string - Represents the comma separated exact members of conversation. (Default: null)
conversationListQuery.membersExactly = '20697,18859';
// string - Represents the comma separated included members of conversation. (Default: null)
conversationListQuery.membersIncluded = '20697,18859';
// string - Represents the type of conversation. (Default: null)
conversationListQuery.type = 'private';
// boolean - Set to true, if you want to retrieve only group conversations. (Default: null)
conversationListQuery.isGroup = true;
// boolean - Represent if deleted conversations (Soft deleted) should be included in the response. (Default: false)
conversationListQuery.includeDeleted = true;
// boolean - Retrieves the conversations in which the user is active. (Default: true)
conversationListQuery.includeOnlyActive = true;
// boolean - Retrieves public conversation that the logged-in user is not a part of. This parameter only works when the type is set to the public. (Default: false)
conversationListQuery.publicMode = false;
// string - Represents extra fields, if you want to include extra fields with the conversation model objects. Allowed value is 'members' for now. (Default: null)
conversationListQuery.include = 'members';
// string - Represents sorting criteria. Allowed values are updatedAt ASC && updatedAt DESC. (Default: updatedAt ASC)
conversationListQuery.sort = 'updatedAt ASC';
// number - Represents the number of conversations. (Default: 25)
conversationListQuery.limit = 25;
// number - Represents the number of items to be skipped from the beginning. (Default: 0)
conversationListQuery.skip = 0;
conversationListQuery.list(function (err, conversations) {
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.conversations
Indicates the response which will be an array of conversation's object.
Get Conversations Count
Retrieves the count of conversations of a user.
let conversationListQuery = channelize.Conversation.createConversationListQuery();
// string - Represents the comma separated ids of conversation. (Default: null)
conversationListQuery.ids = '0558701b-3c7b-45a1-80c3-8af7f0e98l659';
// string - Represents the comma separated custom types of conversation. (Default: null)
conversationListQuery.customTypes = 'messaging';
// string - Represents the name of conversation. (Default: null)
conversationListQuery.search = 'Test_group';
// string - Represents the comma separated exact members of conversation. (Default: null)
conversationListQuery.membersExactly = '20697,18859';
// string - Represents the comma separated included members of conversation. (Default: null)
conversationListQuery.membersIncluded = '20697,18859';
// string - Represents the type of conversation. (Default: null)
// string - Represents the type of conversation. (Default: null)
conversationListQuery.type = 'private';
// boolean - Represents if the conversation is a group conversation or 1-to-1 conversation.
conversationListQuery.isGroup = true;
// boolean - Represents if deleted conversations should be counted.
conversationListQuery.includeDeleted = true;
// boolean - Represents if only active conversations should be counted.
conversationListQuery.includeOnlyActive = true;
// boolean - Retrieves public conversation that the logged-in user is not a part of. This parameter only works when the type is set to the public. (Default: false)
conversationListQuery.publicMode = false;
conversationListQuery.count(function (err, res) {
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates response object having count as property.{ "count": 15 }
Get a Conversation
Retrieves information about a conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
conversationId | string | The unique ID of the conversation to retrieve. |
include | string | Specifies extra fields if you want extra information to be appended with the conversation objects. Allowed value is messages . |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.conversation
Indicates conversation's object.
Create a Conversation
Creates a new conversation.
channelize.Conversation.createConversation(data, function (err, conversation) {
});
Function Params
data is a JavaScript object having below properties. It will be different for 1-to-1 and Group conversations.
Data Properties for Group Conversations
Name | Type | Required | Description |
---|---|---|---|
id | string | no | The unique ID of the conversation. |
title | string | yes | The name of the conversation. |
isGroup | boolean | no | Determines whether to create a group conversation or private 1-to-1 conversation. If set to true , group conversation will create. If set to false , a private 1-to-1 conversation will create. |
profileImageUrl | string | no | The URL of the conversation's profile image. |
createdAt | date object | no | The timestamp when the conversation was created. |
members | array | yes | Specifies an array of user IDs to add to the conversation. E.g. ["20236", "20697", "19116"] |
type | string | no | Specifies the type of conversation. Allowed values are private , public and open . |
config | object | no | Specifies the config settings of the conversation. Config properties are described in a separate section below the data properties. |
customType | string | no | Specifies the role type of conversation. |
metaData | object | no | Some extra data of special conversations. |
Data Properties for 1-to-1 Conversations
Name | Type | Required | Description |
---|---|---|---|
id | string | no | The unique ID of the conversation. |
isGroup | boolean | no | Determines whether to create a group conversation or private 1-to-1 conversation. If set to true , group conversation will create. If set to false , a private 1-to-1 conversation will create. |
createdAt | date object | no | The timestamp when the conversation was created. |
members | array | yes | Specifies an array of user IDs to add to the conversation. E.g. ["20236", "20697"] |
type | string | no | Specifies the type of conversation. Allowed value is private for 1-to-1 conversation. |
config | object | no | Specifies the config settings of the conversation. Config properties are described in a separate section below the data properties. |
customType | string | no | Specifies the role type of conversation. |
metaData | object | no | Some extra data of special conversations. |
Config properties
read_events
If disabled,unreadMessageCount
will not update for a recipient when a new message is sent in a conversation. Also, the count of users read a message will not update. By default, it is enabled for private conversations but disabled for public conversations.typing_events
Determines whether to enable start typing and stop typing events for a conversation. By default, it is enabled for private conversations but disabled for public conversations.push_notifications
Determines whether to enable push notifications for a conversation. By default, push notifications are enabled for private conversations but disabled for public conversations.pin_messages
Determines whether to enable pin messages feature for a conversation. By default, pin messages feature is enabled for open conversations but disabled for public and private conversations.
Callback Params
err
Indicates if there is an error. It will be null if there is no error.conversation
Indicates conversation's object.
Conversation Model Object
A conversation's object can be retrieved either using get conversation method or through various services methods.
{
"id": "1021",
"type": "private",
"title": "Testing New Messenger",
"memberCount": 2,
"watchersCount": 2,
"isGroup": false,
"ownerId": "18859",
"createdAt": "2019-05-23T16:14:15.737Z",
"config": {
"typing_events": true,
"read_events": true,
"push_notification": true,
"pin_messages": false
},
"customType": null,
"isActive": true,
"isAdmin": false,
"isDeleted": false,
"isGroup": false,
"metaData": [],
"mute": false,
"profileImageUrl": null,
"title": "Testing New Messenger",
"unreadMessageCount": 1,
"lastMessage": {
"id": "1f1d473e-b3cd-4be9-b745-66872c443ebc",
"type": "normal",
"body": "Hi! This is a test message.",
"ownerId": "18859",
"owner": {
"displayName": "sydney millers",
"id": "18859",
"profileImageUrl": "http://mobiledemodevelopment.s3.amazonaws.com/public/user/17/0a/02/profile.png"
},
"attachments": [],
"createdAt" : "2020-01-24T05:14:33.017Z",
"isDeleted": null,
"mentionedUsers": [],
"updatedAt": "2020-01-24T05:14:33.017Z"
},
"lastReadAt": {
"18859": "2020-01-24T07:11:58.837Z",
"20697": "2020-01-24T07:38:25.627Z"
}
}
You can call various functions through this conversation model object directly. These functions are mentioned below:
Get Members
You can get all members of the conversation using this function.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.getMembers(function (err, members) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.members
Indicates the members array of conversation.
Get Watchers
Retrieves the list of users who are watchers of the conversation. A watcher refers to a user who has entered the conversation and is currently online.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
let watchersListQuery = conversation.createWatchersListQuery();
// number - represent number of items. (Default: 25)
watchersListQuery.limit = 25;
// number - represent number of items to be skipped from begining. (Default: 0)
watchersListQuery.skip = 0;
watchersListQuery.list(function (err, watchers) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.watchers
Indicates the watchers array of conversation.
Add Members
Adds a member to the conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.addMembers(memberIds, function (err, res) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
memberIds | array | Specifies an array of user IDs to add to the conversation. E.g. ["20236", "20697", "19116"] |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Remove Members
Removes a member from the conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.removeMembers(memberIds, function (err, res) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
memberIds | array | Specifies an array of user IDs to add to the conversation. E.g. ["20236", "20697", "19116"] |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Add Admin
Grants group admin permission to a user. Only an existing member/participant of the group can be admin of the group conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.addAdmin(userId, function (err, res) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
userId | string | The unique ID of the user who is going to be the new group conversation admin. |
Callback Parameters
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Remove Admin
Remove group admin permission from a user.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.removeAdmin(userId, function (err, res) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
userId | string | The unique ID of the user who is going to be removed from group conversation admin role. |
Callback Parameters
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Start Watching
Start watching the conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.startWatching(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Stop Watching
Stop watching the conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.stopWatching(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Clear Conversation
Clears a targeted conversation. Clear conversation is allowed for private conversations only.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.clear(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Join a Conversation
Joins the targeted conversation for a user. Join Conversation is allowed for public conversations only.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.join(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Leave a Conversation
Leaves the targeted conversation for a user.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.leave(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Delete Conversation
Deletes a targeted conversation. The conversation is deleted at logged-in user’s end but appears at other member’s end.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.delete(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Mark Conversation Read
This method mark as read the target conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.markAsRead(timestamp, function (err, res) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
timestamp | date | This is the time when user read the conversation messages. |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Update Title
Updates the title of a group conversation and send a meta-message in the conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.updateTitle(title, function (err, res) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
title | string | Specifies the title for the conversation. |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Update Profile Photo
Updates the profile image of a group conversation and send a meta-message in the conversation.
<input type="file" id="profile">
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
let file = document.getElementById('profile').files[0];
conversation.updateProfilePhoto(file, function (err, updatedConversation) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
file | fileobject | Specifies the file object. |
Callback Params
err
Indicates if there is any error. It will be null if there is no error.updatedConversation
Indicates updated conversation's object.
Mute a Conversation
Mute Conversation feature allows members to turn off notifications of a conversation. The notifications will stay turned off until the member unmute the conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.muteConversation(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Unmute Conversation
Unmute a conversation would allow members to turn on notifications of a conversation which were turned off.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.unmuteConversation(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Start Typing
Triggers typingStatusUpdated
event callback for all active members of the conversation when a group member starts typing.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.startTyping(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
res is a JavaScript object having userId, conversationId and typing status properties.
Stop Typing
Triggers typingStatusUpdated
event callback for all active members of the conversation when a group member stops typing.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.stopTyping(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
res is a javascript object having userId, conversationId and typing status properties.
Get Messages
Retrieves the list of messages from a conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
let messageListQuery = conversation.createMessageListQuery();
// string - represent user id of message owner.
messageListQuery.ownerId = '20141';
// boolean - Search for pinnned or unpinned messages.
messageListQuery.pinned = true';
// number - represent number of items.
messageListQuery.limit = 50;
// number - represent number of items to be skipped from begining.
messageListQuery.skip = 0;
messageListQuery.list(function (err, messages) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.messages
Indicates the response which will be an array of message's object.
Get Messages Count
Retrieves the total number of messages in a conversation.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
let messageListQuery = conversation.createMessageListQuery();
// string - Represents the userID of the message owner.
messageListQuery.ownerId = '20141';
// boolean - Represents the pinnned or unpinned messages.
messageListQuery.pinned = true';
messageListQuery.count(function (err, res) {
});
});
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates response object having count as property.{ "count": 15 }
Send Message
Sends any type of message in a conversation using conversation model object.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
conversation.sendMessage(data, function (err, message) {
});
});
Channelize supports different types of messages like normal, reply, forward, admin.
normal : A normal message created in the conversation.
forward : A forwarded message from previous message. Moreover Forward messages API call automatically send messages of this type.
reply : A message in a reply thread. Messages created with parent_id are automatically of this type.
admin : A message generated by a system event, like updating the group, add members, remove members etc.
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
data | object | yes | It is the object which contain message data fields. |
Data Object Keys
Below table lists all possible keys of above data param.
Name | Type | Required | Description |
---|---|---|---|
id | string | no | The unique ID of the message. |
type | string | no | Specify the type of message. Allowed values are normal, reply, forward, admin . |
body | string | no | The content of the message. |
attachments | array | no | A list of attachments (audio, video, image, location, gif & sticker and text). |
mentionedUsers | array | no | Specifies the tagged members details. |
metaData | object | no | Specifies the meta data of message |
customType | string | no | For grouping messages for customers. |
parentId | string | no | The ID of the parent message, if the message is a reply. |
events | object | no | You can send supportable events with their values. |
createdAt | date | no | The creation time of message. |
recipients | array | no | The ID of users who you want to send and display messages in a conversation but not for other users. If recipients field is not passed, by default the message is sent to all members of a conversation. |
Events in a message: Need to set below object pattern in events
key.
{
"sendPushNotification": true, // Determines whether to send push notification, default value is true.
"updateUnreadCount": true, // Determines whether to send update unread message count of a conversation, default value is true.
}
Mention users in a message: Using the mentionedUsers parameter, you can tag or @mention members in the group conversation as used below:
If a message object has mentionedUsers in it, then %s in the body should be replaced with the @mentioned users in their respective order.
Mentioned Users Params
Name | Type | Description |
---|---|---|
userId | string | The unique ID of the user you want to tag/@mention. |
order | array | Specifies the order in which tagged/mentioned users need to be displayed. |
wordCount | array | Specifies the number of words you want to display for a tagged/mentioned users. This is useful when a user wants to show only first name "Alen" for a user "Alen Joe" when tagged/mentioned. |
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
// For Message: "Hey @Alen Joe and @Sydney Millers, How are you ?'
let body = 'Hey %s and %s, How are you ?'
let mentionedUsers = [{
userId: '18859',
order: 1,
wordCount: 2
}, {
userId: '20697',
order: 2,
wordCount: 2
}];
conversation.sendMessage(body, mentionedUsers, function (err, message) {
});
});
Attachment types in a message
By default Channelize’s pre built UI components support the following attachment types:
- Audio
- Video
- Image
- Text
- Location
- Gif & Sticker
- Admin Message
NOTE: If you want to build your own UI, the API allows type
field value different apart from supported by our UI components. Moreover you are able to send extra keys as well as different keys in attachments apart from supported by our UI components. If you take type
field value different and different extra keys, our UI components will not be supporting these attachments.
Predefine Attachments Params
1. File Attachment Params
This table lists all possible parameters this file object supports.
Name | Type | Required | Description |
---|---|---|---|
type | string | yes | Specify the type of the attachment. |
name | string | yes | Name of the file. |
mimeType | string | yes | Specifies the MIME type of file. |
attachmentType | string | yes | Specifies the type of file. Allowed values are an image, audio, and video. |
extension | string | yes | Specifies the extension of the file. |
fileUrl | string | yes | The file URL where a file is stored. This URL should be publicly accessible. |
thumbnailUrl | string | no | The thumbnail URL where thumbnail has been stored. This URL should be publicly accessible. |
2. Location Attachment Params
The location object will have the below properties.
Name | Type | Required | Description |
---|---|---|---|
type | string | yes | Specify the type of the attachment. |
latitude | number | yes | Specifies the latitude of the location. |
longitude | number | yes | Specifies the longitude of the location. |
title | string | yes | Specifies the name for the location. |
address | string | yes | Specifies the address of the location. |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.message
Indicates response which will be message's object.
Predefine Attachment Params
1. File Attachment Params
This table lists all possible parameters this file object supports.
Name | Type | Required | Description |
---|---|---|---|
type | string | yes | Specify the type of attachment. |
name | string | yes | Name of the file. |
mimeType | string | yes | Specifies the MIME type of file. |
extension | string | yes | Specifies the extension of the file. |
fileUrl | string | yes | The file URL where a file is stored. This URL should be publicly accessible. |
thumbnailUrl | string | no | The thumbnail URL where thumbnail has been stored. This URL should be publicly accessible. |
2. Location Attachment Params
The location object will have the below properties.
Name | Type | Required | Description |
---|---|---|---|
type | string | yes | Specify the type of attachment. |
latitude | number | yes | Specifies the latitude of the location. |
longitude | number | yes | Specifies the longitude of the location. |
title | string | yes | Specifies the name for the location. |
address | string | yes | Specifies the address of the location. |
Upload File
You can Upload your file on our server using this method. This method returns file object as response.
<input type="file" id="file">
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
let file = document.getElementById('file').files[0];
conversation.uploadFile(file, createThumbnail, function(err, fileData) {
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Required | Description |
---|---|---|---|
file | FileObject | yes | Specifies the file object. |
createThumbnail | boolean | no | Specifies if you want to create thumbnail for this file. |
The file provided will be stored on the Channelize server. If you want to store the file separately on your server, you have to send the file as a javascript object with the below properties in the attachments array of send message function.
Get Read Members
This method tells which users already read the message. It takes message objet as an argument.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
let messageListQuery = conversation.createMessageListQuery();
messageListQuery.list(function (error, messages) {
if (error) return console.error(error);
let readMembers = conversation.getReadMembers(messages[0])
});
});
Function Params
This table lists all possible parameters this function supports.
Name | Type | Description |
---|---|---|
message | object | The message object, which read status we want to know. |
Callback Params
err
Indicates if there is an error. It will be null if there is no error.res
Indicates the response. It will be a null value for this case.
Read By All Members
This method is used to know that the message is read by all the members or not. It takes message objet as an argument.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
let messageListQuery = conversation.createMessageListQuery();
messageListQuery.list(function (error, messages) {
if (error) return console.error(error);
let readMembers = conversation.readByAllMembers(messages[0])
});
});
Miscellaneous methods
To Object
Get the json representation of your conversation model object.
channelize.Conversation.getConversation(conversationId, include, function (err, conversation) {
if (err) return console.error(err);
let conversationData = conversation.toJSON();
});