Tutorials/Copilot Studio/Streamline Document Analysis with Copilot Studio File Uploads
Copilot Studiointermediate

Streamline Document Analysis with Copilot Studio File Uploads

Learn how to build a Copilot Studio agent that accepts file uploads directly in a chat window, validates the file type, and uses AI prompts to extract structured information from documents.

NA
Narmer Abader
@narmer · Published June 3, 2026

Copilot Studio enables you to create agents that can accept file uploads directly through the chat conversation. This capability is especially powerful for document‑centric tasks because the uploaded file can be passed to an AI prompt for analysis. In this guide you will build a Contract Insight agent for a legal department. The agent will ask a user to upload a PDF contract, verify that exactly one PDF file is attached, and then extract key clauses (effective date, parties, termination conditions) using a generative prompt.

The same pattern works for expense reports, employee handbooks, medical forms, or request‑for‑proposal documents with only minor modifications.

Build a Document Analysis Agent

Start by creating a new agent in Copilot Studio.

  1. Open Copilot Studio and choose Create.
  2. Name the agent Contract Insight.
  3. Provide this description: This agent receives a contract PDF from the user and extracts important clauses such as effective date, parties, and termination conditions.
  4. Go to the Topics tab and create a new Topic from blank named Upload Contract.
  5. Set the trigger phrase to something like analyze contract, review contract, or upload contract.

Create the Upload Topic

Within the Upload Contract topic, you need to ask the user to attach a file. The simplest method is to use a Question node that expects a File entity.

  • Add a Question node to the topic.
  • In the Identify field, choose File from the entity picker.
  • Write the message the user will see, for example: Please upload the contract PDF you’d like me to review.

When the user responds by attaching a file in Teams (or in the test pane), Copilot Studio automatically stores the file information in the System.Activity.Attachments table.

Validate the Upload

A reliable agent should confirm that the uploaded file is a PDF and that only one file was attached. Create two variables and then branch the conversation accordingly.

Add a Set variable value node and create a new variable named IsPdfFile. Use this formula:

powerfxCheck file extension
EndsWith(
  Lower(First(System.Activity.Attachments).Name),
  ".pdf"
)

Add another Set variable value node for IsSingleFile:

powerfxCheck number of files
CountRows(System.Activity.Attachments) = 1

Now add a Condition node that checks these variables. Build three branches:

  • Branch 1: IsPdfFile = false Show a Message: The file must be a PDF. Please upload a PDF file. Then use a Go to step node to return to the Question so the user can retry.

  • Branch 2: IsSingleFile = false Show a Message: Only one file can be uploaded at a time. Please try again with a single PDF. Use a Go to step node back to the Question.

  • Branch 3: All other conditions (meaning a single PDF is present) Show a confirmation Message: PDF received. I’m now analyzing the contract… Continue to the AI prompt step.

Case sensitivity

The uploaded file’s name may be in uppercase or mixed case. Always convert to lower case before checking the extension – the example above already does this with Lower().

Extract Information with an AI Prompt

You now have a validated file that can be passed to a generative prompt for analysis.

  1. In the topic, click Add a new action and choose Create a prompt.
  2. Name the prompt Extract Contract Clauses.
  3. Add an input of type Document and name it ContractDocument.
  4. Write the prompt instructions:
powerfxPrompt instructions
Your goal is to read the uploaded contract PDF and extract the following details:
- Effective date
- Names of the parties involved
- Termination notice period
- Any renewal terms

Output them as a bulleted list. Do not include any extra text.
  1. Map the file to the prompt input: in the prompt’s input section, select From conversation and choose System.Activity.Attachments (Copilot Studio handles the document conversion automatically for document‑type inputs).

Test the prompt with a sample contract to verify that the output is a clean, bulleted list.

Prompt quality

The quality of extraction depends on the model and the phrasing you use. Test with several sample files and refine the instructions until the output is consistent and accurate.

Display the Results

The prompt’s output is stored in a variable (by default named after the prompt, e.g., ExtractContractClauses.output). Add a final Message node that references this variable so the user sees the extracted clauses.

After publishing the agent, test it in the Copilot Studio test pane, in Microsoft Teams, or in any configured channel.

Security and Performance Considerations

  • File size limits: The default maximum file size for Copilot Studio attachments is 50 MB when testing in the portal and in Teams. Adjust your logic if you expect larger files.
  • Sensitive content: The file is processed by the underlying AI model. For highly confidential documents, consider using your own data source or an on‑premises gateway.
  • Channel differences: The System.Activity.Attachments table behaves similarly in Teams, Microsoft 365 Copilot, and the test pane, but the exact file upload experience may vary. Always test on your target channel.
  • Validation vs. user experience: Keep validation messages friendly and allow the user to correct the mistake without losing the conversation context.

Common Mistakes and Troubleshooting

MistakeSymptomFix
File extension check failsAgent always shows “invalid file”Use EndsWith with a dot (.pdf) and lower case the name.
Attachment table is emptyFirst(System.Activity.Attachments) returns an errorEnsure the Question node uses the File entity. The attachment is captured only after the user answers the question.
Multiple files not handledPrompt fails or returns mixed resultsAlways validate CountRows before continuing.
Prompt output is emptyNo extraction appearsDouble‑check that the prompt input is mapped to the correct document variable and that the PDF is not corrupt.

Recommendation

This file‑upload approach is the most straightforward way to bring document analysis into your Copilot Studio agents. It uses no custom connectors or Power Automate flows, and the built‑in File entity handles the heavy lifting of receiving the attachment. For more advanced validation (e.g., checking file size or scanning for password protection), you can call a Power Automate cloud flow inside the topic.

Start with a simple scenario like contract clause extraction, then expand to other document types. The pattern remains the same: ask, validate, prompt, respond.

References