Need help with Google Docs/Sheets generation from JSON

  • 6 December 2019
  • 6 replies

Userlevel 2

Hello Zapiers!

In our system we generate orders and we want to let to our customers to automatically generate few docs related to such orders. All docs has templates (customisable) and we need to fill different templates with dynamic data.

For example, we need to put {ORDER_NUMDER} {ORDER_DATE} {CLIENT_NAME} {ORDER_SUM} to different docs, like: contract, invoice and report. Contract is Google Doc, Invoice – Google sheet, and report is Google Doc too. Then we need to generate PDFs from this docs and email it all to few emails.

1. Is it possible to solve this complicated logic with Zapier?

2. How would you do that? (any advice or examples, if possible)

Thank you so much!

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +10

Hi @Arkadiy

Not too difficult at all - so long as the JSON data you're sending to Zapier is well formed.

You'd create a zap triggered by "Webhook->Catch Webhook"

Webhooks by Zapier Integrations | Connect Your Apps with Zapier

Then, you'd just have your system fire the JSON data to the unqiue webhook URL Zapier will give you. You'll then end up with all the different data fields you need to map. Both Google Docs and Google Sheets integrate with Zapier.

If you're new to Zapier, here is a good place to start when it comes to learning how to customize them:

Create Zaps

Hopefully that all makes sense. Let us know if you've got any followup questions.

Userlevel 7
Badge +10

Like @AndrewJDavison_Luhhu said this is fairly simple, but I will recommend using something like Formstack Documents (formerly called webmerge) to make the documents as it makes the template filling significantly easier. They also have an export/convert to PDF function at which point you can email it to whomever you choose.

Depending on the logic you need you might want to add paths so if x=blue send the documents to Fred and Lisa, otherwise if x=red send the documents to Sam and Julia. etc.

Userlevel 2

@PaulKortman why not Google Doc/Sheets? Formstack looks like is much expensive.

Userlevel 7
Badge +10

@Arkadiy I'm sorry to have confused, there's no real reason to go with Formstack, yes it does cost more. You should be able to do what you need to do by using a template within Google Documents.

Userlevel 5
Badge +1

So to add on to what was said above:

Catch the data via a Webhook or direct integration.

Each order will likely have it's own trigger event or webhook.

Format that data (if needed) using Formatter by Zapier, to ensure the outputs are human-readible.

Create a Google Doc Template in Google Docs, fill it with the appropriate variables, and then include a 'Create Google Document from Template' action in your Zap using Google Docs.

Fill each variable with the output from the Formatter or Webhooks by Zapier steps (if not formatted).

IMPORTANT - To get a PDF of these files, you must add in a GOOGLE DRIVE action after the Google Docs action. Here, you will specifically choose the 'Find File' option, searching for the file name from the previous step, in the folder where these documents are being created.

Now, you can then include a Gmail action where you are able to include an attachment. In this field, you will choose the file found from the GOOGLE DRIVE action (not Google Docs), specifically, the PDF (file) output.

You can also pull other file types like Docx, rtf, etc., but that is how you get the PDF file.

If you want, you can also take the variables from the first two steps (Webhooks/Formatter) and create a Google Sheet row at any time in this Zap. If you want to include a link to the Google Doc file though, include this step at the end.

Let me know if you have any questions on this! :)

Userlevel 7
Badge +9

Hey @Arkadiy, we just wanted to check in to see if any of the above solutions worked for you. Let us know!