hello :)
I would suggest another approach based on recent tech update in copilot studio.
Most of thing i will speak are covered by this incredible content from Matthew from this video or other video from is channel :
https://www.youtube.com/watch?v=JMlUcxqnU30 (File upload, file generation, retrieve file, etc)
Prerequisite :
- Enable the code interpreter inside of you'r environnement ( to have it click on the "..." in the left pan, code to the admin of the environnement in manage tab and then settings of environnement and then feature and then enable code interpreter -> if you canno't : ask for you'r environnement admininstrator)
- inside you copilot studio agent go to settings and enable the file upload
What to do :
Create a new tool "prompt tool" (also old name is AI builder prompt) with 2 input
- One is the document you wana extract information
- Other one will be the template
Since you'r document is a text PDF it will be enough (OCR document processing tool is only needed to scan and extract entities for image or complexe unstructured invoice). create a prompt to look for the information you need , and you can tell to store them like in JSON or whatever.
Then you have 2 option
- from the same prompt tool : use this information to create the file based on the template you provided and use the video above to have insigh about file generation
- from the same prompt tool : just generate a JSON answer with what you need and call another prompt tool dedicated to file generation (this case you didn't need the template as input of first tool)
you will have to make few try to create the perfect prompt :) but it will work
If the "final file is very complicated" personnaly what i would do :
A prompt tool to extract information
A prompt tool to generate content for every "chapter"
A prompt tool to collect all generated content and create the final file
At the end you could use the Matthew video to store the generated file inside the onedrive of the user and provide the link in the chat or an email if generation take a long time.
Then you could separe step to imagine having this case working in autonomous agent to be used when email with file arrive, when some one drop file in sharepoint etc.
This case will demand you a lot of work, if unlucky with prompt creation few day of work but it will be resilient.
If the prompt tool is not enough and you need the Document processing part of AI Builder, is nearly the same process since you could call the tool from a copilot studio topic (you don't need a power automate to do it)
I hope this help you, this solution demand a lot of work the first time you need to do it but it's a classic , i hope you will enjoy making it and learn a lot of new fun things :)
if it help you please check the answer as resolved it's important for the search engine and community for the futur :)