Message By MetaData

To send custom data along with a message, you can use “metadata” param provided to all kinds of messages such as Text, Image, audio, video & document.

Text Message#

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

To learn more on request and response about ' Text Message ' see the Text Message Section

Image Message#

await SDK.sendMediaFileMessage({
toJid: "",
messageType: "image",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: "",
},
replyMessageId: "",
mentionedUsersIds: [], //Optional
metaData: {} //Optional
},
onPending((msgId) => {
// ...
}),
.onSuccess((response) => {
// ...
}),
.onError((error) => {
// ...
})
);

To learn more on request and response about ' Image Message ' see the Image Message Section

Audio Message#

await SDK.sendMediaFileMessage({
toJid: "",
messageType: "audio",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: "",
},
replyMessageId: "",
mentionedUsersIds: [], //Optional
metaData: {} //Optional
},
onPending((msgId) => {
// ...
}),
.onSuccess((response) => {
// ...
}),
.onError((error) => {
// ...
})
);

To learn more on request and response about ' Audio Message ' see the Audio Message Section

Video Message#

await SDK.sendMediaFileMessage({
toJid: "",
messageType: "video",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: ""
},
replyMessageId: "",
mentionedUsersIds: [], //Optional
metaData: {} //Optional
},
onPending((msgId) => {
// ...
}),
.onSuccess((response) => {
// ...
}),
.onError((error) => {
// ...
})
);

To learn more on request and response about ' Video Message ' see the Video Message Section

Document Message#

await SDK.sendMediaFileMessage({
toJid: "",
messageType: "file",
fileMessageParams: {
file: FILE, // Or .fileUrl = FILE_URL (You can also send a file message with a file URL.)
caption: ""
},
replyMessageId: "",
mentionedUsersIds: [], //Optional
metaData: {} //Optional
},
onPending((msgId) => {
// ...
}),
.onSuccess((response) => {
// ...
}),
.onError((error) => {
// ...
})
);

To learn more on request and response about ' Document Message ' see the Document Message Section

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
},

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: [], // Optional
metaData: {} // Optional
});

Receive a Message#

To receive a metaData related message from another user you must implement the messageListener function. It’s a function that will be triggered whenever you receive a new message or related event in the chat.

function messageListener(response) {
console.log("Message Listener", response);
}
note

To learn more on 'message listener callbacks,' see the Message Callback Event Listener Section