Send a 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.

Note: When you call the methods listed below, the messageListener callback will trigger based on the method you are calling.

Text 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_TOSpecifies the Message ID of replied message (Optional)Stringfalse

Response Format:#

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

Location Message#

await SDK.sendLocationMessage(`TO_USER_JID`, `LATITUDE`, `LONGITUDE`,`MESSAGE_ID`, `REPLY_TO` );

Request Param#

StatusDescriptionTypeRequired
TO_USER_JIDJID of the To User. username + "@" + xmppSocketHostJID Stringtrue
LATITUDElocation latitude which needs to be sentNumbertrue
LONGITUDElocation longitude which needs to be sentNumbertrue
MESSAGE_IDLocation Message IdStringfalse
REPLY_TOSpecifies the Message ID of replied message (Optional)Stringfalse

Response Format:#

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

Contact Message#

const contacts = [
{
name: 'John Doe',// String duration
phone_number: ['9988776655', '9900884455'] // Array of String
active_status: [ 0, 1] // Array of Number (0 or 1)
msgId: '' // String (Optional)
}
];
await SDK.sendContactMessage(`TO_USER_JID`, `CONTACTS`, `REPLY_TO` );

Request Param#

StatusDescriptionTypeRequired
TO_USER_JIDJID of the To User. username + "@" + xmppSocketHostJID Stringtrue
CONTACTSlist of numbers in that contactArray of Objecttrue
REPLY_TOSpecifies the Message ID of replied message (Optional)Stringfalse

Response Format:#

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

Image Message#

const fileDetails = {
"extension": "jpg", //Image Format
"type": "image/jpg", //Image Type
"modificationTimestamp": 1734340598777, // number modificationTimestamp
"uri": "file:///Users/user/Library/Developer/CoreSimulator/Devices/9FA93417-BF50-47F6-A8E8-8ED3BA28B0CC/data/Media/DCIM/100APPLE/IMG_0012.JPG",//Image Uri
"fileSize": 2268348,//number File Size
"width": 5088, //number Width
"height": 3253, //number Height
"filename": "IMG_0012.JPG",//Image FileName
"duration": 0 // number duration
}
const fileOptions = {
"msgId": "3cdb5781-43b8-e1a3-89e9-a9214e0c2474", // message Id (unique id for each message)
"caption": "",//Image caption
"duration": 0,//Image duration
"webWidth": 330,//Image webHeight
"webHeight": 211,//Image webWidth
"androidWidth": 250, //number androidWidth
"androidHeight": 160, //number androidHeight
"originalWidth": 5088, // Image originalHeight
"originalHeight": 3253,
"thumbImage": "" // base64 string
}
await SDK.sendImageMessage(`TO_USER_JID`, `FILE_DETAILS`, `FILE_OPTIONS`, `REPLY_TO`);

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 & gifObjecttrue
FILE_OPTIONSImage File ObjectObjecttrue
REPLY_TOSpecifies the Message ID of replied message (Optional)Stringtrue

Response Format:#

statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
"fileToken": "",// String - File Url
"thumbImage": ""// Base64 - Thumb Image
},

Audio Message#

const AudioFile = {
fileDetails: {
duration: '', //number duration
extension: "mp3", //string extension
fileSize: '',// number fileSize
filename: '',// string filename
height: '',//number height
modificationTimestamp: '', // number modificationTimestamp
replyTo: "",
type: "",// string audio Type
uri: '',// string uri
width: '' // number width
}
};
const fileOptions = {
androidHeight: '', // number androidHeight
androidWidth:'', // number androidWidth
audioType: '', // string audioType
caption: '', // string caption
duration: '',// number duration
msgId: '',// string msgId
originalHeight: '',// number originalHeight
originalWidth: '',// number originalWidth
webHeight: '',// number webHeight
webWidth: ''// number webWidth
};
await SDK.sendAudioMessage(`TO_USER_JID`, `AUDIO_FILE`, `FILE_OPTIONS`, `REPLY_TO`);

Media Message

ParamDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue
FILE_OPTIONSFile Message ParamsObjecttrue
AUDIO_FILEAudio File - Should be of type mp3, mpeg & wavobjecttrue
REPLY_TOMessage ID of Original MessageStringfalse

Response Format:#

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

Video Message#

const VideoFile ={
"extension": "mov", //video Format
"type": "video/quickTime", //video Type
"modificationTimestamp": 1734340598777, // number modificationTimestamp
"uri": "file:///Users/user/Library/Developer/CoreSimulator/Devices/9FA93417-BF50-47F6-A8E8-8ED3BA28B0CC/data/Media/DCIM/100APPLE/MOV_0012.mov",//video Uri
"fileSize": 2268348,//number File Size
"width": 5088, //number Width
"height": 3253, //number Height
"filename": "MOV_0012.JPG",//video FileName
"duration": 0 // number duration
}
const fileOptions = {
"msgId": "3cdb5781-43b8-e1a3-89e9-a9214e0c2674", // message Id (unique id for each message)
"caption": "",//Video caption
"duration": 0,//Video duration
"webWidth": 330,//Video webHeight
"webHeight": 211,//Video webWidth
"androidWidth": 250, //number androidWidth
"androidHeight": 160, //number androidHeight
"originalWidth": 5088, // Video originalHeight
"originalHeight": 3253,
"thumbImage": "" // base64 string
}
await SDK.sendVideoMessage(`TO_USER_JID`, `VIDEO_FILE`, `FILE_OPTIONS`, `REPLY_TO`);
ParamDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue
FILE_OPTIONSFile Message ParamsObjecttrue
VIDEO_FILEVideo File - Should be of type mp4objecttrue
REPLY_TOMessage ID of Original MessageStringfalse

Response Format:#

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

Document Message#

const FileOptions = {
androidHeight: '',// number
androidWidth: '',// number
caption: "",//string caption
duration: '',// number
msgId: "",// string msgId
originalHeight: '',// number
originalWidth: '',// number
webHeight: '',// number
webWidth: ''// number
}
const DocumentFile = {
duration: '',// number duration
extension: '',// string extension
fileSize: '',// number fileSize
filename: '',// string filename
height: '',// number height
modificationTimestamp: '',//number modificationTimestamp
replyTo: "",// string replyTo
type: '',// string type
uri: '',// string uri
width: ''// number width
}
await SDK.sendDocumentMessage(`TO_USER_JID`, `DOCUMENT_FILE`, `FILE_OPTIONS`, `REPLY_TO`);
ParamDescriptionTypeRequired
TO_USER_JIDJID of the To UserJID Stringtrue
FILE_OPTIONSFile Message ParamsObjecttrue
DOCUMENT_FILEDOCUMENT_FILE - Accepted files are pdf, doc, xls, csv, ppt & txtObjecttrue
REPLY_TOMessage ID of Original MessageStringfalse

Response Format:#

data:
{
"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