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 ChatsTo get all the list of recent chats, send a request to the server as described below.
Check here for response format
#
Response ParamsArguments | Description | Type |
---|---|---|
statusCode | Status Code | Number |
message | Success/Error Message | String |
data | Array of Object datas | Array |
#
Get Chat MessagesTo 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 ParamsStatus | 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 ParamsArguments | Description | Type |
---|---|---|
statusCode | Status Code | Number |
message | Success/Error Message | String |
data | Array of Object datas | Array |
#
Send MessageTo 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 Messagecaution
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 Messagecaution
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 Messagecaution
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 Messagecaution
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 MediaThis method is used to get the media file url when we download the media.
#
Request ParamStatus | 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 MessageTo 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 StatusTo send message read status, use the below method.
#
Request ParamStatus | Description | Type | Required |
---|---|---|---|
TO_USER_JID | JID of the To User | JID String | true |
MESSAGE_ID | Unique Message ID | String | true |
#
Send Typing StatusYou 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 parameterStatus | Description | Type | Required |
---|---|---|---|
TO_JID | JID of the User | JID String | true |
#
Get Media MessagesTo 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 ParamStatus | 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 ParamsArguments | Description | Type |
---|---|---|
statusCode | Status Code | Number |
message | Success/Error Message | String |
data | Array of Object datas | Array |
#
Send Reply MessageTo send a reply to the original message, we are using sendTextMessage by passing in the additional parameter original message-id.
#
Request ParamParam | 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 MessageTo get the reply message by message id, send a request to the server as described below.
Check here for response format
#
Request ParamsStatus | 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 MessagesTo forward an message to the single/group chat, we use following methods.
#
Forward Single/Multiple Messages to Single/Group Chat#
Request ParamStatus | 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 ParamStatus | 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 MessagesThe 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 Favouritescaution
If FavouriteMessage feature is unavailable for your plan, then it will throw 403 exception
#
Request ParamStatus | 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 Favouritescaution
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 Favouritescaution
If FavouriteMessage feature is unavailable for your plan, then it will throw 403 exception
#
Clear Chat MessagesThe 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 ChatYou 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 ParamsStatus | 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 ChatYou 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 ParamsStatus | 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 ChatYou can clear all conversation by using the below method.
#
Delete MessagesDelete 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 ChatsTo delete all recent chat messages use below method, which deletes all single and group conversation.
#
Delete for MeIf 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 EveryoneIf 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 ParamsStatus | Description | Type | Required |
---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
MESSAGE_IDS | Array of To Message Ids | Array | true |
#
Mute ChatTo 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 ChatTo Archive the single and group chat use below method.
#
Method ParamsStatus | 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 ChatRetrieves all archived chats.
#
Display Browser NotificationDisplay 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 ParamsArguments | Description | Type |
---|---|---|
statusCode | Status Code | Number |
message | Success/Error Message | String |