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 = {
duration: '',// number duration
extension: '',//Image Format
fileSize: '',//number File Size
filename: '',//Image FileName
height: '',//number Height
modificationTimestamp: '',// number modificationTimestamp
replyTo: '',//Optioinal
type: ''//Image Type
uri: '',//Image Uri
width: '' //number Width
};
const fileOptions = {
"androidHeight": '', //number androidHeight
"androidWidth": '', //number androidWidth
"caption": "", //Image caption
"duration": '', //Image duration
"msgId": '',//msgId
"originalHeight": '', //Image originalHeight
"originalWidth": '',// Image originalHeight
"thumbImage": '',//Image thumbImage
"webHeight" :'', //Image webHeight
"webWidth":''//Image webWidth
};
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 ={
duration: '',//number duration
extension: "",// string extension
fileSize: '',// string fileSize
filename: '',// string filename
height: '',// number height
modificationTimestamp: '',// string modificationTimestamp
replyTo: '',// string replyTo
type: '',// string type
uri: '', //string uri
width: '' // number width
}
const fileOptions = {
androidHeight: '', //number androidHeight
androidWidth: '', //number androidWidth
"caption": "", //video caption
"duration": '', //video duration
"msgId": '',//msgId
"originalHeight": '', //video originalHeight
"originalWidth": '',// video originalHeight
"thumbImage": '',//video thumbImage
"webHeight" :'', //video webHeight
"webWidth":''//video webWidth
};
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