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.

Text Message#

await SDK.sendTextMessage({
toJid: "",
messageText: "",
mentionedUsersIds: [],
topicId: "",
metaData: {}
});
ParamDescriptionTypeRequired
toJidJID of the To UserJID Stringtrue
messageTextText Message BodyStringtrue
mentionedUsersIdsArray of Group Mentioned UsersIdsArray of Stringsfalse
topicIdTopic Id for the MessageStringfalse
metaDataMetaData for the MessageObjectfalse

Response Format:#

statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
metaData: {}, //Object - Meta data for the message
msgBody: {
message: "", // String - Message Body
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
topicId: "", //String - Topic id for the message
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Image Message#

caution

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

await SDK.sendFileMessage({
toJid: "",
messageType: "image",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: "",
},
replyMessageId: "",
mentionedUsersIds: [],
topicId: "",
metaData: {}
});
ParamDescriptionTypeRequired
toJidJID of the To UserJID Stringtrue
fileMessageParamsFile Message ParamsObjecttrue
fileMessageParams.fileImage File - Should be of type png, jpg, jpeg, svg & gifFiletrue
fileMessageParams.thumbImageImage File Thumb Image. When the value not given, SDK will generate thumb image for the given FILE. When using the fileUrl SDK won't generate the thumb image.Stringfalse
fileMessageParams.fileSizeImage File Size. When the value not given, SDK will detect the size of the given FILE. When using the fileUrl SDK won't detect the size.Stringfalse
fileMessageParams.fileNameImage File Name. When the value not given, SDK will detect the name of the given FILE. When using the fileUrl SDK won't detect the name.Stringfalse
fileMessageParams.captionImage CaptionStringfalse
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArray of Stringsfalse
topicIdTopic Id for the MessageStringfalse
metaDataMetaData for the MessageObjectfalse

Response Format:#

statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
metaData: {}, //Object - Meta data for the message
msgBody: {
media: { // For Media Message Only
caption: "", // String - Media Caption
duration: "", // String - Duration - For Audio/Videos
fileName: "", // String - File Name
file_size: "", // Number - File Size
fileToken: "", // String - File Url
is_downloaded: "", // Number - Downloaded Status
is_uploading: "", // Number - Uploading Status
local_path: "", // String - Local Path
thumb_image: "", // Base64 - Thumb Image
}
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
topicId: "", //String - Topic id for the message
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Audio Message#

caution

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

await SDK.sendFileMessage({
toJid: "",
messageType: "audio",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: "",
},
replyMessageId: "",
mentionedUsersIds: [],
topicId: "",
metaData: {}
});
ParamDescriptionTypeRequired
toJidJID of the To UserJID Stringtrue
fileMessageParamsFile Message ParamsObjecttrue
fileMessageParams.fileAudio File - Should be of type mp3, mpeg & wavFiletrue
fileMessageParams.fileSizeAudio File Size. When the value not given, SDK will detect the size of the given FILE. When using the fileUrl SDK won't detect the size.Stringfalse
fileMessageParams.fileNameAudio File Name. When the value not given, SDK will detect the name of the given FILE. When using the fileUrl SDK won't detect the name.Stringfalse
fileMessageParams.durationAudio File Duration. When the value not given, SDK will detect the duration of the given FILE. When using the fileUrl SDK won't detect the duration.Stringfalse
fileMessageParams.captionAudio CaptionStringfalse
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArray of Stringsfalse
topicIdTopic Id for the MessageStringfalse
metaDataMetaData for the MessageObjectfalse

Response Format:#

statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
metaData: {}, //Object - Meta data for the message
msgBody: {
media: { // For Media Message Only
caption: "", // String - Media Caption
duration: "", // String - Duration - For Audio/Videos
fileName: "", // String - File Name
file_size: "", // Number - File Size
fileToken: "", // String - File Url
is_downloaded: "", // Number - Downloaded Status
is_uploading: "", // Number - Uploading Status
local_path: "", // String - Local Path
thumb_image: "", // Base64 - Thumb Image
}
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
topicId: "", //String - Topic id for the message
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Video Message#

caution

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

await SDK.sendFileMessage({
toJid: "",
messageType: "video",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: ""
},
replyMessageId: "",
mentionedUsersIds: [],
topicId: "",
metaData: {}
});
ParamDescriptionTypeRequired
toJidJID of the To UserJID Stringtrue
fileMessageParamsFile Message ParamsObjecttrue
fileMessageParams.fileVideo File - Should be of type mp4Filetrue
fileMessageParams.fileSizeVideo File Size. When the value not given, SDK will detect the size of the given FILE. When using the fileUrl SDK won't detect the size.Stringfalse
fileMessageParams.fileNameVideo File Name. When the value not given, SDK will detect the name of the given FILE. When using the fileUrl SDK won't detect the name.Stringfalse
fileMessageParams.durationVideo File Duration. When the value not given, SDK will detect the duration of the given FILE. When using the fileUrl SDK won't detect the duration.Stringfalse
fileMessageParams.thumbImageVideo File Thumb Image. When the value not given, SDK will generate thumb image for the given FILE. When using the fileUrl SDK won't generate the thumb image.Stringfalse
fileMessageParams.captionVideo CaptionStringfalse
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArray of Stringsfalse
topicIdTopic Id for the MessageStringfalse
metaDataMetaData for the MessageObjectfalse

Response Format:#

statusCode: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
metaData: {}, //Object - Meta data for the message
msgBody: {
media: { // For Media Message Only
caption: "", // String - Media Caption
duration: "", // String - Duration - For Audio/Videos
fileName: "", // String - File Name
file_size: "", // Number - File Size
fileToken: "", // String - File Url
is_downloaded: "", // Number - Downloaded Status
is_uploading: "", // Number - Uploading Status
local_path: "", // String - Local Path
thumb_image: "", // Base64 - Thumb Image
}
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
topicId: "", //String - Topic id for the message
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Document Message#

caution

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

await SDK.sendFileMessage({
toJid: GroupJID,
messageType: "file",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: ""
},
replyMessageId: "",
mentionedUsersIds: [],
topicId: "",
metaData: {}
});
ParamDescriptionTypeRequired
toJidJID of the To UserJID Stringtrue
fileMessageParamsFile Message ParamsObjecttrue
fileMessageParams.fileDocument File - Accepted files are pdf, doc, xls, csv, ppt & txtFiletrue
fileMessageParams.fileSizeDocument File Size. When the value not given, SDK will detect the size of the given FILE. When using the fileUrl SDK won't detect the size.Stringfalse
fileMessageParams.fileNameDocument File Name. When the value not given, SDK will detect the name of the given FILE. When using the fileUrl SDK won't detect the name.Stringfalse
fileMessageParams.captionDocument CaptionStringfalse
replyMessageIdMessage ID of Original MessageStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArray of Stringsfalse
topicIdTopic Id for the MessageStringfalse
metaDataMetaData for the MessageObjectfalse

Response Format:#

status code: "", // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
metaData: {}, //Object - Meta data for the message
msgBody: {
media: { // For Media Message Only
caption: "", // String - Media Caption
duration: "", // String - Duration - For Audio/Videos
fileName: "", // String - File Name
file_size: "", // Number - File Size
fileToken: "", // String - File Url
is_downloaded: "", // Number - Downloaded Status
is_uploading: "", // Number - Uploading Status
local_path: "", // String - Local Path
thumb_image: "", // Base64 - Thumb Image
}
message_type: "", // String - Message Type
nickname: "", // String - nick name
mentionedUsersIds: [] // Array of mentioned users
},
msgId: "", // String - Unique Message Id
topicId: "", //String - Topic id for the message
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Meet Message#

Before you send the meet message, you need to create the meet link using the createMeetLink method. Once the meet link has been created successfully, you can send the Meet message.

caution

If Group call feature is unavailable for your plan, then it will throw 403 exception

SDK.createMeetLink();

Response Format#

{
statusCode: `STATUS_CODE`,
message: `ERROR|SUCCESS message`,
data: "ehl-niyc-wcc"
}

You can send the meet message by using the sendMeetMessage method. You can share the title, link and schdueled date and time using this method.

caution

If Group call feature is unavailable for your plan, then it will throw 403 exception

await SDK.sendMeetMessage({
toJid: "",
link: "",
scheduledDateTime: 0,
title: "",
mentionedUsersIds: [],
topicId: "",
metaData: {}
});
ParamDescriptionTypeRequired
toJidJID of the To User/GROUPJID Stringtrue
linkMeet Link which we need to shareStringtrue
scheduledDateTimeScheduled Date and TimeNumber (Timestamp)true
titleMeet Title which we need to shareStringfalse
mentionedUsersIdsArray of Group Mentioned UsersIdsArray of Stringfalse
topicIdTopic Id for the MessageStringfalse
metaDataMetaData for the MessageStringfalse

Response Format:#

statusCode: 200, // Number - status code
message: "", // String - Success/Error Message
data:
{
chatType: "", // String - Chat Type - "chat"
createdAt: "", // String - Message Created Time
deleteStatus: "", // Number - Delete Status
favouriteBy: "", // String - Favourited By - User
favouriteStatus: "", //Number - Favourite status
fromUserJid: "", // String - From User Jid
metaData: {}, //Object - Meta data for the message
msgBody: {
    message_type: "meet", // String - Message Type
      nickName: "", // String - nick name
      mentionedUsersIds: [], // Array of mentioned users
      meet: {
      title: "", // String - Title
        scheduledDateTime: 1695202750020, // Number - Timestamp - Milliseconds
        link: "ehl-niyc-wcc" // String - Link
      }
    }
topicId: "", //String - Topic id for the message
msgId: "", // String - Unique Message Id
msgType: "", // String - Group Message Type
publisherId: "", // String - user Id
timestamp: 1681185232000, // Number - TimeStamp - Milliseconds
},

Download Media#

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

await SDK.getMediaURL(`fileToken`, `filekey`);

Request Param#

StatusDescriptionTypeRequired
fileTokenFile UrlStringtrue
filekeyFile key is optional param, which we get from the selected Media message BodyStringfalse

Example Requests#

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

Response Format#

{
"statusCode": "" // Number - status code,
"message": "", // String - Success/Error Message
"data": {
"blobUrl": "", // String - blobUrl
"blob": {
"size" : "", // Number - size
"type" : "" // String
}
}
}

Send Reply Message#

To send a reply to the original message, we are using sendTextMessage by passing in the additional parameter original message-id.

await SDK.sendTextMessage({
toJid: "",
messageText: "",
replyMessageId: "",
mentionedUsersIds: [],
topicId: "",
metaData: {}
});

Request Param#

ParamDescriptionTypeRequired
toJidJID of the To User/GroupJID Stringtrue
messageTextText Message BodyStringtrue
replyMessageIdMessage ID of Original MessageStringtrue
mentionedUsersIdsArray of Group Mentioned UsersIdsArrayfalse
topicIdTopic Id for the MessageStringfalse
metaDataMetaData for the MessageObjectfalse