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
Example
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
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.
MESSAGE_ID - Unique Id for each and every messages. When you given your MESSAGE_ID, SDK will take your message id otherwise SDK will generate it's own MESSAGE_ID
Media Message Data#
Send Media message as a meta data, here media will be uploaded externally (client side) and media information will be sent.
Request Params#
| Status | Description | Type | Required |
|---|---|---|---|
TO_USER_JID | JID of the To User | JID String | true |
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#
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 |
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#
| Status | Description | Type | Required |
|---|---|---|---|
TO_JID | JID of the To User/Group | JID String | true |
MESSAGE_BODY | Text Message Body | String | true |
MESSAGE_ID | Unique Message ID | String | true |
REPLY_TO | Message ID of Original Message | String | true |
Note: MESSAGE_ID can be passed as empty/null
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/Group JIDs | 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#
Request Param#
| Status | Description | Type | Required |
|---|---|---|---|
MESSAGE_ID | Unique Message ID | String | true |
IS_FAVOURITE | true for adding to favourites, false for removing | Boolean | true |
Get All Favourites#
Once get all favourites method initiated, an callback method favouriteMessageListener will be triggered and response will be sent.
Remove All Favourites#
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.
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 |
Delete Chat#
You can delelte the chat (from recent chat) by using the below method.
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.
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.
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 |