Upload File In Copilot Studio (Generative Orchestration Mode)

Upload File In Copilot Studio (Generative Orchestration Mode)

You can upload a file in Copilot Studio without prompting the User without using a question node. The User can simply drop a file into the chat window, the Agent will detect the file and then process it. This is made possible by creating a topic that triggers when an activity is performed and checking the Attachments table system variable for files.


Table of Contents
• Introduction: The File Upload AgentAdd A New Topic To The Copilot Studio AgentTrigger The Topic When A File Is Uploaded In ChatGet The Filename And Extension For The Uploaded FileCreate A New File In OneDrive/SharePointTest The File Upload In Generative Orchestration Mode




Introduction: The File Upload Agent

A Copilot Studio Agent accepts a file upload from the User in the chat window at anytime. The Agent does not use a question node, nor is it inside a topic before the file is added by the User.



The User’s uploaded file appears in OneDrive/SharePoint.




Add A New Topic To The Copilot Studio Agent

Open Copilot Studio and create a new Agent named File Upload Agent (Generative).



Use this text in the Agent description.

The Agent will receive a file from the user in the chat window, detect it using Generative Orchestration and perform actions on it.



Then go to the Topics tab and add a new Topic from blank named Upload A File To Copilot Studio (Teams).



Trigger The Topic When A File Is Uploaded In Chat

We want to trigger the topic when a file is uploaded to the chat window. Not when the Agent detects a trigger phrase. To do this, change the trigger type to when an activity occurs.



Then we add a condition to the trigger to specifically detect when a file is uploaded. Open the On Activity properties and change the condition type to formula.



Use this formula as the conidtion. It checks the Attachments table in the System variable to see if it is empty. When the attachments table has a file, it returns true and when there is no file it returns false.

Not(IsEmpty(System.Activity.Attachments)






Get The Filename And Extension For The Uploaded File

The Agent should communicate to the user that it is going to perform a file upload to let them know what it is doing. Add a message node with the text show below.



Use this formula to get the filename and extension. The First function is necessary because a User can potentially upload more than a single file, but in this simple example we only want to use one. To learn how perform addition validation to ensure there are not multiple files uploaded read this tutorial.

First(System.Activity.Attachments).Name




Create A New File In OneDrive/SharePoint

We want the Agent to upload a file to OneDrive/SharePoint. Both connectors work in a similar way. For this example, we will use the Create File – OneDrive for Business connector. Then setup the input parameters as follows:

  • Folder Path: (your folder path)
  • File Name: First(System.Activity.Attachments).Name
  • File Content: First(System.Activity.Attachments).Content




Send A Message To The User

After the file is uploaded we want to send a message to let the User know it was successful. Add a message node with the message “File successfully uploaded to the path {CreateFile.Path}”.




Test The File Upload In Generative Orchestration Mode

We are done. Save the topic. Publish the Agent. And upload a file to the chat window.



The Copilot Studio Agent will upload the file to OneDrive.






Questions?

If you have any questions or feedback about Upload File In Copilot Studio (Generative Orchestration Mode) please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

0 Comments
Oldest
Newest
Inline Feedbacks
View all comments