[2025 Update] Save Files from Copilot Studio to SharePoint (Standard Feature Guide)

2025 Update: Copilot Studio can now handle files using standard capabilities!
Previously, this required a complex workaround using Power Automate, but today it can be completed with a single configuration.
This article explains the latest “standard implementation method.”

*The legacy method (using ChannelData and Power Automate flow) is archived at the end of this article.

This is a quick note on how to retrieve the content of files attached to a conversation.

スポンサーリンク

Goal

I want to build an agent that saves a file to a SharePoint Online (SPO) document library when I attach a file in the conversation and ask it to “save file.”
Copilot Studio conversation showing a file attachment request being saved to SPO

Build

First, create a new topic and set the trigger to activate when “asked to save a file.”
Topic trigger configuration
Next, select [Add a tool] > [Connector], and choose SharePoint [Create file].
Selecting SharePoint Create file action
Click [Submit].

*As you can see, the popup might not disappear and could block the view, so you may need to maneuver around it to click the button.
Submitting the connector selection
In the input fields for the added tool, set the “Site Address” and “Folder Path” to your destination.
Then, enter the following formula for [File Name]:
Setting File Name input using Power Fx
First(System.Activity.Attachments).Name
Enter the following formula for [File Content]:
Setting File Content input using Power Fx
First(System.Activity.Attachments).Content

The build is now complete.

Note:
This example assumes “always exactly one file is attached.” If there is a possibility of zero attachments (user error), use an If condition. If multiple files might be attached, use a loop.

Test

When you ask the agent to save an attached file:
Testing the agent with a file attachment
It will ask for connection approval. Click [Allow].
The flow might error out the first time—don’t worry about it. Just restart the conversation via [Start a new test session].
Connection approval prompt
Make the same request again. This time the flow succeeds:
Successful file save confirmation
And the file is saved in the document library.
File appearing in SharePoint document library

This is significantly easier compared to the “legacy method” described below.

Since this was just a test, the manual connection approval was fine. However, in actual operation, you may need to implement measures such as configuring SSO correctly or adding a topic at the beginning of the conversation to request authentication proactively to prevent errors.

Related Articles


[How to create a Multimodal Agent]


[Copilot Studio FX Guide]


[Power Automate Actions in Copilot Studio]


Bonus: [Legacy Method Archive] ChannelData & Power Automate

Goal

This section discusses how to retrieve a file attached in a Copilot conversation and use it in subsequent nodes or Power Automate (Legacy approach).
Legacy goal visualization

Attachments are available in ChannelData

There is an “Attachments” property in System.Activity, which is misleading.
According to the reference below, attachment information actually exists in “ChannelData.”


Reference Link

When we inspect ChannelData, we can see that the file data (Base64) is contained in the OriginalAttachments property.
Inspecting ChannelData content

We will use this Base64 data to add file saving functionality to the agent.

Build: Saving attached files to SharePoint (Legacy)

In this example, we assume we are targeting only the first attached file.

*If you want to handle multiple files, do not use the First function; instead, handle them as a Table or loop with Foreach.

Build Power Automate

First, build the Power Automate flow to save the file.

Retrieve the file name and data string as arguments, then use the “Create file” action to save it.
Ensure the data string is converted to binary using the base64ToBinary function.
Legacy Power Automate flow setup
*Since “File” type arguments were not yet supported for Copilot Studio calls at the time, we create the argument as a “String.”
Setting input argument as String

Power Automate construction is complete.

Build Copilot Studio (Legacy)

Create a topic and retrieve the contentUrl of the first file in ChannelData as a string:
Retrieving contentUrl
Use a combination of Split and Index to extract the data string portion from the contentUrl:
Extracting data string
Then retrieve the file name:
Retrieving file name
Pass these values to the Power Automate flow created earlier:
Passing values to Power Automate

The legacy build is complete.

// Get contentUrl
Text(First(System.Activity.ChannelData.OriginalAttachments).contentUrl)

// Get data portion
Index(Split(Topic.contentUrl,","),2).Value

// Get file name
Text(First(System.Activity.ChannelData.OriginalAttachments).name)

Legacy Test

When you send a file and trigger the topic, file info is passed to Power Automate:
Legacy test execution
And the file is successfully saved.
File saved successfully
Result confirmation

コメント

  1. Samba says:

    Hello,
    I am able to Send attachment to the flow. Thank you.
    But, After publishing, attachment option not showing in demo site. Is there any settings needs to be changed ?

    Thank you

    • Ippu Ito Ippu says:

      Hello,
      Unfortunately, I have only tested it within Copilot Studio, so I am not sure how to display the attachment option on the demo site.
      There is also a high possibility that file attachments are not supported on the site (when published as a website).
      Thank you.

Copied title and URL