Single chat
note
To generate your own or others JID using the unique username got in registration response, use the const userJid = SDK.getJid(USER_ID) method.
Get Recent Chats#
To get all the list of recent chats, send a request to the server as described below.
Check here for response format
Response Params#
| Arguments | Description | Type |
|---|---|---|
| statusCode | Status Code | Number |
| message | Success/Error Message | String |
| data | Array of Object datas | Array |
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
With Pagination
Example
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
POSITION | Position for Pagination | String | false |
LAST_ROW_ID | Last Row ID of Pagination | String | false |
LIMIT | Pagination Limit | Number | false |
Note: POSITION - Accepts "down"/"up"
Response Params#
| Arguments | Description | Type |
|---|---|---|
| statusCode | Status Code | Number |
| message | Success/Error Message | String |
| data | Array of Object datas | Array |
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.
Text Message#
Sample Request:#
| Param | Description | Type | Required |
|---|---|---|---|
| toJid | JID of the To User | JID String | true |
| messageText | Text Message Body | String | true |
| mentionedUsersIds | Array of Group Mentioned UsersIds | Array | false |
Response Format:#
Image Message#
caution
If Image attachment feature is unavailable for your plan, then it will throw 403 exception
| Param | Description | Type | Required |
|---|---|---|---|
| toJid | JID of the To User | JID String | true |
| fileMessageParams | File Message Params | Object | true |
| fileMessageParams.file | Image File - Should be of type png, jpg, jpeg, svg & gif | File | true |
| fileMessageParams.thumbImage | Image 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. | String | false |
| fileMessageParams.fileSize | Image 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. | String | false |
| fileMessageParams.fileName | Image 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. | String | false |
| fileMessageParams.caption | Image Caption | String | false |
| replyMessageId | Message ID of Original Message | String | false |
| mentionedUsersIds | Array of Group Mentioned UsersIds | Array of Strings | false |
Response Format:#
Audio Message#
caution
If Audio attachment feature is unavailable for your plan, then it will throw 403 exception
| Param | Description | Type | Required |
|---|---|---|---|
| toJid | JID of the To User | JID String | true |
| fileMessageParams | File Message Params | Object | true |
| fileMessageParams.file | Audio File - Should be of type mp3, mpeg & wav | File | true |
| fileMessageParams.fileSize | Audio 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. | String | false |
| fileMessageParams.fileName | Audio 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. | String | false |
| fileMessageParams.duration | Audio 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. | String | false |
| fileMessageParams.caption | Audio Caption | String | false |
| replyMessageId | Message ID of Original Message | String | false |
| mentionedUsersIds | Array of Group Mentioned UsersIds | Array of Strings | false |
Response Format:#
Video Message#
caution
If Video attachment feature is unavailable for your plan, then it will throw 403 exception
| Param | Description | Type | Required |
|---|---|---|---|
| toJid | JID of the To User | JID String | true |
| fileMessageParams | File Message Params | Object | true |
| fileMessageParams.file | Video File - Should be of type mp4 | File | true |
| fileMessageParams.fileSize | Video 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. | String | false |
| fileMessageParams.fileName | Video 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. | String | false |
| fileMessageParams.duration | Video 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. | String | false |
| fileMessageParams.thumbImage | Video 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. | String | false |
| fileMessageParams.caption | Video Caption | String | false |
| replyMessageId | Message ID of Original Message | String | false |
| mentionedUsersIds | Array of Group Mentioned UsersIds | Array of Strings | false |
Response Format:#
Document Message#
caution
If Document attachment feature is unavailable for your plan, then it will throw 403 exception
| Param | Description | Type | Required |
|---|---|---|---|
| toJid | JID of the To User | JID String | true |
| fileMessageParams | File Message Params | Object | true |
| fileMessageParams.file | Document File - Accepted files are pdf, doc, xls, csv, ppt & txt | File | true |
| fileMessageParams.fileSize | Document 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. | String | false |
| fileMessageParams.fileName | Document 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. | String | false |
| fileMessageParams.caption | Document Caption | String | false |
| replyMessageId | Message ID of Original Message | String | false |
| mentionedUsersIds | Array of Group Mentioned UsersIds | Array of Strings | false |
Response Format:#
Download Media#
This method is used to get the media file url when we download the media.
Request Param#
| Status | Description | Type | Required |
|---|---|---|---|
fileToken | File Url | String | true |
filekey | File key is optional param, which we get from the selected Media message Body | String | false |
Example Requests#
Response Format#
Receive Message#
To receive the incoming message from other users, you need to implement the event messageListener, which will be triggered whenever a new message is received. Once the message is received it automatically send the delivery status to the user if the logged-in user is online.
Send Seen Status#
To send message read status, use the below method.
Request Param#
| Status | Description | Type | Required |
|---|---|---|---|
TO_USER_JID | JID of the To User | JID String | true |
MESSAGE_ID | Unique Message ID | String | true |
Send Typing Status#
You can able to send the typing/gone status to the user so that receipent user can aware of that the user is typing the message.
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 |
|---|---|---|---|
TO_JID | JID of the User | JID String | true |
Get Media Messages#
To get the media messages for the particular chat, 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 Param#
| Status | Description | Type | Required |
|---|---|---|---|
TO_USER_JID | JID of the To User | JID String | true |
LAST_MESSAGE_ID | Last Message ID of Pagination | String | false |
Response Params#
| Arguments | Description | Type |
|---|---|---|
| statusCode | Status Code | Number |
| message | Success/Error Message | String |
| data | Array of Object datas | Array |
Send Reply Message#
To send a reply to the original message, we are using sendTextMessage by passing in the additional parameter original message-id.
Request Param#
| Param | Description | Type | Required |
|---|---|---|---|
toJid | JID of the To User/Group | JID String | true |
messageText | Text Message Body | String | true |
replyMessageId | Message ID of Original Message | String | true |
mentionedUsersIds | Array of Group Mentioned UsersIds | Array | false |
Get Reply Message#
To get the reply message by message id, send a request to the server as described below.
Check here for response format
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
REPLY_MESSAGE_ID | Reply Message ID | String | true |
CHAT_TYPE | Chat Type | String | false |
Note: CHAT_TYPE values are "chat"/"groupchat"
Forward Messages#
To forward an message to the single/group chat, we use following methods.
Forward Single/Multiple Messages to Single/Group Chat#
Request Param#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
MESSAGE_IDS | Array of To Original Message Ids | Array | true |
IS_ASYNC | IF Forward has to be in Asynchronous (One by One) - Default true | Boolean | false |
Forward Single/Multiple Messages to Multiple User#
Request Param#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JIDS | Array of To User/JID of the To Users | Array | true |
MESSAGE_IDS | Array of To Original Message Ids | Array | true |
IS_ASYNC | IF Forward has to be in Asynchronous (One by One) - Default true | Boolean | false |
Favourite Messages#
The favourite message is a feature that allows users to mark some messages as favourites. So that they can see those important messages in the future without searching for them in chat.
Once you marked messages as favourite, you can get those from SDK to show them on your app's screen.
Add/Remove Favourites#
caution
If FavouriteMessage feature is unavailable for your plan, then it will throw 403 exception
Request Param#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | String | true |
MESSAGE_ID | Unique Message ID | String | true |
IS_FAVOURITE | true for adding to favourites, false for removing | Boolean | true |
MENTIONED_USERS_IDS | Array of Group Mentioned UsersIds | Array | false |
Get All Favourites#
caution
If FavouriteMessage feature is unavailable for your plan, then it will throw 403 exception
Once get all favourites method initiated, an callback method favouriteMessageListener will be triggered and response will be sent.
Remove All Favourites#
caution
If FavouriteMessage feature is unavailable for your plan, then it will throw 403 exception
Clear Chat Messages#
The clear chat message is a feature that allows users to delete chat messages.
If you want to clear the messages for the entire chat, or multiple chats then you can utilize the below methods.
Clear Chat#
You can clear the messages for any chat by using the below method. The messages will not be deleted from the recipient.
caution
If Clear Chat feature is unavailable for your plan, then it will throw 403 exception
Method Params#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
FAVOURITES | Whether to Delete Favourites Messages or not | Boolean | false |
LAST_MSG_ID | lastMsgId which the message is send | String | false |
Delete Chat#
You can delete the chat (from recent chat) by using the below method.
caution
If Delete Chat feature is unavailable for your plan, then it will throw 403 exception
Method Params#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
FAVOURITES | Whether to Delete Favourites Messages or not | Boolean | false |
Clear All Chat#
You can clear all conversation by using the below method.
Delete Messages#
Delete message is a feature that is found in modern messaging apps that allows the user to delete the message once it is sent. Once you sent the message, you can able to delete the messages by using built-in SDK methods.
Delete All Recent Chats#
To delete all recent chat messages use below method, which deletes all single and group conversation.
Delete for Me#
If you want to delete the messages for yourself only then you can use the below method.
caution
If DeleteMessage feature is unavailable for your plan, then it will throw 403 exception
Note: The messages will not be deleted from the recipient.
Delete for Everyone#
If you want to delete the messages for yourself and the receiver then you can use the below method. The messages will also be deleted from the recipient.
caution
If DeleteMessage feature is unavailable for your plan, then it will throw 403 exception
Method Params#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
MESSAGE_IDS | Array of To Message Ids | Array | true |
Mute Chat#
To Mute the chat use below method which disables the notification for the chat when the new messages are received or any action on group chat.
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
IS_MUTED | true for muting the chat, false for removing | Boolean | true |
Archive Chat#
Archive/Unarchive Chat#
To Archive the single and group chat use below method.
Method Params#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
IS_ARCHIVED | true for archive the chat, false for removing | Boolean | true |
Get All Archived Chat#
Retrieves all archived chats.
Display Browser Notification#
Display the browser notification by providing the notification object into the showChatNotification method. Notification would display when a user receive a message while user on different screen instead of on webchat application screen.
Response Params#
| Arguments | Description | Type |
|---|---|---|
| statusCode | Status Code | Number |
| message | Success/Error Message | String |