Best answer

How to add data in output fields dynamically?

  • 29 July 2021
  • 1 reply
  • 2030 views

I am integrating my API with Zapier and I am faced with a trouble. I am sending data from API in this format:

{
"email": "player@domain.com",
"phoneNumber": "+380991234567",
"fullName": "John Doe",
"termsAccepted": true,
"extra": "{\"city\":\"New York\", \"hobby\":\"music\"}",
"campaignId": 1,
"createdAt": "2021-03-16T12:36:44.595Z",
"updatedAt": "2021-06-24T21:18:47.871Z"
}

Every time API send extra field with different structure. For next request data can be in another format:

{
"email": "player@domain.com",
"phoneNumber": "+380991234567",
"fullName": "John Doe",
"termsAccepted": true,
"extra": "{\"car\":\"Audi\", \"country\":\"USA\"}",
"campaignId": 1,
"createdAt": "2021-03-16T12:36:44.595Z",
"updatedAt": "2021-06-24T21:18:47.871Z"
}

For the trigger, I added user input data to choose the fields to process from the extra field, but I don't understand how to dynamically add this data to the sample data and output fields so that the user has access to it when the ZAP is created.

 

I would be grateful for any help

 

icon

Best answer by Zane 31 July 2021, 02:02

View original

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

1 reply

Userlevel 7
Badge +9

Firstly: The input fields you are defining in the trigger - are those needed to create/configure the trigger? Are they, say, filters, say, the workflow will only trigger for leads with name x or address y? Or are you trying to allow the user to create a Lead with that data? I suspect what you want here is an Action, rather than a Trigger.

Next: The static sample data field must only contain fields that will be there for every single API response, from any user using your API. A principal use of static sample is for building “Zap Templates” which you’ll encounter a little later in your partner journey, but these are like Zaps you set up to share publicly and any field mapping or configuration you make has to work for everyone. TLDR, don’t include custom/user defined fields in the static sample. 

How does a user get to map the content from those special fields into subsequent action steps? When a user is setting up a Zap the Zap editor will call your API and will fetch that user’s real data for them to map into the next step. 

How does a user get to map data into one of these special, user specific, fields? Generally this is done by using a “dynamic” field. Create a Javascript function to call an API endpoint to get a list of the user defined “extra” fields for this user and dynamically generate input field objects for the Zapier editor to render.  https://platform.zapier.com/docs/input-designer#how-to-add-dynamic-and-custom-fields

My advice is to get the static stuff working first, also make sure you have a solid understanding of how a Zap works, identify your use cases for triggers, your use cases for actions - and then finish up with adding support for dynamically created fields.