Edit a Message

Edit message is a feature which allows you to edit the content of your previously sent Text Messages and Captions associated with Media in your chat conversation.

Note : User can edit only Sent Messages.

Edit Message#

To edit a sent text message, use this below method by passing the required inputs to modify the content of the message in the editTextMessage method.

await SDK.editTextMessage({
messageId: "",
editedTextContent: "",
mentionedUsersIds: []
})
ParamDescriptionTypeRequired
messageIdMessageId of the message which is editStringtrue
editedTextContentEditable Text contentStringtrue
mentionedUsersIdsArray of Group MentionedUsersIdsArray of Stringsfalse

Response Format:#

{
statusCode: 200, // Number - status code
message: "", // String - Success/Error Message
data: {
chatType: "", // String - ChatType - "chat" or "groupchat"
createdAt: "", // String - Message Created Time
deleteStatus: 0, // Number - Delete Status
editMessageId: "", // String - Unique EditMessageId
editedStatus: 1, // Number - Edited Status - 0 or 1
fromUserJid: "", // String - From User Jid
fromUserId: "", // String - From User Id
metaData: {}, //Object - Meta data for the message
msgBody: {
mentionedUsersIds: [] // Array of mentioned users
message: "", // String - Edited Message
message_type: "", // String - Message Type
nickname: "", // String - nick name
},
msgId: "", // String - Original MessageId of the message
msgtype: "text", // String - Message Type
msgStatus: 0, // Number - Messsage Status
publisherId: "", // String - user Id
timestamp: 1705310998000, // Number - TimeStamp - Milliseconds
toUserId: "", // String - To User Id
toUserJid: "", // String - To User Jid
topicId: "", //String - Topic id for the message
}
}
info

When a message is being edited, editMessageListener event will be triggered. Based on this event, update the message and refresh the UI.

Edit Media Caption#

To edit a media caption, use this below method by passing the required inputs to modify the caption of the media message in the editMediaCaption method.

await SDK.editMediaCaption({
messageId: "",
editedTextContent: "",
mentionedUsersIds: []
})
ParamDescriptionTypeRequired
messageIdMessageId of the message which is editStringtrue
editedTextContentEditable Caption TextStringtrue
mentionedUsersIdsArray of Group MentionedUsersIdsArray of Stringsfalse

Response Format:#

{
statusCode: 200, // Number - status code
message: "", // String - Success/Error Message
data: {
chatType: "", // String - ChatType - "chat" or "groupchat"
createdAt: "", // String - Message Edited Time
deleteStatus: 0, // Number - Delete Status
editMessageId: "", // String - Unique EditMessageId
editedStatus: 1, // Number - Edited Status - 0 or 1
fromUserJid: "", // String - From User Jid
fromUserId: "", // String - From User Id
metaData: {}, //Object - Meta data for the message
msgBody: {
media: {
androidHeight: 140, // Number
androidWidth: 250, // Number
caption: "", // String - Edited Media Caption
duration: 0, // Number - Duration - For Audio/Videos
fileName: "", // String - File Name
file_key: "", // String - File Key
file_size: 22184, // Number - File Size
file_url: "", // String - File Url
isLargeFile: true, // Boolean - File Type
is_downloaded: 0, // Number - Downloaded Status
is_uploading: 2, // Number - Uploading Status
local_path: "", // String - Local Path
msgId: "", // String - Original MessageId of the message
originalHeight: 139, // Number
originalWidth: 248, // Number
thumb_image: "", // Base64 - Thumb Image
webHeight: 185, // Number
webWidth: 330, // Number
},
mentionedUsersIds: [] // Array of mentioned users
message: "", // String - Message Body
message_type: "", // String - Message Type - image/video/audio/file
nickname: "", // String - nick name
},
msgId: "", // String - Original MessageId of the message
message_type: "", // String - Message Type - image/video/audio/file
msgStatus: 0, // Number - Messsage Status
publisherId: "", // String - user Id
timestamp: 1705310998000, // Number - TimeStamp - Milliseconds
toUserId: "", // String - To User Id
toUserJid: "", // String - To User Jid
topicId: "", //String - Topic id for the message
}
}
info

When a message is being edited, editMessageListener event will be triggered. Based on this event, update the message and refresh the UI.