Getting startedSet up the Generate document action in Shopify Flow

Set up the Generate document action in Shopify Flow

Copy page

Connect a template to a Shopify Flow workflow: the trigger, the Generate document action, the template name and language, and the download link it returns.

The Generate document action renders one of your templates as a PDF whenever a workflow runs, and gives the workflow a download link for the next steps. This walkthrough connects a template to a workflow, end to end. The example generates an invoice when an order is paid.

You need a saved template first. See Create your first template.

Step 1: Choose a trigger

In your Shopify admin, open Flow, select Create workflow, then Select a trigger. This example uses Order paid.

The trigger decides which templates fit: a template that renders an order needs a workflow that has an order, a product template needs a product, and a customer template needs a customer.

Step 2: Add the Generate document action

Select the + under the trigger, choose Action, then Workflow Documents, and select Generate document.

Step 3: Fill the fields

Field What to enter
Order, product or customer The one the document is about. A trigger that has it fills it for you. The template decides which of the three it needs, the other two can stay empty
Template name The exact name of a template in Workflow Documents, for example Invoice. Upper and lower case matter
Language Optional. A language code such as de, or a variable that holds one. Leave it empty to use the customer's language

For Language, the order's customer locale is the usual choice:

css
{{order.customerLocale}}

When the field is empty, the app uses the language of the order's customer (or of the customer, for a customer template) when the template has it, else the template's main language. See Templates in several languages.

Step 4: Use the result in the next step

Add the step that should receive the document, for example an email action. The Generate document step offers these values in Flow's variable picker:

Field What it holds
url Download link to the PDF, valid for 7 days
filename File name of the PDF
expiresAt When the download link stops working
sizeBytes Size of the PDF in bytes
documentId The id of this document in Workflow Documents

Insert url into the body of an email or the payload of a request. See Example workflows for complete workflows.

Step 5: Turn it on and run it for real

Name the workflow and select Turn on workflow. Then trigger it, here by paying a test order.

Open Documents in Workflow Documents. The document appears with the source Shopify Flow and the status Generated, and you can download the PDF from there.

When the action fails

A failed step shows its reason in Flow's run details. A document that failed while it was being generated, for example because of missing data in Shopify, is also listed as Failed in Documents with the same message. A step that was refused before generating, such as an unknown template name or a used-up allowance, only shows in Flow. Common causes:

No template named "..." in Workflow Documents

The Template name does not match a template. Check the spelling, including upper and lower case and spaces. If you renamed the template, enter the new name.

The template "..." is turned off in Workflow Documents

Open the template, go to the Settings tab and select Template is on.

The template renders an order, but this workflow passes no order

The template needs an order, a product or a customer that the workflow does not provide. Use a trigger that has it, or fill the matching field of the action. For example, an invoice template cannot run in a workflow that starts from a product trigger.

The plan's documents for the last 30 days are used up

You reached your plan's allowance. Documents are generated again when the rolling 30-day window frees up, or right away after you change to a larger plan. See Plans and pricing.

The order was not found

The order no longer exists, or it is older than the orders the app can read. See Troubleshooting.

This account has been suspended

Contact support.

A failed document does not count toward your plan.

Retries do not generate twice

When something temporary goes wrong, for example Shopify does not answer in time, the action reports a temporary failure and Flow retries it by itself. If Flow retries a step that already succeeded, the app returns the earlier result instead of generating a second document, so it is not counted twice. A new trigger is a new document.

Next steps