Integromat (https://integromat.com) is a powerful tool to connect apps and automate workflows.
In the example below we will create an Integromat Scenario that watches a Google Sheet for a new row of data and then sends the data from that row to Docmosis to generate a letter. As a final step we will store the generated letter as a PDF in Google Drive.
It should be noted however that Integromat offers many ways to collect data that could be used to trigger the document generation process and the output document could be a PDF/DOCX/ODT/TXT file that can be stored to many different locations.
You will need
If you don't have one already you will need to create a Free Integromat account to get you started.
Start by creating a Scenario with the data source and file destination of your choice. In this case we will use Google Sheets and Google Drive. Also include the HTTP Service as this will be used to connect to Docmosis.
Docmosis Cloud Account
If you don't already have a Docmosis Cloud account, you can sign up for a free trial here.
Once you have an account you should login to the Docmosis Cloud Console.
Note: In this example we are using the AU region for storing templates and generating the document, but you could choose EU or US as needed.
Let's Get Started
Step 1: Upload the Template to your Docmosis Cloud Account
1.A) In the Docmosis Cloud account we created a top-level folder called "Integromat".
1.B) Then we uploaded a letter template that looked like this:
Step 2: Locate your Docmosis Cloud access key and URL
Navigate to the Account page in your Docmosis Cloud account. You will need the access key and URL when setting up the HTTP call to Docmosis.
Note: If your Docmosis processing location is EU or US, use the corresponding region's URL.
Step 3: Create a Google Sheet and Google Drive folder
3.A) Create a Google Sheet with a heading row to hold your data. Ours looked like this:
3.B) We also created a folder in Google Drive where we will store the generated documents:
Step 4: Configure the Integromat Scenario.
4.A) Connect the "Google Sheets (Watch Rows)" service to the Google Sheet you created at step 3A above :
4.B) Connect the HTTP Service to Docmosis:
Note: Use the URL from Step 2 above and add the "/renderForm" endpoint. Set Method to POST and Body type as shown here:
4.C) Configure the fields. This is one of the most important steps to get right:
Note: The spelling/case of every Key is important. For example: "accessKey" starts with a lower case "a" and uppercase "K". The first three fields are required. The other fields should have Keys that exactly match the fields in the template... eg: the key "firstName" also has a matching <<firstName>> field in the template. The Value of "firstName" is being mapped to the corresponding column in the Google Sheet, in this case Column (B).
Note: Set the "templateName" to the name of the template file from step 1.B. It should include the name of the Folder as well as the full file name with the ".docx" extension:
4.D) Configure the Google Drive service:
Note: We are using the folder we created in Step 3B above. The File Name is going to be generated using some data from the Google Sheet... plus we have added a ".PDF" extension. The "Data" is mapped on to the output from the HTTP call to Docmosis.
Step 5: Run the Integromat Scenario.
The Image below loops as follows:
A. The data in the Google Sheet is shown first.
B. The Google Drive is empty.
C. Set the Google Sheets connection to "Choose Where to Start" to "All". (This step is important when you are testing so you can use the first row again and again.)
D. Click on "Run once".
E. The data is extracted from the Google Sheet, sent to Docmosis via HTTP, and the file stored on Google Drive.
F. The PDF letter appears in the Google Drive, and contains the data from the Sheet.
Step 6: Debugging.
6.A) Following the Run you can inspect the Data from each step:
6.A) If things aren't working as expected you can add a "storeTo" field to the HTTP step as follows:
Note: The "storeTo" should contain two items: Firstly... "stream", this will ensure the generated document is returned to Integromat so it can be sent to Google Drive. Then a semi-colon ";". Secondly... "mailto:" followed by your email address. If you are still on a Docmosis Free Trial the email should match the email you used to create your Docmosis Cloud account. By adding this the document will be emailed to you as well as stored to Google. It can help determine where the process may be failing.
That’s it - you're Finished!
Of course, the primary purpose of Integromat is to automate these processes. So once you are happy with your Scenario you should turn ON scheduling. Then, each time a new row appears in the Google Sheet, a new PDF letter will automatically be generated.