Group chat

Groups is the simplest way to chat with multiple user at any given time.

caution

If GroupChat feature is unavailable for your plan, then the below methods will not be able to access and throw 403 exception

Create Group#

To create a new group use below method. Once the request is made successfully, an groupProfileListener callback will be triggered. Response will be of two types, one is for successfull adding of participant with both party details and other one is for group profile udpate.

await SDK.createGroup(`GROUP_NAME`, [`USER_JID`], `GROUP_IMAGE`);

Request Params#

StatusDescriptionTypeRequired
GROUP_NAMEGroup NameStringtrue
USER_JIDArray of User JIDJID Stringtrue
GROUP_IMAGEProfile Image - Upload an image file or image URLFile / Stringfalse

Get GroupJid#

Use the below method to generate the GroupJID using the GroupId.

SDK.getGroupJid(`GROUP_ID`);

Example Request#

SDK.getGroupJid(`0f617991-08d0-4474-ae6c-f070dc63bb1a`);

Example Response#

{
statusCode: 200,
message: "Success",
groupJid: "0f617991-08d0-4474-ae6c-f070dc63bb1a@mix.xmppdomain"
}

Get All Groups#

To get the all groups that the user part of, send a request as described below.

await SDK.getGroupsList();

Check here for response format

Set Group Profile Detail#

To set the Profile detail of the group, send a request as described below. Once the request is made successfully, an groupProfileListener callback will be triggered and a updated profile response will be received for all group participants.

await SDK.setGroupProfile(`GROUP_JID`, `GROUP_NAME`, `GROUP_IMAGE`);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDGroup JIDJID Stringtrue
GROUP_NAMENickname of the GroupStringtrue
GROUP_IMAGEGroup Image - Upload an image file or image URLFile / Stringfalse

Get Group Profile Detail#

To get the Profile detail of the group, send a request as described below. Once the request is made successfully, an groupProfileListener callback will be triggered and a group profile response will be received.

await SDK.getGroupProfile(`GROUP_JID`);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDGrouop JIDJID Stringtrue

Get Group Participants#

To get the all the group members, send a request as described below.

await SDK.getGroupParticipants(`GROUP_JID`);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDGrouop JIDJID Stringtrue

Add Participants#

To add a participants to a existing group use below method. You can add multiple participants by passing multiple USER_JID. Once the request is made successfully, an groupProfileListener callback will be triggered and response will be received for all group participants.

await SDK.addParticipants(`GROUP_JID`, `GROUP_NAME`, [`USER_JID`]);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDGroup JIDJID Stringtrue
GROUP_NAMEGroup NameStringtrue
USER_JIDArray of To User JIDJID Stringtrue

Remove Participant#

To remove a participant from a existing group use below method. Once the request is made successfully, an groupProfileListener callback will be triggered and response will be received for all group participants.

await SDK.removeParticipant(`GROUP_JID`, `USER_JID`, `IS_ADMIN`);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDGroup JIDJID Stringtrue
USER_JIDUser JIDJID Stringtrue
IS_ADMINWhether the To User is Admin or notBooleantrue

Make As Admin#

To make a participant as a admin to the group. Once the request is made successfully, an groupProfileListener callback will be triggered and response will be received for all group participants.

await SDK.makeAsAdmin(`GROUP_JID`, `USER_JID`);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDGroup JIDJID Stringtrue
USER_JIDUser JIDJID Stringtrue

Exit Group#

To leave a group for the participant use below method. If the user is admin pass isAdmin as a true, otherwise false. Once the request is made successfully, an groupProfileListener callback will be triggered and response will be received for all group participants.

await SDK.userExitGroup(`GROUP_JID`, `USER_JID`, `IS_ADMIN`);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDGroup JIDJID Stringtrue
USER_JIDUser JIDJID Stringtrue
IS_ADMINWhether the User is Admin or notStringtrue

Delete Group#

To delete the group for the user.

await SDK.userDeleteGroup(`GROUP_JID`);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDGroup JIDJID Stringtrue

Get Chat Messages#

To get the chat history of the selected user, send a request to the server as described below.

Check here for response format

Without Pagination

await SDK.getChatMessages(`GROUP_JID`);

With Pagination

await SDK.getChatMessages(`GROUP_JID`, `POSITION`, `LAST_ROW_ID`, `LIMIT`);

Example

await SDK.getChatMessages(
"91XXXXXXXXXX@mix.domain.com",
"down",
"12345",
10,
);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDJID of the To GroupJID Stringtrue
POSITIONPosition for PaginationStringfalse
LAST_ROW_IDLast Row ID of PaginationStringfalse
LIMITPagination LimitNumberfalse

Note: POSITION - Accepts "down"/"up"

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataArray of Object datasArray

Send Typing Status#

You can able to send the typing/gone status to the group so that all group participants can aware of that the user is typing the message. If you want to send the typing status for a group, you can utilize the below method.

await SDK.sendTypingStatus(`TO_GROUP_JID`);

When the user starts typing the message in the input box of the chat window, call the below method to send the composing status, so that they can show a typing message in the header/recent chat.

Once the user stopped/finished typing the message send the gone status as described below, so that they can hide a typing message in the header/recent chat.

await SDK.sendTypingGoneStatus(`TO_GROUP_JID`);

Method parameter#

StatusDescriptionTypeRequired
GROUP_JIDGroup JIDJID Stringtrue

Send Message#

To send the message to the user, use the below methods. Different messages such as text, image, audio, video & document type messages can be sent using the below methods.

Note: Send message to single and group chat uses same methods. SDK will identify the difference by the JID format. If the TO_JID has the mix in it, it is considered as a group chat otherwise single chat. Single chat send message methods are defined here.

Text Message#

await SDK.sendTextMessage({
toJid: "",
messageText: "",
replyMessageId: "",
mentionedUsersIds: []
});
ParamDescriptionTypeRequired
toJidGroup JIDJID Stringtrue
messageTextText Message BodyStringtrue
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArrayfalse

Response Format:#

statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
msgBody: {
message: "", // String - Message Body
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Image Message#

caution

If Image attachment feature is unavailable for your plan, then it will throw 403 exception

await SDK.sendFileMessage({
toJid: "",
messageType: "image",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: "",
},
replyMessageId: "",
mentionedUsersIds: []
});
ParamDescriptionTypeRequired
toJidGroup JIDJID Stringtrue
fileMessageParamsFile Message ParamsObjecttrue
fileMessageParams.fileImage File - Should be of type png, jpg, jpeg, svg & gifFiletrue
fileMessageParams.thumbImageImage File Thumb Image. When the value not given, SDK will generate thumb image for the given FILE. When using the fileUrl SDK won't generate the thumb image.Stringfalse
fileMessageParams.fileSizeImage File Size. When the value not given, SDK will detect the size of the given FILE. When using the fileUrl SDK won't detect the size.Stringfalse
fileMessageParams.fileNameImage File Name. When the value not given, SDK will detect the name of the given FILE. When using the fileUrl SDK won't detect the name.Stringfalse
fileMessageParams.captionImage CaptionStringfalse
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArrayfalse

Response Format:#

statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
msgBody: {
media: { // For Media Message Only
caption: "", // String - Media Caption
duration: "", // String - Duration - For Audio/Videos
fileName: "", // String - File Name
file_size: "", // Number - File Size
fileToken: "", // String - File Url
is_downloaded: "", // Number - Downloaded Status
is_uploading: "", // Number - Uploading Status
local_path: "", // String - Local Path
thumb_image: "", // Base64 - Thumb Image
}
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Audio Message#

caution

If Audio attachment feature is unavailable for your plan, then it will throw 403 exception

await SDK.sendFileMessage({
toJid: "",
messageType: "audio",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: "",
},
replyMessageId: "",
mentionedUsersIds: []
});
ParamDescriptionTypeRequired
toJidGroup JIDJID Stringtrue
fileMessageParamsFile Message ParamsObjecttrue
fileMessageParams.fileAudio File - Should be of type mp3, mpeg & wavFiletrue
fileMessageParams.fileSizeAudio File Size. When the value not given, SDK will detect the size of the given FILE. When using the fileUrl SDK won't detect the size.Stringfalse
fileMessageParams.fileNameAudio File Name. When the value not given, SDK will detect the name of the given FILE. When using the fileUrl SDK won't detect the name.Stringfalse
fileMessageParams.durationAudio File Duration. When the value not given, SDK will detect the duration of the given FILE. When using the fileUrl SDK won't detect the duration.Stringfalse
fileMessageParams.captionAudio CaptionStringfalse
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArrayfalse

Response Format:#

statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
msgBody: {
media: { // For Media Message Only
caption: "", // String - Media Caption
duration: "", // String - Duration - For Audio/Videos
fileName: "", // String - File Name
file_size: "", // Number - File Size
fileToken: "", // String - File Url
is_downloaded: "", // Number - Downloaded Status
is_uploading: "", // Number - Uploading Status
local_path: "", // String - Local Path
thumb_image: "", // Base64 - Thumb Image
}
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Video Message#

caution

If Video attachment feature is unavailable for your plan, then it will throw 403 exception

await SDK.sendFileMessage({
toJid: "",
messageType: "video",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: ""
},
replyMessageId: "",
mentionedUsersIds: []
});
ParamDescriptionTypeRequired
toJidGroup JIDJID Stringtrue
fileMessageParamsFile Message ParamsObjecttrue
fileMessageParams.fileVideo File - Should be of type mp4Filetrue
fileMessageParams.fileSizeVideo File Size. When the value not given, SDK will detect the size of the given FILE. When using the fileUrl SDK won't detect the size.Stringfalse
fileMessageParams.fileNameVideo File Name. When the value not given, SDK will detect the name of the given FILE. When using the fileUrl SDK won't detect the name.Stringfalse
fileMessageParams.durationVideo File Duration. When the value not given, SDK will detect the duration of the given FILE. When using the fileUrl SDK won't detect the duration.Stringfalse
fileMessageParams.thumbImageVideo File Thumb Image. When the value not given, SDK will generate thumb image for the given FILE. When using the fileUrl SDK won't generate the thumb image.Stringfalse
fileMessageParams.captionVideo CaptionStringfalse
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArrayfalse

Response Format:#

statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
msgBody: {
media: { // For Media Message Only
caption: "", // String - Media Caption
duration: "", // String - Duration - For Audio/Videos
fileName: "", // String - File Name
file_size: "", // Number - File Size
fileToken: "", // String - File Url
is_downloaded: "", // Number - Downloaded Status
is_uploading: "", // Number - Uploading Status
local_path: "", // String - Local Path
thumb_image: "", // Base64 - Thumb Image
}
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Document Message#

caution

If Document attachment feature is unavailable for your plan, then it will throw 403 exception

await SDK.sendFileMessage({
toJid: GroupJID,
messageType: "file",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: ""
},
replyMessageId: "",
mentionedUsersIds: []
});
ParamDescriptionTypeRequired
toJidGroup JIDJID Stringtrue
fileMessageParamsFile Message ParamsObjecttrue
fileMessageParams.fileDocument File - Accepted files are pdf, doc, xls, csv, ppt & txtFiletrue
fileMessageParams.fileSizeDocument File Size. When the value not given, SDK will detect the size of the given FILE. When using the fileUrl SDK won't detect the size.Stringfalse
fileMessageParams.fileNameDocument File Name. When the value not given, SDK will detect the name of the given FILE. When using the fileUrl SDK won't detect the name.Stringfalse
fileMessageParams.captionDocument CaptionStringfalse
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArrayfalse

Response Format:#

status code: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
msgBody: {
media: { // For Media Message Only
caption: "", // String - Media Caption
duration: "", // String - Duration - For Audio/Videos
fileName: "", // String - File Name
file_size: "", // Number - File Size
fileToken: "", // String - File Url
is_downloaded: "", // Number - Downloaded Status
is_uploading: "", // Number - Uploading Status
local_path: "", // String - Local Path
thumb_image: "", // Base64 - Thumb Image
}
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Download Media#

This method is used to get the media file url when we download the media.

await SDK.getMediaURL(`fileToken`, `filekey`);

Request Param#

StatusDescriptionTypeRequired
fileTokenFile UrlStringtrue
filekeyFile key is optional param, which we get from the selected Media message BodyStringfalse

Example Requests#

await SDK.getMediaURL("9178680804311682318992048B1cCBm6F6WIVI38s9r1a.mp4", "AllRgIXOXZAHxAzxxggTTQvapoxpzEfx");

Response Format#

{
"statusCode": "" // Number - status code,
"message": "", // String - Success/Error Message
"data": {
"blobUrl": "", // String - blobUrl
"blob": {
"size" : "", // Number - size
"type" : "" // String
}
}
}

Get Group Media Messages#

To get the media messages for the particular groupchat. On initial request it fetches three media. Then on the pagination request by passing the last message-id, it fetches 10 next media messages.

Check here for response format

caution

If getMediaMessages feature is unavailable for your plan, then it will throw 403 exception

Without Pagination

await SDK.getMediaMessages(`TO_GROUP_JID`);

With Pagination

await SDK.getMediaMessages(`TO_GROUP_JID`, `LAST_MESSAGE_ID`);

Request Params#

StatusDescriptionTypeRequired
TO_GROUP_JIDJID of the GroupJID Stringtrue
LAST_MESSAGE_IDLast Message ID of PaginationStringfalse

Get Group Message Info#

To get the group message info use below method. It retrieves the message info with the number of group members has received and seen the message. Once the request is made successfully, an groupMsgInfoListener callback will be triggered and response will be received;

await SDK.getGroupMsgInfo(`GROUP_JID`, `MESSAGE_ID`);

Request Params#

StatusDescriptionTypeRequired
GROUP_JIDJID of the GroupJID Stringtrue
MESSAGE_IDMessage IDStringtrue

Clear & Delete Message#

Clear and Delete Message follows same as described in the single chat section. Instead of sending user jid, group jid will be sent to clear/delete group related chats.