Add Copilot Studio Knowledge Files Using Power Automate

Our HR team regularly updates policy documents, including leave policies, codes of conduct, and remote work guidelines, and stores them in a SharePoint library. We use a chatbot called Policy Assistant Bot, built in Copilot Studio, to answer employee questions based on these documents.

However, every time we update a file, we must manually upload it again to the Agent as a knowledge file. It’s time-consuming, easy to forget, and creates a gap between updated documents and what the bot can answer.

Therefore, I created a Power Automate flow to upload the file.

Now, whenever someone adds a policy document in SharePoint, the flow automatically adds that file to Policy Assistant Bot’s knowledge base. The bot always stays in sync without manual work.

In this tutorial, I’ll show you how to create a Power Automate flow that automatically adds files to Copilot Studio Knowledge. I’ll also explain the file size limits you need to be aware of, both when uploading manually and when using Power Automate.

Create a Flow to Add Knowledge Files to Copilot Studio

Before we build the flow, ensure your Copilot Studio Agent is ready. This Agent will receive the knowledge files and respond to user questions based on them.

So let’s get started to add Copilot Studio knowledge files using Power Automate step by step.

Create a Copilot Studio Agent (Policy Assistant Bot)

This Agent will use uploaded documents, such as HR policies, leave guidelines, or employee handbooks, to automatically respond to employee questions.

Go to Copilot Studio, click + Create > + New Agent, skip the configuration step, enter the Agent name and description, then click create, or use an existing Agent you’ve created earlier.

Copilot Studio Knowledge Base Management with Power Automate

We’ll handle that automatically using Power Automate, so you won’t need to add anything to the Agent yourself.

Add Copilot Studio Knowledge Files Using Power Automate

Create a SharePoint Document Library

To store and manage your policy documents, you’ll need a dedicated SharePoint document library. This is where your Power Automate flow will monitor for new files and send them to your Copilot Agent.

Add Copilot Studio Knowledge Files in Power Automate

Create a Power Automate Flow to Upload Knowledge Files

Now that your SharePoint document library and Copilot Studio Agent (Policy Assistant Bot) are ready, let’s build the flow that will automatically upload policy documents to the Agent’s knowledge base.

  1. Go to Power Automate. Click Create > Automated cloud flow. Choose the trigger: When a file is created (properties only) (SharePoint). Select the SharePoint site and Library Name (“Policy Documents”).
Dynamic Knowledge File Upload in Copilot Studio via Power Automate

When an agent (Copilot) is created in Copilot Studio, a corresponding record is stored in the Dataverse table named Copilots.

  1. To retrieve the details of the newly created agent, use the List rows action for Microsoft Dataverse in Power Automate and provide the following parameters:
    • Table name: Select Copilots
    • Filter rows:
name eq 'Policy Assistant Bot'
Upload Knowledge Files from Email to Copilot Studio

Now we’ll store the Agent ID of our Policy Assistant Bot in a variable so we can reuse it later in the flow when adding a Knowledge File to the Copilot Studio.

  1. Add a new Initialize variable action with the following parameters:
    • Name: varCopiloteId
    • Type: String
    • Value: Provide the below expression:
first(outputs('List_rows')?['body/value'])?['botId']
Build a Flow for Copilot Studio Knowledge File Management

Whenever we upload a file to the Agent, a record gets created in the Copilot components table in Dataverse. To avoid uploading duplicates, we’ll query this table to check if the file is already there.

  1. Add a List rows action from the Dataverse connector and configure it as follows:
    • Table name: Copilot components
    • Select columns: name
    • Filter rows:
_parentbotid_value eq @{variables('varCopiloteId')}

This filter ensures we only retrieve components (such as knowledge files) linked to the specific Copilot Agent we’re working with.

Power Automate Upload to Copilot Studio Knowledge from SharePoint

The List rows action gives us a full list of components (including various details), but we only need the file names to check whether the current file has already been uploaded. To simplify this, we’ll use the Select action to extract just the name property of each item.

  1. Add a Select action with the following parameters:
    • From: @{outputs(‘List_rows_1’)?[‘body/value’]}
    • Map: Click the small T Icon to switch to text mode. Then enter the following expression:
@{item()?['name']}
Upload PDF to Copilot Studio Using Power Automate

This will create an array containing only the names of all existing knowledge files in the Copilot components table. We’ll use this list to verify whether the current file already exists.

Now that we have a list of all existing knowledge file names, let’s add a Condition to check if the current SharePoint file already exists in that list.

  1. Add a Condition action and use the following expression:
@{body('Select')} does not contain @{triggerBody()?['{FilenameWithExtension}']}
Triggered Uploads to Copilot Studio Knowledge Sources
  1. In the true section, add a Get file content action (from the SharePoint connector) with the following parameters:
    • Site Address: Select the SharePoint site where your policy documents are stored.
    • File Identifier: Use the following expression from dynamic content:
@{triggerBody()?['{Identifier}']}
Connect SharePoint to Copilot Studio Knowledge via Power Automate

Once you retrieve the file content, you can now register the file as a knowledge component by adding a new row to the Copilot components table in Dataverse.

  1. Add an ‘Add a new row‘ action (from the Dataverse connector) and configure it as follows:
    • Table name: Copilot components
    • ComponentType: Bot File Attachment
    • SchemaName:
cr0e5_policyAssistantBot.file.@{triggerBody()?['{FilenameWithExtension}']}
  1. Expand the Advanced parameters section and fill in:
    • Description: Power Automate Flow adds Knowledge.
    • Name: @{triggerBody()?[‘{FilenameWithExtension}’]}
    • parentbotid (Copilots): Parentbotid lookup field to indicate which Agent owns the component:
/bots(@{variables('varCopiloteId')})
Automate Copilot Studio Knowledge Updates Using Power Automate

After you add the metadata to the Copilot components table, you need to upload the actual file content (binary data). We do this using the ‘Upload a file or an image’ action in Power Automate.

Tip:

If you’re unsure how to find the correct schema name, scroll down to the Find Schema Name in Dataverse section.

  1. Add an Upload a file or an image action (Dataverse connector) and configure the following:
    • Content name: @{triggerBody()?[‘{FilenameWithExtension}’]}
    • Table name: Copilot components
    • Row ID: @{outputs(‘Add_a_new_row’)?[‘body/botcomponentid’]}
    • Column name: filedata
    • Content: @{body(‘Get_file_content’)}
Create a Flow to Add Knowledge Files to Copilot Studio

After uploading the file to Dataverse and linking it to your Agent, you need to publish the changes so the file becomes active and usable in Copilot Studio.

We’ll do this by calling the PvaPublish action on the Copilots table in Dataverse.

  1. Add a ‘Perform a bound action‘ action (Dataverse connector) and configure it as follows:
    • Table name: Copilots
    • Action Name: PvaPublish
    • Row ID: @{variables(‘varCopiloteId’)}
Schedule Copilot Studio Knowledge Uploads via Power Automate

This action will trigger the publishing process for the selected Copilot Agent, in this case, your Policy Assistant Bot. Once published, the newly uploaded knowledge file will become available in the bot’s knowledge base.

Note:

In the “False” branch of the condition (i.e., the file already exists in the Agent’s knowledge base), you may want to notify the person responsible that the file is already present. This helps avoid unintentional duplicate uploads.

Test Copilot Studio Agent To Upload a File

Once your flow is complete, it’s time to test the full automation and ensure everything works as expected.

Save your flow in Power Automate. Go to your SharePoint document library (Policy Documents). Upload a large file (you can test with something over 7MB to confirm the benefit).

Tip:

Make sure your file name does not contain spaces. For example: Power_Platform_EBook.pdf

Power Automate Flow to Upload Copilot Studio Knowledge

Once the flow runs successfully, follow these steps to confirm the file has been added to your Agent:

  1. Go to Copilot Studio.
  2. Open your Policy Assistant Bot.
  3. Navigate to Knowledge.

You will see the uploaded file listed there. Its status may initially show as “In progress.” This means Copilot Studio is still processing the file and extracting the content.

Power Automate Add Copilot Studio Knowledge Files

After a few minutes, you’ll see the file’s status change from “In progress” to “Ready.”

Add Copilot Studio Knowledge Files Power Automate

Once the file status shows ‘Ready’, proceed to test your Policy Assistant Bot. Click Test your bot inside Copilot Studio.

How To Add Copilot Studio Knowledge Files Using Power Automate

Find Schema Name in Dataverse

To get the correct Schema Name for your Agent’s knowledge files, follow these steps:

  1. Go to Power Apps > Tables.
  2. Search for the Copilot components table.
  3. In the data view, filter the ComponentType column by Knowledge Source.
  4. Look at the SchemaName column; you should see values related to your Agent name. The format typically looks like this:
<your publisher prefix>_<agent name>.
Use Power Automate to Maintain Copilot Studio Knowledge

Still Can not Find the Schema Name

If you don’t see anything in the list:

  1. Manually add a knowledge file to your Agent from the Copilot Studio.
  2. Then return to the Copilot components table.
  3. This time, filter ComponentType by Bot File Attachment.
  4. You should now see a SchemaName that matches your Agent, which you can use in the Power Automate flow.

Copilot Studio Knowledge Limit

Copilot Studio only allows manual uploads of up to 7MB, and even with a trial license, this limit remains unchanged. If you’re using a licensed version, you can upload files up to 200MB but only through the Copilot Studio interface.

With Power Automate, you can go even further. You can upload knowledge files up to 512MB directly to your Agent.

With this Power Automate flow, you no longer need to upload files to your Policy Assistant Bot manually. Whenever someone adds a new policy document to SharePoint, the bot is automatically updated.

Also, you may like some tutorials:

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial

FREE Power Platform Tutorial PDF

Download 135+ Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…