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.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_NAME | Group Name | String | true |
USER_JID | Array of User JID | JID String | true |
GROUP_IMAGE | Profile Image - Upload an image file or image URL | File / String | false |
Get All Groups#
To get the all groups that the user part of, send a request as described below.
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.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | Group JID | JID String | true |
GROUP_NAME | Nickname of the Group | String | true |
GROUP_IMAGE | Group Image - Upload an image file or image URL | File / String | false |
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.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | Grouop JID | JID String | true |
Get Group Participants#
To get the all the group members, send a request as described below. Once the request is made successfully, an messageListener callback will be triggered and a updated profile response will be received.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | Grouop JID | JID String | true |
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.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | Group JID | JID String | true |
GROUP_NAME | Group Name | String | true |
USER_JID | Array of To User JID | JID String | true |
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.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | Group JID | JID String | true |
USER_JID | User JID | JID String | true |
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.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | Group JID | JID String | true |
USER_JID | User JID | JID String | true |
Exit Group#
To leave a group for the participant use below method. Once the request is made successfully, an groupProfileListener callback will be triggered and response will be received for all group participants.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | Group JID | JID String | true |
USER_JID | User JID | JID String | true |
Delete Group#
To delete the group for the user.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | Group JID | JID String | true |
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.
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.
Method parameter#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | Group JID | JID String | true |
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_JIDhas themixin it, it is considered as a group chat otherwise single chat. Single chat send message methods are defined here.
Text Message#
| Status | Description | Type | Required |
|---|---|---|---|
TO_GROUP_JID | JID of the Group | JID String | true |
MESSAGE_BODY | Text Message Body | String | true |
Image Message#
| Status | Description | Type | Required |
|---|---|---|---|
IMAGE_FILE | Image File - Should be of type png, jpg, jpeg, svg & gif | File | true |
FILE_OPTIONS | File Option Params | Object | true |
FILE_OPTIONS.caption | Image Caption | String | false |
FILE_OPTIONS.thumbImage | Thumbnail Image - Base64 | String | false |
FILE_OPTIONS.msgId | Message Id | String | false |
caution
If Image attachment feature is unavailable for your plan, then it will throw 403 exception
Audio Message#
| Status | Description | Type | Required |
|---|---|---|---|
AUDIO_FILE | Image File - Should be of type mp3, mpeg & wav | File | true |
FILE_OPTIONS | File Option Params | Object | true |
FILE_OPTIONS.caption | Audio Caption | String | false |
FILE_OPTIONS.duration | Audio Duration - "mm:ss" | String | false |
FILE_OPTIONS.msgId | Message Id | String | false |
caution
If Audio attachment feature is unavailable for your plan, then it will throw 403 exception
Video Message#
| Status | Description | Type | Required |
|---|---|---|---|
VIDEO_FILE | Image File - Should be of type mp4 | File | true |
FILE_OPTIONS | File Option Params | Object | true |
FILE_OPTIONS.caption | Video Caption | String | false |
FILE_OPTIONS.duration | Video Duration - "mm:ss" | String | false |
FILE_OPTIONS.thumbImage | Thumbnail Image for Video - Base64 | String | false |
FILE_OPTIONS.msgId | Message Id | String | false |
caution
If Video attachment feature is unavailable for your plan, then it will throw 403 exception
Document Message#
| Status | Description | Type | Required |
|---|---|---|---|
DOCUMENT_FILE | Document File - Accepted files are pdf, doc, xls, csv, ppt & txt | File | true |
FILE_OPTIONS | File Option Params | Object | true |
FILE_OPTIONS.caption | Document Caption | String | false |
FILE_OPTIONS.msgId | Message Id | String | false |
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.
| Status | Description | Type | Required |
|---|---|---|---|
MSG_TYPE | Message Type - Accepted types are image, video, audio & file | File | true |
FILE_OPTIONS | File Option Params | Object | true |
FILE_OPTIONS.fileName | File Name | String | true |
FILE_OPTIONS.fileURL | File Url | String | true |
FILE_OPTIONS.fileSize | File Size | String | true |
FILE_OPTIONS.duration | Media Duration - "mm:ss" | String | true if MSG_TYPE is "audio"/"video" |
FILE_OPTIONS.thumbImg | Thumbnail Image - Base64 | String | true if MSG_TYPE is "video" |
FILE_OPTIONS.caption | Media Caption | String | false |
Example Requests#
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
With Pagination
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
TO_GROUP_JID | JID of the Group | JID String | true |
LAST_MESSAGE_ID | Last Message ID of Pagination | String | false |
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;
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
GROUP_JID | JID of the Group | JID String | true |
MESSAGE_ID | Message ID | String | true |
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.