icon

Table of Contents

How to Create Payload Data for Basic, Complex Data and Line items For CraftMyPDF Integrations(Zapier & Make.com)

1. Introduction

CraftMyPDF offers an advanced drag-and-drop editor and we empower businesses and individuals to automate document generation with no-code platforms like Make.com(Formerly Integromat) and Zapier.


To generate PDF or image content, you’ll first need to create the payload data on the no-code platform. We support three types of payloads, so you can choose the one that best suits your needs.

2. Three Ways to Create Payload Data

Our integrations for Make.com and Zapier support 3 types of Payload Types. The payload types are:

  • Schema of Data: Create payload data with the schema of sample data(The sample data in Data tab in the template editor). This is the simplest way to create payload data, it also handles nested objects and arrays. It’s recommended to use for most cases.
  • JSON Data: For complex data, it includes the basic data types — strings, numbers, arrays, booleans, and other objects. JSON data can contain objects and arrays.
  • Dictionary: A dictionary is an ideal data structure for storing simple key-value pairs. If your payload data is just a list of simple key-value pairs, then a dictionary is the perfect data structure to use.

In this tutorial, we are going to explore the ways to handle payload data including complex data(line items, or arrays) with Dictionary, Schema of Data, and JSON Data for Make.com and Zapier.

The following is the comparison of all the supported payload types:

Schema of Data**JSON DataDictionary
When to useRecommended to use for most casesWhen you have highly complex dataIf you have only key-value-pair data which is all string
Easy-to-useEasy to use, types and fields are auto-generated from the sample dataHard to useEasy to use
Handle line Items/Nested itemsYes*YesNo
Handle types such as number, boolean etcYes, types are generated from the sample dataYes, you define the types and dataNo, only string type is supported for the dictionary payload type
FlexibilityMediumVery FlexibleNot Flexible

* Zapier only supports 1-level nested line items

** Schema of Data option is pending on Make.com

3. Payload Types for Make.com Integration

Option 1: Use Schema of Data

Schema of Data option reads the schema data of your sample data and automatically populates the input fields.

The followings are the steps to use the payload type Schema of Data

i. Data Tab in the template editor

If you select Schema of Data for the Payload Type for the action on Make.com, please make sure the Data tab in the template editor is populated with sample data. The schema of the sample data will be used to generate the input fields for your Make action. Here’s what the Data tab looks like in the template editor:

ii. Select “Schema of Data”

Select the Schema of Data option in the action when creating your PDF and input fields such as the Order Number, Order Date, and items will be automatically displayed.

Option 2: Use JSON Data

Transforming data from Google Spreadsheet or Airtable is easy with Array Aggregator and JSON module, the following section is a step-by-step guide to creating JSON strings from Google sheets.

i. Prepare Google Spreadsheet data

In this section, we are going to use a Google Spreadsheet for the data source. You may use other data sources like Airtable. The following is the Google Spreadsheet:

ii. Add & Configure Google Sheets App

Firstly create a new Scenario in Make.com. You may use any triggers or leave it.

Then, create a new action by searching for Google Sheets module and use the Search Rows action.

Next is to configure the action by connecting the action to your google account, choose your SpreadSheet and select the Sheet.

iii. Configure JSON module

Next, create a subsequent action and search, add the JSON app

Select Create JSON module

Next is to configure the Create JSON module. Firstly click on the Add button. It brings up a dialog and name your data structure as Line items and click on Generate

Paste the JSON (You can copy the JSON from the CraftMyPDF Data tab in the template editor) and click on the Generate button. Close all the dialogues and save all the settings.

iv. Add an Array Aggregator

Now we need to add an Array Aggregator between Google Sheets and JSON module as the arrow shown below:

To do so, click on the Tools icon and select Array aggregator

Arrange the Array aggregator to be in between Google Sheets and JSON

Then, configure the Array aggregator. Select items for the Target structure type

Map all fields of the Google spreadshets to the items as follows.

v. Map the List Items Array to the JSON

Now, go back to the Create JSON module and map the field by toggling the Map button. Then select Array[] of Array aggregator. Press the OK button to save the settings.

You may now run the scenario to look at the JSON string

vi. Configure CraftMyPDF app

Search for CraftMyPDF app and select the Generate PDF module

Step i. Configure the connection, the API Key can be obtained from the CraftMyPDF API Integration tab.

Step ii. Select JSON(Complex Dynamic Data) as the Payload Type

Step iii. Select JSON string from the Create JSON module

Step iv. Select a Template ID

Now, run the scenario to generate a PDF.

Option 3: Use of Dictionary

If you’re looking for a simple way to create payload data, a dictionary is a great option. It’s just a collection of key-value pairs, so each key is associated with a value. This is perfect if your data is just a list of simple key-value pairs.

If your payload data is just a collection of key-value pairs like the following:

Dictionary payload type(1) can be used to represent these simple key-value pairs(2) in the action.

4. Payload Types for Zapier Integration

Option 1: Use Schema of Data

Schema of Data option reads the schema data of your sample data and automatically populates the input fields.

The followings are the steps to use the payload type Schema of Data

i. Data Tab in the template editor

If Schema of Data is selected for the Payload Type in the action on Zapier, please ensure the Data tab in the template editor is populated with sample data. The schema of the sample data will be used to build the input fields for your Zapier action.

The following is the Data tab in the template editor.

ii. Select “Schema of Data”

The following is a Create PDF action of CraftMyPDF in a Zap and Schema of Data is selected. The input fields such as Order Number, Order Date, items and other input fields will be automatically shown.

In the screenshot above, section 2 is a section for line items. To learn more about Line Items click here.

** Note: If you want to refresh the schema(or input fields), change the Payload Type to another type then change it back to Schema of Data again.

Option 2: Use JSON Data

The following section is to make use of Code by Zapier to create a JSON string for CraftMyPDF integration.

i. Setup Trigger

Setup the trigger, you may use any triggers that you find appropriate.

ii. Add and Setup Google Sheets

Next is to create a new action. Search for Google Sheets for the app and select Get Many Spreadsheet Rows(Advanced, With Line Item Support)

iii. Create a Setup Code by Zapier

Create a new action, look for Code by Zapier, and select Run Javascript for the event.

In the Input Data, enter all the keys, it includes the rows, invoice number, and currency. For the rows key, select Raw Rows of the Google Sheets

Enter the code snippet into the Code

let objs = JSON.parse(inputData.rows);
let items = [];

objs.forEach((obj)=>{
  items.push({
    "description": obj[0],
    "quantity": parseFloat(obj[1]),
    "unit_price": parseFloat(obj[2]),
    "total": parseFloat(obj[3]),
  });
});

let result = {
    "invoice_number": inputData.invoice_number,
    "currency": inputData.currency,
    "items":items
}

output = {"json" : JSON.stringify(result), "count": objs.length};

iv. Create a CraftMyPDF Action

Create a new action, Select CraftMyPDF.com for the app and Create PDF for the event.

In the Set up action

(i) Select a template

(ii) For the Payload Type select JSON

(iii) For JSON Payload, select the JSON string generated by the Zapier by Code

Option 3. Use of Dictionary

A dictionary is a great way to create simple key-value-pair payload data. Use this if your payload data is just a list of simple key-value pairs.

The following a collection of key-value pairs in Data tab:

Dictionary payload type can be used to represent these simple key-value pairs in the Zap.

Recent Posts
blog

How to generate PDF documents with PHP

There are various libraries available to generate PDF documents with PHP such as FPDF, TCPDF, or DOMPDF. These libraries provide a wide range of features for creating PDF documents, such as setting page size, margins, fonts, and images.

In this article, I would briefly discuss some of these libraries along with some code snippets and show you how to generate a PDF document using PHP and CraftMyPDF.

Read More »
blog

5 Ways to generate PDFs with C#

In this article, we will cover different options available, including using libraries such as iTextSharp and PdfSharp, cloud-based APIs such as CraftMyPDF, built-in classes in the .NET Framework like the PrintDocument class, and the Microsoft Office Interop library.

Read More »
blog

How to Generate PDF Invoices with Zapier

With PDF invoices, it’s easier to send invoices directly to clients without needing paper copies.

In this article, I would be showing you how to generate PDF invoices with Zapier and also help you understand the benefits of doing this. Let’s get to it!

Read More »
blog

Best-performing Banner Ads Sizes in 2023

Choosing the most appropriate banner for your company isn’t always easy. There are lots of things to consider such as the color, size, type of banner, and so on. This could be a little problematic if you have no knowledge of the different types of banner ads but don’t worry, that’s why I’m here.

Read More »
blog

How to create PDF invoices with Bubble.io

In this tutorial, we will create line items for an invoice template.

The takeaway of the tutorial is to build JSON with our Bubble plugin actions Thing(s) to JSON and Build JSON for complex JSON that consists of line items(an array). Then, the JSON will be used for generating the dynamic PDF documents.

Read More »
Copyright ©2024 CraftMyPDF.com

Email us at [email protected] for support