Thank you for your reply however I dont know if its quite right. Here is what I have done:
I am building a Copilot Studio agent that takes a PDF product sheet, extracts text, matches it with two CSV catalogs (Akeneo field mappings + Family/Variant definitions), and returns pure JSON.
However, I cannot get the agent to receive the correct PDF text inside the Run a prompt action. The prompt always returns my fallback error:{ "error": "PDF-informationen är otydlig eller saknar produktdata." } which is my own error handling for when pdf is not available or correct read.
Even though all steps run successfully.
Below is a complete breakdown of what I have done.
SUMMARY OF WHAT I HAVE DONE SO FAR AND THE ISSUE I AM FACING:
I am building a custom action flow for a Copilot Studio agent. The agent should take a PDF file uploaded by the user, extract the product information using OCR, match this information with two CSV-based catalogs (Akeneo field mappings and Family/Variant mappings), and return a JSON object. The entire setup works except for one critical issue: the prompt never receives the PDF text, and always returns my fallback error.
Here is everything I have done so far:
The flow structure looks like this:
In the prompt editor I created three inputs:
DocumentInput (text)
AkeneoFields (text)
FamiliesAndVariants (text)
These correctly appear in the Run a prompt action.
The CSV inputs work correctly. Both CSV files are loaded as text and mapped to the prompt inputs in code view. In code view I can see that:
item/requestv2/Attribut contains the CSV text
item/requestv2/familjer_20o_20varianter contains the CSV text
So both catalog files are being passed correctly.
The main problem is with the PDF text (DocumentInput). The OCR action returns the full text successfully in the run logs. In the logs I see:
responsev2 → predictionOutput → results[0] → fullPageText
This contains the full extracted PDF text.
However, Copilot Studio does NOT expose fullPageText or fullText as dynamic content. The only dynamic content available from the OCR step is:
Document’s entire text (usually empty)
Page’s entire text (interpreted as an array)
Text (each line)
Coordinates
If I select “Page’s entire text”, Copilot Studio automatically wraps the prompt in an “Apply to each” loop, because it thinks the value is an array. This breaks the prompt.
To avoid this, I tried using an expression instead of dynamic content. The correct path to the PDF text is:
outputs('ReadPDF')?['body']?['responsev2']?['predictionOutput']?['results']?[0]?['fullPageText']
I wrapped it in string() and saved it as the DocumentInput value.
The expression appears correct and tooltip validation works. However, the Copilot Studio expression editor automatically inserts line breaks inside the action name or path for display purposes. Even though it looks right in tooltip form, the internal behavior seems to break the expression or cause it to evaluate to empty at runtime. As a result, DocumentInput becomes an empty string.
Because DocumentInput is empty, the prompt receives no PDF text. The prompt always returns my fallback JSON:
{ "error": "PDF-informationen är otydlig eller saknar produktdata." }
All steps run without errors, but the output is always the fallback.
What I have confirmed:
The OCR step definitely extracts the full text (visible in logs)
The CSV files are passed correctly as text
The prompt works in isolated test mode when I paste text manually
Respond to agent correctly returns the prompt’s response field
The only missing piece is DocumentInput not getting any text during runtime
Things I have tried that did NOT work:
Using “Page’s entire text” dynamic content (creates unwanted For each)
Using “Text (each line)” (array, also causes loop)
Using “Document’s entire text” (empty)
Using fullText via body(), outputs(), both correct JSON paths
Renaming the OCR step to a short name like “ReadPDF”
Re-creating the prompt inputs
Removing and re-adding Run a Prompt
Removing and re-adding the OCR step
Using string(), first(), join(), select(), etc. (not all template functions are supported in Copilot Studio)
What I suspect is happening:
The OCR output contains the correct text, but Copilot Studio Action Flows do not currently support accessing nested JSON fields like:
responsev2 → predictionOutput → results[0] → fullPageText
via FX expressions. The dynamic content system exposes only a limited and “flattened” subset of fields. Because of this, DocumentInput evaluates to empty even if the FX expression is syntactically correct.
What I need help with:
Is there an officially supported way to retrieve OCR full text (fullPageText or fullText) inside a Copilot Studio flow?
Is deep JSON extraction supported in custom actions when using AI Builder connectors?
Is this a known limitation or bug in Copilot Studio?
Is there a recommended workaround to flatten the OCR output so that I can pass it into Run a Prompt without triggering “Apply to each”?
My goal is simply to get the extracted PDF text as a single string into my prompt’s DocumentInput parameter.
When an agent invokes the flow: receives the uploaded PDF file
Get file content using path (SharePoint, attributes.csv) – set to “Infer content type = No” and “Return file content as Text”
Get file content using path (SharePoint, families_and_variants.csv) – same settings
OCR step (“Extract text from image or document”) which I renamed to “ReadPDF”
Run a prompt (my custom GPT-5 prompt)
Respond to the agent
I know this is a lot to read but all the help I can get regarding this is much appreciated. Please help!