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`);

Check here for response format

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`);

Check here for response format

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`);

Check here for response format

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. An groupProfileListener callback will be triggered and response will be received.

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.

Check here for response format for both TypingStatus and GoneStatus 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 group, 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(`TO_GROUP_JID`, `MESSAGE_BODY`);
StatusDescriptionTypeRequired
TO_GROUP_JIDJID of the GroupJID Stringtrue
MESSAGE_BODYText Message BodyStringtrue

Image Message#

await SDK.sendImageMessage(`TO_GROUP_JID`, `IMAGE_FILE`, `FILE_OPTIONS`);
StatusDescriptionTypeRequired
IMAGE_FILEImage File - Should be of type png, jpg, jpeg, svg & gifFiletrue
FILE_OPTIONSFile Option ParamsObjecttrue
FILE_OPTIONS.captionImage CaptionStringfalse
FILE_OPTIONS.thumbImageThumbnail Image - Base64Stringfalse
FILE_OPTIONS.msgIdMessage IdStringfalse
caution

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

Audio Message#

await SDK.sendAudioMessage(`TO_GROUP_JID`, `AUDIO_FILE`, `FILE_OPTIONS`);
StatusDescriptionTypeRequired
AUDIO_FILEImage File - Should be of type mp3, mpeg & wavFiletrue
FILE_OPTIONSFile Option ParamsObjecttrue
FILE_OPTIONS.captionAudio CaptionStringfalse
FILE_OPTIONS.durationAudio Duration - "mm:ss"Stringfalse
FILE_OPTIONS.msgIdMessage IdStringfalse
caution

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

Video Message#

await SDK.sendVideoMessage(`TO_GROUP_JID`, `VIDEO_FILE`, `FILE_OPTIONS`);
StatusDescriptionTypeRequired
VIDEO_FILEImage File - Should be of type mp4Filetrue
FILE_OPTIONSFile Option ParamsObjecttrue
FILE_OPTIONS.captionVideo CaptionStringfalse
FILE_OPTIONS.durationVideo Duration - "mm:ss"Stringfalse
FILE_OPTIONS.thumbImageThumbnail Image for Video - Base64Stringfalse
FILE_OPTIONS.msgIdMessage IdStringfalse
caution

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

Document Message#

await SDK.sendDocumentMessage(`TO_GROUP_JID`, `DOCUMENT_FILE`, `FILE_OPTIONS`);
StatusDescriptionTypeRequired
DOCUMENT_FILEDocument File - Accepted files are pdf, doc, xls, csv, ppt & txtFiletrue
FILE_OPTIONSFile Option ParamsObjecttrue
FILE_OPTIONS.captionDocument CaptionStringfalse
FILE_OPTIONS.msgIdMessage IdStringfalse
caution

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

Media Message Data#

Send Media message as a meta data, here media will be uploaded externally (client side) and media information will be sent.

await SDK.sendMediaMessageData(`TO_GROUP_JID`, `MSG_TYPE`, `FILE_OPTIONS`);
StatusDescriptionTypeRequired
MSG_TYPEMessage Type - Accepted types are image, video, audio & fileFiletrue
FILE_OPTIONSFile Option ParamsObjecttrue
FILE_OPTIONS.fileNameFile NameStringtrue
FILE_OPTIONS.fileURLFile UrlStringtrue
FILE_OPTIONS.fileSizeFile SizeStringtrue
FILE_OPTIONS.durationMedia Duration - "mm:ss"Stringtrue if MSG_TYPE is "audio"/"video"
FILE_OPTIONS.thumbImgThumbnail Image - Base64Stringtrue if MSG_TYPE is "video"
FILE_OPTIONS.captionMedia CaptionStringfalse

Example Requests#

const fileOptions = {
fileName: "fileName.png",
fileSize: 1000,
fileURL: "https://imagepath.com",
};
await SDK.sendMediaMessageData("222222222@mix.domain.com", "image", fileOptions);
const fileOptions = {
fileName: "fileName.png",
fileSize: 1000,
fileURL: "https://imagepath.com",
duration: "02:22",
thumbImg: "base64",
};
await SDK.sendMediaMessageData("222222222@mix.domain.com", "video", fileOptions);

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

Download Media#

This method is used to get the media file url when we download the media.In this download media same as described in the single chat section.

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.