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.

await SDK.getRecentChats();

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataArray of Object datasArray

Response Format:#

Get Recent Chats#

To get all the list of recent chats, send a request to the server as described below.

await SDK.getRecentChats();

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataArray of Object datasArray

Response Format:#

{
"statusCode": 200,
"message": "Success",
"data": [
{
"chatType": "chat",
"createdAt": "2023-09-06 10:52:46",
"deleteStatus": 0,
"fromUserId": "", // String - fromUserId
"msgBody": {
"nickName": "",
"mid": "",// String - user mid
"message": "",// String - User Text Mesaage
"message_type": "",// String - User Text Mesaage Type
"replyTo": "",
"mentionedUsersIds": ""
},
"msgId": "",// String - user msgId
"msgStatus": 1,
"msgType": "text",
"muteStatus": 0,
"publisherId": "",// String - user Number
"timestamp": 1693977766567,
"toUserId": "",
"unreadCount": 0,
"userId": "",// String - userId
"userJid": "",// String - userJid
"profileDetails": {
"nickName": "",// String - User Name
"image": "",//String - image
"status": "",//String - User status
"colorCode": "#7b0b88",
"userId": "",// String - userId
"userJid": "",// String - userJid
"email": "",//String - User Email-Id
"mobileNumber": "",//String - User mobile number
"isAdminBlocked": 0
}
},
]
}

Get Chat Messages#

To get the chat history of the selected user, send a request to the server as described below.

Without Pagination

await SDK.getChatMessages({
toJid: ""
});

Example

await SDK.getChatMessages({
toJid: "91XXXXXXXXXX@domain.com",
});

Request Params#

StatusDescriptionTypeRequired
toJidJID of the To User/GroupJID Stringtrue

Response Format#

{
statusCode: 200,
message: "Success",
userJid: "", // String - Requested User Jid
"data": [
{
"createdAt": "",//String - Message Created Time
"chatType": "chat",
"favouriteBy": "",
"favouriteStatus": 0,
"deleteStatus": 0,
"fromUserJid": "",// string -fromUserJid
"publisherJid": "",// string -publisherJid
"publisherId": "",// string -publisherId
"timestamp": "",//number- timestamp
"msgId": "",//string - msgId
"msgStatus": 1,
"msgBody": {
"nickName": "",
"mid": "",//string - msgId
"message": "",//string - send media message
"message_type": "text",
"replyTo": "",
"mentionedUsersIds": ""
}
},
{
"createdAt": "2023-09-07 06:35:23",
"chatType": "chat",
"favouriteBy": "",
"favouriteStatus": 0,
deleteStatus: "", // Number - Delete Status
fromUserId: "", // String - From User Id
"fromUserJid": "",// String - fromUserJid
"publisherJid": "",// String - publisherJid
"publisherId": "",// String - mobile Number publisherJid
"timestamp": "",// number- timestamp
"msgId": "",// String - msgId
"msgStatus": 1,// Number - msgStatus
"msgBody": {
"nickName": "",//String - UserName
"media": {
"androidHeight": "",//Number - androidHeight
"androidWidth": "",//Number - androidWidth
"caption": "",
"duration": 0,
"fileName": "",//string fileName
"file_key": "",
"file_url": "",//string - File format file_url
"file_size": 139791,
"is_downloaded": 0,
"is_uploading": 2,
"local_path": "",//string - File format local_path
"msgId": "",//string - msgId
"originalHeight": 0,
"originalWidth": 0,
"thumb_image": "",
"webWidth": "",//Number - webWidth
"webHeight": "",//Number - webHeight
"fileType": "image/jpeg" //string -File format
},
"mid": "98b05f38-5f42-42fc-9313-be84793b3312",//string -mid
"message": "",//string - media message
"message_type": "image",
"replyTo": "",
"mentionedUsersIds": ""
}
}
]
}

Text Message#

await SDK.sendTextMessage(`TO_USER_JID`, `MESSAGE_BODY`, `MESSAGE_ID`);

Request Param#

StatusDescriptionTypeRequired
TO_USER_JIDJID of the To User. username + "@" + xmppSocketHostJID Stringtrue
MESSAGE_BODYText Message BodyStringtrue
MESSAGE_IDText Message IdStringtrue

Response Format:#

{
"message": "",// String - Success/Error Message
"statusCode": "" // Number - status code
}

Image Message#

caution

If Image attachment feature is unavailable for your plan, then it will throw 403 exception

await SDK.sendImageMessage(`TO_USER_JID`, `IMAGE_FILE`, `FILE_OPTIONS`, `REPLY_TO`, `MENTIONED_USERS_IDS`);

Request Param toJid,#

StatusDescriptionTypeRequired
TO_USER_JIDJID of the To User. username + "@" + xmppSocketHostJID Stringtrue
IMAGE_FILEImage File - Should be of type png, jpg, jpeg, svg & gifFiletrue
FILE_OPTIONSImage File ObjectObjecttrue
REPLY_TOSpecifies the Message ID of replied message (Optional)Stringtrue
MENTIONED_USERS_IDSArray of Group Mentioned UsersIdsArray of Stringsfalse
#### Response Format:
```js
statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
"fileToken": "",// String - File Url
"thumbImage": ""// Base64 - Thumb Image
},

Audio Message#

caution

If Audio attachment feature is unavailable for your plan, then it will throw 403 exception

await SDK.sendAudioMessage(`TO_USER_JID`, `AUDIO_FILE`, `FILE_OPTIONS`, `REPLY_TO`, `MENTIONED_USERS_IDS`);

Media Message

ParamDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue
FILE_OPTIONSFile Message ParamsObjecttrue
AUDIO_FILEAudio File - Should be of type mp3, mpeg & wavFiletrue
REPLY_TOMessage ID of Original MessageStringfalse
MENTIONED_USERS_IDSArray of Group Mentioned UsersIdsArray of Stringsfalse

Response Format:#

{
"fileToken": "",//string fileToken Audio Format
statusCode: "", // Number - status code
message: "", // String - Success/Error Message
}

Video Message#

caution

If Video attachment feature is unavailable for your plan, then it will throw 403 exception

await SDK.sendVideoMessage(`TO_USER_JID`, `VIDEO_FILE`, `FILE_OPTIONS`, `REPLY_TO`, `MENTIONED_USERS_IDS`);
ParamDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue
VIDEO_FILEFile Message ParamsObjecttrue
VIDEO_FILEVideo File - Should be of type mp4Filetrue
REPLY_TOMessage ID of Original MessageStringfalse

Response Format:#

{
"fileToken": "",//string fileToken Video Format
statusCode: "", // Number - status code
message: "", // String - Success/Error Message
}

Document Message#

caution

If Document attachment feature is unavailable for your plan, then it will throw 403 exception

await SDK.sendDocumentMessage(`TO_USER_JID`, `DOCUMENT_FILE`, `FILE_OPTIONS`, `REPLY_TO`, `MENTIONED_USERS_IDS`);
ParamDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue
FILE_OPTIONSFile Message ParamsObjecttrue
DOCUMENT_FILE - Accepted files are pdf, doc, xls, csv, ppt & txtFiletrue
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArray of Stringsfalse

Response Format:#

{
"fileToken": "",//string fileToken Document Format
statusCode: "", // Number - status code
message: "", // String - Success/Error Message
}

Download Media#

This method is used to get the media file url when we download the media.

await SDK.getMediaURL(`fileToken`);

Request Param#

StatusDescriptionTypeRequired
fileTokenFile UrlStringtrue

Example Requests#

await SDK.getMediaURL("9178680804311682318992048B1cCBm6F6WIVI38s9r1a.mp4");

Response Format#

{
"data": {
"fileUrl": "",// String - image Url
"token": "" // // String - image Token
},
"message": "",// String - Success/Error Message
"statusCode": "" // Number - status code,
}

Send Reply Message#

await SDK.sendTextMessage(`TO_USER_JID`, `MESSAGE_BODY`, `MESSAGE_ID`,`REPLY_TO`);

Request Param#

StatusDescriptionTypeRequired
TO_USER_JIDJID of the To User. username + "@" + xmppSocketHostJID Stringtrue
MESSAGE_BODYText Message BodyStringtrue
MESSAGE_IDText Message IdStringtrue
REPLY_TOMessage ID of Original MessageStringtrue