Hi @tim.smith, let me know if any additional details are required from my end. Not sure how to send an image with sendMessage command after it gets uploaded. I don't find the example in documentation.
I do not see any specific data structure for sending attachments (with or without a message).
Looks like a defect here.
I would advise you to open a ticket with Care.
Event subscriptions should happen before the requestUpload command but not in the success callback of that command, otherwise subscriptions will not be executed.
After the MessagingService.requestUpload command is successful, you can simply call MessagingService.sendMessage command without any message property (its optional) and the image would be automatically sent. You will do this subscribing to MessagingService.fileUploaded event.
Here is a working example script that will subscribe to the fileUploaded event and send the image.
// subscribe to the event first and send the file.
Genesys("subscribe", "MessagingService.fileUploaded", function() {
console.log("sending file as message....");
Genesys("command", "MessagingService.sendMessage");
});
// Make upload request. Here I'm fetching a random image from url and trying to upload it using MessagingService.requestUpload command.
const url = "https://picsum.photos/200/300";
let fileN = "";
fetch(url).then(async (response) => {
const contentType = response.headers.get("content-type");
const blob = await response.blob();
fileN = new File([blob], "Name", {type: contentType});
var dt = new DataTransfer();
dt.items.add(fileN);
var file_list = dt.files;
Genesys("command", "MessagingService.requestUpload", {
file: file_list
});
});