that downloads a file from another system via API and then attaches this file to the currently open editor. Is this possible?
According to the official documentation it should be possible:
but there is zero documentation on how to actually do this.
Can anyone help me with this?
Hi Christopher,
You can use Server Method Invocation (SMI) to fetch the file from the external system’s API and then upload it using the appropriate Freshdesk API.
Here’s how you can approach this:
Fetch the file: Use SMI to invoke a serverless function that downloads the file from the external system’s API.
Attach the file to the ticket: Use the Freshdesk API to add the file as an attachment where supported. This makes it available on the ticket but does not necessarily include it in a reply.
Attach the file to the reply: If the goal is to send the file as part of the current reply, it must be included in the reply’s attachment list when submitting the reply. Uploading it separately to the ticket does not automatically attach it to the open conversation editor.
Populate the editor: Use the ticket_conversation_editor placeholder and the setValue interface method to populate the editor with the required text.
The key distinction is that a ticket attachment is stored on the ticket, whereas a reply attachment is sent with the specific outgoing reply. If you need the file to be sent to the customer, it must be attached to the reply itself.
Do you have an example on how to attach a file to a reply? I haven’t found any documentation on what attribute to use, all that is in the official documentation is this bit describing on how to set a text, but not attachment:
client.interface.trigger("setValue", {
id: "editor",
text: "<Text to be inserted>",
replace: false, position: "end"
}).then(function(data) {
// data - success message
}).catch(function(error) {
// error - error object
});