Power Automate and Power Apps
The AutomaDoc connector brings your templates into Microsoft’s workflow tools. A flow sends the values of a template’s placeholders (from a SharePoint list item, a Dataverse row, an Excel row, a form response) and gets the finished document back, ready to save to a document library, attach to an email or post in Teams.
It works in Power Automate, Power Apps (through a flow), Azure Logic Apps and Copilot Studio. It is built on the document API, so everything the API does with your data (names, loops, pictures, conditions) is the same here.
Before you start
Section titled “Before you start”- A template. Create it in the Company Portal under Templates, in the Excel add-in or in the Lark Base extension, with placeholders such as
{Customer},{Invoice_No}or a{#Items}…{/Items}loop. The connector shows one input per placeholder, read from the template’s last upload. - A company API key. An admin of your company creates one in the Company Portal under Company → API keys. It starts with
amk_and is shown once: copy it somewhere safe. (A template’s own key cannot list your templates, so the connector needs a company key.)
Add the connector
Section titled “Add the connector”Until the AutomaDoc connector appears among the certified connectors, add it to your environment as a custom connector. You do this once per Power Platform environment.
- Get the connector’s definition. Download it, Download the connector definition, or use its address:
https://api.automadoc.cc/api/v1/power-platform.swagger.json - In Power Automate, open Data → Custom connectors (or More → Discover all → Custom connectors), then New custom connector and either Import an OpenAPI file (the file you downloaded) or Import an OpenAPI from URL (paste the address). Name it
AutomaDocand select Continue. - The General tab is filled in from the definition (host, base URL and description): nothing to change.
- On the Security tab, check that the authentication type is API Key, with the parameter name
X-Webhook-API-Keyand the location Header (they come with the definition). If the parameter label is empty, typeAPI Key. Select Create connector. - On the Test tab, select New connection, paste your company API key and create the connection. Test the ListTemplates operation: it answers
200with your templates.
In a flow, add an action and search for AutomaDoc: it is listed with your custom connectors. Once the certified connector is listed, search for AutomaDoc when adding an action and paste the key when asked for a connection.
If your organization’s data loss prevention (DLP) policies block custom connectors, your Power Platform admin can allow this one by its host, api.automadoc.cc. The Power Automate page of the Company Portal has the same steps and the download.
Walkthrough: a document for each new SharePoint item
Section titled “Walkthrough: a document for each new SharePoint item”This flow makes an invoice whenever an item is added to a SharePoint list, and saves the PDF to a document library.
- Trigger. Create an automated cloud flow with SharePoint → When an item is created, and choose your site and list (for example Invoices).
- Generate the document. Add AutomaDoc → Generate a document.
- Template: pick your invoice template from the list.
- The template’s inputs appear below it. Map each one from the trigger’s dynamic content:
Invoice_No← Title,Customer← Customer,Total← Amount, and so on. - Output Format:
pdf. The step waits until the document is ready, then hands the next steps itsDocument ID,File Name,StatusandDownload URL.
- Download it. Add AutomaDoc → Download document with Document ID ←
Document IDfrom the previous step. - Save it. Add SharePoint → Create file:
- Folder Path: your library, for example
/Shared Documents/Invoices. - File Name:
File Namefrom Generate a document. - File Content:
File Contentfrom Download document.
- Folder Path: your library, for example
- Save the flow and add an item to the list. The PDF appears in the library a few seconds later.
To email it instead, use Office 365 Outlook → Send an email (V2) with an attachment: name File Name, content File Content.
More ready-made flows, for an approval, a Microsoft Forms response or attaching the file to the item, are in Power Automate recipes.
Line items: a loop in the template
Section titled “Line items: a loop in the template”A {#Items}…{/Items} table row in the template appears as a list input, Items, with one field per column. To fill it from another list (the invoice’s lines, say), switch the input to entire array mode and pass an array whose objects use the column names as keys, for example built with Data Operation → Select from Get items:
| Select: map key | Value |
|---|---|
Product |
Title |
Qty |
Quantity |
Price |
UnitPrice |
From Dataverse or Excel
Section titled “From Dataverse or Excel”The steps after the trigger are the same; only the trigger and the dynamic content change:
- Dataverse: When a row is added, modified or deleted (change type Added), then map the row’s columns to the template’s inputs.
- Excel Online (Business): For a selected row (run from Excel), or List rows present in a table followed by an Apply to each: one Generate a document per row makes one document per row.
One document from many rows
Section titled “One document from many rows”A template set to make one document from many records (a list, a page per record, labels) takes a list instead: its input is Records, one entry per row, and the step makes one document from all of them. Pass the rows of List rows or Get items through a Select, as for line items. Up to 500 rows per document.
Power Apps
Section titled “Power Apps”Make the document in a flow and call the flow from the app:
- Create an instant cloud flow with the Power Apps (V2) trigger and add text inputs for the values the app sends.
- Add Generate a document and map those inputs; finish with Respond to a Power App or flow returning
Download URL(or save the file as above and return its link). - In the app, call it from a button:
Set(doc, GenerateInvoice.Run(txtCustomer.Text, txtTotal.Text)); Launch(doc.downloadurl).
The flow waits for the document. An app that calls the connector directly is not made to wait: it gets the document back while it is still processing, and has to call Get document status until it is completed.
Logic Apps and Copilot Studio
Section titled “Logic Apps and Copilot Studio”The same connector works in Logic Apps (Standard and Consumption), with the same actions. In Copilot Studio, add Generate a document as a tool of your agent: the agent fills the template’s inputs from the conversation and can hand the user the Download URL.
How the generate step waits
Section titled “How the generate step waits”Generate a document uses the polling pattern Microsoft’s workflow tools follow by themselves: the request is answered 202 Accepted with a link to poll, and the platform reads it every 5 seconds until the document is completed, then continues with the finished document. A document that fails makes the step fail, with the reason (a loop that is never closed, a picture that could not be fetched) in the step’s output. A failed document never reaches the next step as if it were a file: Get document status and Download document fail on it too (DOCUMENT_FAILED).
If you turn the step’s Asynchronous pattern setting off, it returns at once with the document still processing. Add Get document status with the Document ID: it waits for the document the same way. With that step’s asynchronous pattern turned off as well, it answers at once; wait yourself with Do until Status is not processing, containing Delay (5 seconds) and Get document status. A document that fails makes Get document status fail (422), so the loop stops on that error and never reads failed: handle it with Configure run after (has failed) on the next step, or put the loop in a Scope.
Limits
Section titled “Limits”- 60 requests a minute per template and 600 documents a minute per company, shared with the document API and the HTTP trigger; 60 template lists a minute per company; 60 status reads and 60 downloads a minute per document. Over a limit the step answers
429and the platform’s retry policy tries again. - Picture inputs must be public web addresses (
https://, orhttp://). A SharePoint or OneDrive link that needs a sign-in cannot be fetched; share the picture with a public link or host it elsewhere. - Documents are kept as long as your company keeps generated documents (set by your plan). Download the file in the same flow rather than storing the link.
- Sending a document for signature and attachments merged into a PDF are available through the document API, not as connector inputs.
Troubleshooting
Section titled “Troubleshooting”| What you see | Why |
|---|---|
The template list is empty or the connection fails with COMPANY_KEY_REQUIRED |
The connection uses a template’s own key; create one with a company API key |
| A placeholder has no input | The inputs come from the template’s last upload; upload the template again |
QUOTA_EXCEEDED |
No documents left this month; buy a pack or a seat |
The step fails with DOCUMENT_FAILED |
The document could not be made; the step’s output says why |
Download document fails with DOCUMENT_NOT_READY |
The generate step’s asynchronous pattern is off, so the document was still being made; add Get document status before the download |
Every other refusal is listed with its reason in the document API reference.