Generating a Document using Zapier

PDFMonkey on Zapier

The PDFMonkey Zapier integration provides a Document Generated trigger, a Generate Document action and a Find Document action. This recipe will leverage the Generate Document action.

Our sample use-case

You can generate a Document based on pretty much any trigger in Zapier. To illustrate a common use-case we will use the WooCommerce New Order trigger, generate a Document using the order data and finally send the generated Document as attachment in an email.

Let’s dive in!

The trigger

We’ll start by creating a Zap named Woo to PDFMonkey to Email and use the WooCommerce New Order trigger.

Generating the Document

The next step in our workflow is to generate a Document using data from the order. Add the PDFMonkey Generate Document action.

Zapier will ask you to authenticate your PDFMonkey account. You can do so by filling in your private key (you can find it the Account page in the Dashboard).

Once authenticated you’ll be able to select the App and Template to use.

In the Dynamic Data (JSON Payload) field, map the data of the order to the name you will use in your Document Template.

Be careful to surround data coming from the order with double quotes, otherwise the payload will be invalid.

Optionally you can set additional data on your Document. You can use the special _filename one to specify the name of the generated Document file:

Sending the Document by email

Once the Document is generated you have access to a URL that will be valid for 30s. You can use this URL to retreive the Document and attach it to an email.

You can also use this URL to store the Document in your Dropbox (our Drobox guide) or Drive (our Drive guide).

Select the Send Outbound Email action and fill in the details of the email you want to send.

In the Attachment field, use the Download URL (valid for 30s) property of the generated Document. This will ensure that the Document is downloaded and attached to the email.

Fill in any additional field you want to customize.

Conclusion

You can now save your Zap and turn in on.

This is an example use-case demonstrating how to generate a Document but also how to plug other actions afterward. You can connect PDFMonkey with pretty much any service available on Zapier. Have fun with it and let us know what you’ve built!

Troubleshooting

I’m getting a 422 response when creating a Document

This issue can happen for multiple variants of the same issue: an invalid JSON payload.

The most frequent case is a bad formatting of the payload, make sure it looks like this:

{
  "someKey": "[DYNAMIC DATA FROM ZAPIER]",
  "otherKey": "[DYNAMIC DATA FROM ZAPIER]"
}

Notice the quotes around the dynamic data coming from Zapier. The content is a single JSON Object, not an Array, not a series of Objects.

Another reason can be the presence of line breaks in dynamic data you’re using. For instance a multiline comment on the order or something similar.

For this case you will need to escape those line breaks using a Formatter by Zapier > Text action to Replace any instance of \n with nothing. Once that’s done, use its output as dynamic data.

I cannot use the 30s URL in my email

That’s on purpose. PDFMonkey doesn’t aim at being a storage service and that’s the reason we set an expiration limit of 30s.

If you need to send a link instead of an attachment, consider storing the file in your own Dropbox (our Dropbox guide), Drive (our Drive guide) or S3 and then get a shareable URL that you can send by email.