web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Trying to build an age...
Copilot Studio
Suggested Answer

Trying to build an agent that reads a pdf and gives me an excel file

(0) ShareShare
ReportReport
Posted on by 4

Hi everyone, I’m working on building an agent in Copilot Studio that converts PDF files into Excel files. The Excel output then needs to be imported into a PIM system, which requires very specific fields.

My goal is to have the agent automatically map the fields during the PDF ingestion — for example, mapping “article number” to “SKU,” and so on. When I test this in the “Run a prompt” view, the mapping works exactly as expected.

However, once I save the agent and go to the step where I’m supposed to select the fields, I get stuck. Instead of being able to choose the actual files I used in the prompt testing, I can only choose from dynamic content or use fx, neither of which allows me to select the real files. I even uploaded the files to SharePoint, hoping that would make them more accessible for the agent, but it still doesn’t help — the files simply don’t appear as selectable options.

I’m not sure if I’m explaining the issue clearly, but I’m hoping someone here might recognize this situation or have advice on how I should structure things to get this working.

Any tips or guidance would be greatly appreciated!

Thank you!

I have the same question (0)
  • Suggested answer
    ITWithAllan Profile Picture
    160 Moderator on at
    If I understood you clearly you want to upload a file during a conversation and then have the agent return it as an excel file, right? You can try using a question with the type "file" for answer. That way you can send your file metadata directly to power automate as an data input, so you'll be able to use it as dynamic content. You can also try to use the "Analyst" agent in copilot 365, he's fully capable of understading your data and files and returning excel, pdf and word documents.

    Hope it helped :)
  • Suggested answer
    HC-16031516-0 Profile Picture
    4 on at
    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!
  • Suggested answer
    DP_Prabh Profile Picture
    361 on at
    Hi @HC-16031516-0, I think test uploads don't persist. You must use runtime file input. I'll suggest use power automate and sharepoint. Flow can be like:
    1. Trigger: file added (SharePoint)
    2. Get file content
    3. Run prompt (pass file dynamically). Do field mapping inside the prompt, not in UI based on my experience.
    4. Return structured JSON (mapped fields)
    5. Send to PIM (product info management)

    I hope this works for you!

  • HC-16031516-0 Profile Picture
    4 on at
    Thank you for your reply. I have tried this approach but found myself not being able to select the neede files dynamically since they do not appear in the dynamic content list.
    My issue here is that my reference files are to big (all attrbutes and families and their variants) When I try to put the files in pdf of as raw text I get the message that it is too much or pages or tokens in the text. However when I do not specify the mapping documents onyl write them in the prompt and tell in the instructions: Fetch information from file named: *the name* then I do not get any errors but then when I test my flow I get the output rawdata to be null, no matter what files I then put in when I do the test.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 531

#2
Vish WR Profile Picture

Vish WR 293

#3
Haque Profile Picture

Haque 208

Last 30 days Overall leaderboard