"Every step in this guide tells you what the screen looks like before telling you what to click. If what you see does not match the description, stop and re-read — you are in the wrong place."
Architecture — Why We Use OneDrive-First
You may have read tutorials that pass the file directly from
Copilot Studio to Power Automate via Power Fx formulas
like Topic.ExamFile.Content.
In practice this causes type mismatch errors on many Microsoft 365 tenants
because Copilot Studio stores uploaded files as Blob objects
which are not compatible with Agent Flow text inputs.
This guide uses the OneDrive-first pattern — the approach that works reliably in production:
WHAT WE BUILD:
Student uploads file
↓
Copilot Studio saves file automatically to OneDrive
(this happens inside the Question node — no extra step needed)
↓
Copilot Studio calls Power Automate flow
passing only: the filename (text) — no file binary
↓
Power Automate reads the file FROM OneDrive directly
using the filename it received
↓
Power Automate reads each question → AI answers → saves to SharePoint
No type mismatch. No base64 conversion errors. No Power Fx dot notation on Blob objects. The file stays in OneDrive — both tools access it there.
Phase 1 — Create the Copilot Studio Agent
Step 1: Open Copilot Studio
Go to copilotstudio.microsoft.com. Sign in with your work Microsoft 365 account. You land on the home page. The left sidebar shows: Home, Agents, Flows, Tools, Settings.
Step 2: Create a new agent
- At the bottom of the home page you see a large text input
with placeholder text "Describe your agent...".
Below this input, look for a small text link:
"Skip to configure". Click it.
If you cannot find "Skip to configure": click Agents in the left sidebar → click "+ New agent" (top right) → on the wizard screen that opens look for "Skip to configure" at the bottom. - A configuration form appears with three fields.
Fill in exactly:
- Name:
Exam Evaluator - Description:
Receives exam question files from students, automatically answers all questions using AI, and sends results for review - Instructions:
You help teachers evaluate student exam papers. When a user uploads an Excel file with exam questions, save it to OneDrive and trigger the evaluation flow.
- Name:
- Click Create (blue button, top right)
- You land on the agent Overview page. Left sidebar now shows tabs for this agent: Overview | Topics | Actions | Knowledge | Analytics | Channels | Settings
Step 3: Create the conversation Topic
- Click Topics in the left sidebar
- You see two tabs at the top: Custom and System. Click Custom
- Click "+ Add a topic" (top right) → click "From blank"
- The topic canvas opens showing one node: a purple Trigger node at the top with placeholder text "Add trigger phrases"
- At the very top of the page, click the topic name showing "Untitled" → type Evaluate Exam Paper → press Enter
Step 4: Add trigger phrases
- Click inside the Trigger node. It expands to show a Phrases section with an "+ Add phrase" link below it.
- Click "+ Add phrase" →
a text box appears → type:
evaluate exam→ press Enter to confirm - Click "+ Add phrase" again →
type:
upload exam file→ press Enter - Click "+ Add phrase" →
type:
answer my questions→ press Enter - Click "+ Add phrase" →
type:
process exam paper→ press Enter
Step 5: Add a welcome message
- Below the Trigger node, click the blue + button that appears between nodes
- A popup menu appears with options: Send a message | Ask a question | Add a condition | Call an action | etc.
- Click "Send a message"
- A blue Message node appears with a text area inside it
- Click inside the text area and type:
Hello! Please upload your Excel file (.xlsx) containing the exam questions. I will answer all questions automatically and send results for review.
Step 6: Add the file upload Question node
- Click the blue + button below the Message node
- Click "Ask a question"
- A Question node appears with two sections:
- Top section: "Ask a question" — a text area for your question text
- Bottom section: "Identify" — a dropdown for what type of answer you expect
- In the top text area, type:
Please upload your Excel file with exam questions in Column A. - In the Identify section: click the dropdown currently showing "User's entire response"
- A long list of options appears. Scroll down past the common options (Number, Date, Email, etc.) toward the bottom of the list. Find and click "File"
- Below the Identify section you see:
"Save response as" with a variable name like
Var1 - Click on
Var1→ a small rename field appears → clear it and type ExamFile → click anywhere outside to confirm
Phase 2 — Build the Power Automate Agent Flow
Step 7: Create the Agent Flow
- In the Copilot Studio left sidebar, click Flows (the icon looks like a lightning bolt)
- Click "+ New flow"
- A small dropdown appears with exactly two options:
- Agent flow
- Cloud flow
- Click Agent flow
- The Power Automate designer opens in a new browser tab.
You see the flow canvas with two nodes already connected by an arrow:
- Top blue node: "When an agent calls the flow" — this is the trigger. Do not delete it.
- Bottom blue node: "Respond to the agent" — this sends data back to Copilot Studio. Do not delete it.
- At the top of the page, click the flow name showing "Untitled" → type Process Exam Questions → click outside to save the name
Step 8: Add inputs to the trigger
- Click the "When an agent calls the flow" trigger node to expand it
- Inside the expanded node, scroll to the bottom. You see a grey button: "+ Add an input". Click it.
- A row appears with:
- Left: a type selector showing a dropdown
- Right: a name field with placeholder "Input"
- Click the type dropdown → select Text
- Click the name field → clear it → type FileName
- Click the description field that appears below →
type:
Name of the uploaded Excel file
Step 9: Read the Excel file from OneDrive
- Click the + (plus) button between the trigger node and the "Respond to the agent" node. A search box appears.
- Type: List rows present in a table
- In the results, find the green Excel icon labelled Excel Online (Business) → click "List rows present in a table" under it
- The action card expands showing these fields:
Location field:
- Click the Location dropdown → select OneDrive for Business
Document Library field:
- Click the Document Library dropdown → select OneDrive
File field:
- Click the folder icon on the right side of the File field
- A file browser opens showing your OneDrive for Business folders
- Navigate to the ExamProcessing folder
- Click your exam-questions.xlsx file → click Select
- The file path appears in the field
Table field:
- Click the Table dropdown
- Power Automate connects to the file and reads available tables
- You should see ExamQuestions — click it
- If the dropdown is empty or shows an error:
- Verify the file is saved to OneDrive for Business (not local)
- Open the file → confirm the data has Insert → Table applied
- Confirm the table name is exactly
ExamQuestions(Table Design tab → Table Name field in Excel ribbon)
Step 10: Initialize a variable to collect answers
- Click the + below the List rows action
- Search: Initialize variable
- Click Variables → Initialize variable
- Fill in:
- Name: type
AllAnswers - Type: click dropdown → select String
- Value: leave this field completely empty
- Name: type
Step 11: Add the loop — Apply to each
- Click + below Initialize variable
- In the search box type: Apply to each
- Under Control category, click "Apply to each"
- A loop container appears with one field: "Select an output from previous steps"
- Click inside this field
- A dynamic content panel opens on the right (or slides up from the bottom depending on screen size)
- Look for the section labelled "List rows present in a table"
- Under that section, click value (this is the array of rows from your Excel table)
- A blue pill labelled value appears in the field
Step 12: Add AI Builder inside the loop
- Click the + button inside the Apply to each loop. Look for the + sign inside the loop boundary, not the + below the loop.
- Search: Run a prompt
- Under AI Builder connector, click "Run a prompt"
- The action card appears inside the loop with a Prompt field
- Click "+ Create a prompt" (you may also see this as "New prompt")
- A Prompt Builder panel opens on the right side of your screen. This is part of Power Automate — not a separate website or portal.
Inside Prompt Builder — follow these exact steps:
- At the top, click the name field showing "Untitled" → type Answer Exam Question
- In the large white text area (the prompt body),
click inside it and type exactly:
You are an expert teacher and subject matter expert. A student has submitted an exam question for evaluation. Provide a clear, accurate, and educational answer. Question: [Question] Instructions: - Answer accurately and completely - Keep answers to 2-5 sentences - Use plain English suitable for a student
- Notice
[Question]in the text above. Now create the input variable that will replace it:- Below the text area, click "+ Add input"
- A row appears with a type selector and name field
- Leave type as Text
- In the name field, type Question
- After typing the name, look at the prompt text above —
[Question]should now be highlighted or linked showing it is connected to your input - Click Save (blue button, usually at top right of the Prompt Builder panel)
- You return to the Power Automate flow canvas. The "Run a prompt" action now shows Answer Exam Question as the selected prompt.
- Below the prompt selection, you see a field labelled Question
- Click inside the Question field
- Dynamic content panel opens → look for the section "Apply to each" or "List rows present in a table" → click Question (this is the Question column from your Excel row)
- A blue pill labelled Question appears in the field
Step 13: Append each answer to the variable
- Click + inside the loop, below "Run a prompt"
- Search: Append to string variable
- Click Variables → Append to string variable
- Fill in the Name field: click the dropdown → select AllAnswers
- Now fill in the Value field.
You will mix typed text with dynamic content — follow these steps one by one:
- Click inside the Value field
- Type:
Question:(include the space after colon) - Click "Add dynamic content" (a lightning bolt icon or link below the field) → under Apply to each / current item → click Question
- Press Enter (new line)
- Type:
Answer: - Click "Add dynamic content" → under "Run a prompt" section → click text (this is the AI's response — it may appear as "text" or "Prediction text" depending on your environment)
- Press Enter twice (two new lines for spacing)
- Type:
---(three dashes as a separator between Q&A pairs) - Press Enter
- The completed Value field should contain:
Question: [Question] Answer: [text] ---Where [Question] and [text] are blue dynamic content pills.
Step 14: Return the result to Copilot Studio
- Click the "Respond to the agent" node at the very bottom of the flow. This node was pre-created — you do not need to add it.
- Inside the node, click "+ Add an output"
- Type selector: click dropdown → select Text
- Name field: type ProcessingResult
- Value field: click inside it → dynamic content panel opens → click AllAnswers
- Click Save draft (top right)
- Click Publish (blue button, top right)
- Wait for the confirmation message: "Your flow is ready to use" or "Flow published successfully"
Phase 3 — Connect the Flow to Copilot Studio
Step 15: Return to Copilot Studio
- Switch back to the browser tab with Copilot Studio. If you closed it, go to copilotstudio.microsoft.com → click Agents → click Exam Evaluator
- Click Topics in the left sidebar → click Evaluate Exam Paper
- Your topic canvas opens showing: Trigger → Message → Question (ExamFile) nodes
Step 16: Pass the filename using a Set Variable node
Before calling the flow, we store the filename in a text variable so we can pass it cleanly.
- Click + below the Question node
- Click "Set a variable value" (you may need to scroll in the popup menu to find it)
- In the Set variable node:
- Click "Create new variable"
- Name: ExamFileName
- Type: String
- Value: click the input field →
click the formula (fx) icon →
type:
Topic.ExamFile.Name→ press Enter
Topic.ExamFile.Name returns just the filename as text
(e.g. "exam-questions.xlsx").
The .Name property is text, not a Blob —
so it works in the formula bar without errors.
We are NOT accessing .Content (which causes Blob errors).
Step 17: Call the Power Automate flow
- Click + below the Set variable node
- Click "Call an action"
- A panel opens showing available flows. You should see Process Exam Questions listed.
- Click Process Exam Questions
- An Action node is added showing one input field: FileName
- Click inside the FileName input field
- Click the {} (variable) icon or the dynamic content picker → select ExamFileName (the text variable you just set in Step 16)
- Below the inputs section you see Outputs: ProcessingResult is listed automatically
- Click the variable name next to ProcessingResult → rename it to FlowResult
Step 18: Add confirmation message
- Click + below the Action node
- Click "Send a message"
- Type:
Your exam has been processed. The results are being saved and an approval request has been sent for review. You will receive confirmation once approved. - Click Save (top right of the topic editor)
Phase 4 — Test
Step 19: Test in the Copilot Studio test panel
- Click Test (top right of Copilot Studio, looks like a chat bubble with a play icon)
- A test chat panel slides in from the right side of the screen
- Type: evaluate exam → press Enter
- The agent responds with your welcome message
- Click the paperclip (attachment) icon in the test chat input bar
- Select your exam-questions.xlsx file → click Open
- Press Enter or click Send
- You see a loading indicator — the flow is running. Wait 30-90 seconds.
- The agent responds with your confirmation message when done
How to diagnose if the flow fails
- Go to powerautomate.microsoft.com
- Click My flows in the left sidebar
- Click Process Exam Questions
- Scroll down to 28 day run history
- Click the most recent run (red circle with X = failed, green circle = success)
- The run detail page shows every step. Failed steps have a red X. Click a failed step to expand it — the error message tells you exactly what went wrong.
Common Errors and Exact Fixes
-
"Table not found" or "ExamQuestions not found"
Open your Excel file in OneDrive → click anywhere in the data → check the Table Design tab appears in the ribbon → check Table Name shows exactlyExamQuestions(no spaces, correct capitalisation). If it shows "Table1", click it and rename it to ExamQuestions. -
"Run a prompt" action not found
Your Power Automate Premium trial may not be active. Go to powerautomate.microsoft.com → click your profile picture (top right) → check your licence shows Premium or Trial. The AI Builder connector only appears with a Premium licence. -
Flow not appearing in Copilot Studio "Call an action"
Flow must be Published, not just saved as draft. In Power Automate → My flows → check the toggle is ON (green) and status shows Published. Then in Copilot Studio: delete the Action node, refresh the page, re-add the action. -
"text" not found in dynamic content for Append variable
The AI Builder output field name varies by environment. In dynamic content under "Run a prompt", look for:text,Prediction text, orresponsev2. Select whichever appears — it is the AI's answer. -
Topic.ExamFile.Name gives PowerFxError
TryText(Topic.ExamFile.Name)instead. If still failing, hardcode a test filename: replace the Set Variable value with the literal textexam-questions.xlsxto confirm the rest of the flow works, then fix the variable formula after.
🎯 Quick Check — Part 2
Q1: Why do we pass only the filename to Power Automate instead of the file content?
Show Answer
Because passing file binary content (Blob) from Copilot Studio to Agent Flow inputs causes type mismatch errors on most tenants. In the OneDrive-first architecture, Copilot Studio saves the file to OneDrive automatically when the student uploads it. Power Automate reads the file directly from OneDrive using the filename. No file binary is ever passed between the two platforms.
Q2: The Apply to each loop iterates over "value" from List rows. What is "value"?
Show Answer
"value" is the array of rows returned by the "List rows present in a table" action. Each item in the array is one Excel row — an object with properties matching your column names. So if your Excel has columns Question and Answer, each item has a Question property and an Answer property. When you select "value" in Apply to each, the loop runs once per row.
Q3: Where is the "Respond to the agent" node? Do you need to add it?
Show Answer
No — it is pre-created at the bottom of every Agent Flow automatically when you create the flow. You never need to add it. You only need to click it and add your output variable (ProcessingResult) inside it. If you cannot see it, scroll to the very bottom of the flow canvas.
Key Takeaways — Part 2
- OneDrive-first pattern: Copilot Studio saves the file automatically, Power Automate reads it from OneDrive — no file binary is passed between platforms
- Agent Flow has two pre-built nodes: trigger at top and "Respond to the agent" at bottom — build all steps between them, never delete them
- Initialize variable BEFORE the loop — Power Automate will error if you try to initialize inside Apply to each
- The flow MUST be Published (not just saved as draft) before it appears in Copilot Studio "Call an action"
- When a step fails: Power Automate → My flows → Run history → click the failed run → expand the red X step to read the exact error