How to access user uploaded files in Copilot Studio?

Frank 70 Reputation points
2025-01-12T10:19:26.7933333+00:00

In Microsoft Copilot Studio, how can I extract and store the text content of a Word or PDF file uploaded by an end user via the chat UI (using the attachment icon) into a variable for further processing?

For example, I want to:

  1. Extract the file's text and store it in a variable.
  2. Use this text in a workflow to send it to a private GPT instance with a custom prompt to generate a structured summary.

This question is not related to the "Add Content" feature for knowledge file uploads but focuses on handling files uploaded during live chat interactions.

Any guidance or documentation would be greatly appreciated!

Microsoft Copilot
Microsoft Copilot
Microsoft terminology for a universal copilot interface.
621 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Johannes Indbjo 10 Reputation points
    2025-02-25T14:36:24.8666667+00:00

    Hi! I might have a solution, that worked for me.

    The variable System.Activity.ChannelData is what solved it for me. It contains an object called OriginalAttachment that either stores the Base64-file content or an URL to download (if the file is stored in Onedrive).

    Steps to capture channelData

    1. Use a trigger to start the topic, for example that the Activity.Attachments table is not empty.
    2. Set a variable (e.g. attachment_data) to JSON(System.Activity.ChannelData). This variable will become a string. This should happen before any other messages are sent.
    3. Pass the variable to Power Automate.
    4. Parse the variable to a JSON schema with "Analyze Json".
    5. Work with the file content as desired. For example, you can convert the base64-encoded data from contentUrl to binary with base64toBinary in a "Compose". Some connectors need a base64-encoded string anyway. For example, extracting text from a document with AIBuilder to send it to a GPT uses base64-encoded string for the document.

    Otherwise, uploading the file with a Onedrive Connector and First(System.Activity.Attachments).Value and downloading it from Power Automate with the file ID is possible. If you need the filename, it should be in the channelData

    Hope this helps!

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.