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.
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
#
Text Message#
Sample Request:#
Request ParamStatus | Description | Type | Required |
---|---|---|---|
TO_USER_JID | JID of the To User | JID String | true |
MESSAGE_BODY | Text Message Body | String | true |
MESSAGE_ID | Message Id | String | false |
REPLY_TO | Message ID of Original Message | String | false |
MENTIONED_USERS_IDS | 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
#
Sample Request:#
Request ParamsStatus | Description | Type | Required |
---|---|---|---|
TO_USER_JID | JID of the To User | JID String | true |
IMAGE_FILE | Image File - Should be of type png , jpg , jpeg , svg & gif | File | true |
FILE_OPTIONS | File Option Params | Object | true |
FILE_OPTIONS.msgId | Message Id | String | false |
FILE_OPTIONS.caption | Image Caption | String | false |
FILE_OPTIONS.thumbImage | Thumbnail Image - Base64 | String | false |
FILE_OPTIONS.webWidth | Width for Web | String | false |
FILE_OPTIONS.webHeight | Height for Web | String | false |
FILE_OPTIONS.androidWidth | Width for Android | String | false |
FILE_OPTIONS.androidHeight | Height for Android | String | false |
FILE_OPTIONS.thumbRatio | Aspect ratio for Thumb Image | String | false |
REPLY_TO | Message ID of Original Message | String | false |
MENTIONED_USERS_IDS | Array of Group Mentioned UsersIds | Array | false |
Note: Width and Height Params are Used to Display the Image with Original Dimenstions
#
Response Format:
#
Audio Messagecaution
If Audio attachment feature is unavailable for your plan, then it will throw 403 exception
#
Sample Request:#
Request ParamsStatus | Description | Type | Required |
---|---|---|---|
TO_USER_JID | JID of the To User | JID String | true |
AUDIO_FILE | Image File - Should be of type mp3 , mpeg & wav | File | true |
FILE_OPTIONS | File Option Params | Object | true |
FILE_OPTIONS.msgId | Message Id | String | false |
FILE_OPTIONS.caption | Audio Caption | String | false |
FILE_OPTIONS.duration | Audio Duration | Number | false |
REPLY_TO | Message ID of Original Message | String | false |
MENTIONED_USERS_IDS | Array of Group Mentioned UsersIds | Array | false |
#
Response Format:#
Video Messagecaution
If Video attachment feature is unavailable for your plan, then it will throw 403 exception
#
Sample Request:#
Request ParamsStatus | Description | Type | Required |
---|---|---|---|
TO_USER_JID | JID of the To User | JID String | true |
VIDEO_FILE | Image File - Should be of type mp4 | File | true |
FILE_OPTIONS | File Option Params | Object | true |
FILE_OPTIONS.msgId | Message Id | String | false |
FILE_OPTIONS.caption | Video Caption | String | false |
FILE_OPTIONS.duration | Video Duration | Number | false |
FILE_OPTIONS.thumbImage | Thumbnail Image - Base64 | String | false |
FILE_OPTIONS.webWidth | Width | String | false |
FILE_OPTIONS.webHeight | Height for Web | String | false |
FILE_OPTIONS.androidWidth | Width for Android | String | false |
FILE_OPTIONS.androidHeight | Height for Android | String | false |
FILE_OPTIONS.thumbRatio | Aspect ratio for Thumb Image | String | false |
REPLY_TO | Message ID of Original Message | String | false |
MENTIONED_USERS_IDS | Array of Group Mentioned UsersIds | Array | false |
#
Response Format:#
Document Messagecaution
If Document attachment feature is unavailable for your plan, then it will throw 403 exception
#
Sample Request:#
Request ParamsStatus | Description | Type | Required |
---|---|---|---|
TO_USER_JID | JID of the To User | JID String | true |
DOCUMENT_FILE | Document File - Accepted files are pdf , doc , xls , csv , ppt & txt | File | true |
FILE_OPTIONS | File Option Params | Object | true |
FILE_OPTIONS.msgId | Message Id | String | false |
FILE_OPTIONS.caption | Document Caption | String | false |
REPLY_TO | Message ID of Original Message | String | false |
MENTIONED_USERS_IDS | Array of Group Mentioned UsersIds | Array | false |
#
Response Format:#
Media Message DataSend Media message as a meta data, here media will be uploaded externally (client side) and media information will be sent.
#
Request ParamsStatus | 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 |
REPLY_TO | Message ID of Original Message | String | false |
MENTIONED_USERS_IDS | Array of Group Mentioned UsersIds | Array | false |
#
Example Requests#
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.
Check here for response format
#
Request ParamStatus | 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 |
MENTIONED_USERS_IDS | Array of Group Mentioned UsersIds | Array | false |
Note: MESSAGE_ID can be passed as empty/null
#
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/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 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 |
#
Response Format:#
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 |
#
Response Format:#
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. A callback method MessageListener will be triggered and response will be sent.
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. A callback method MessageListener will be triggered and response will be sent.
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.
#
Response Format:#
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 |