Access conversation Files

I am developing an app to integrate with an existing system, its simple, grab the files from the conversation, post it to a server for records management
But I am having trouble accessing the files on a conversation

Currently in the app.js

document.onreadystatechange = function () {
    if (document.readyState === 'interactive') renderApp();

    function renderApp() {
        let onInit = app.initialized();



function handleErr(err = 'None') {
    console.error(`Error occured. Details:`, err);
function getClient(_client) {
    window.client = _client;
    client.instance.resize({ height: "700px" });'app.activated', getAgentDetails);"conversation").then (
        function(data) {
        function(error) {


But from the logs, no files are present in the messages array from the log

message_parts: Array(2)
content: "Another one"
__proto__: Object
__proto__: Object
1: null
length: 2
__proto__: Array(0)

Image of conversation

Any ideas on how to get the file as the requirement is for the user to not download the file, and for the custom app to post the file/files to an API ?

Hi @Devandrin_Kuni,

It looks like you are trying to do this on via a frontend app. But I would recommend the serverless app.

Can you try consuming the onMessageCreate event via the Product Events on the Serverless apps?

The documentation for the same is available here.


The user needs to select which documents they intend to upload, is it possible to use a server in a frontend app?

@Devandrin_Kuni - Not sure why Data API returns like that. Does it look like PDF attachments are not recognized? Let me try to if I can reproduce this issue.

Yes. All you need to do is create a server/server.js file and start listing the events that your app wants to listen to as listed in the documentation as @Arjun_Paliath suggested. But if your use case requires the user to select the files, serverless might not be best suited.

1 Like

@Devandrin_Kuni Are you trying to validate the attachment being uploaded or are you just trying to copy it to a different location? If it is the former, then I am afraid that may not be possible.

However, If it is the latter, you don’t need a front end component. The ideal way would be to use serverless events to capture the onMessageCreate event and get the file URL from the response. You can then download the file to your middleware or DB.

If you can also let me know your exact use case, I may be able to suggest any alternatives if it is possible via Marketplace.

Hope this helps.

1 Like

Im trying to post it to a different location

So the use case is :

User should be able to send selected attachments to the remote server, without downloading the document as downloading the documents does not make it compliant with the law in South Africa

So All I gotta do is allow the user to submit select documents with information relating to the document

By user, are you referring to agents? In any case, if an end-user(customer who initiated the chat) attaches a file, it will by default be uploaded to Freshchat’s S3 bucket and the link is what is attached to the UI.

This is the same behaviour for agents as well, and while we can set up a serverless app to retrieve the links and store them in a remote server, the links on the front end can still be accessible since Freshchat does not allow editing of messages.


@Devandrin_Kuni - I hope the comments shared on this thread were of help to you. Please feel free to let us know if you have any further questions. We’ll be happy to help.

This topic will automatically be closed in under a week. We welcome you to create new topic

This topic was automatically closed after 4 days. New replies are no longer allowed.