Receive json via webhook, iterate objects and send a recap mail well formatted

  • 31 October 2023
  • 4 replies

Userlevel 1


I need to implement a Beckend Zapier with webhooks.

Webhooks must receive a complex json object, composed of arrays of objects.

I need to create a summary email to send to the customer.

How can I loop the json objects to correctly format the email?

I attach an example of json I need to format.

Example of mail output:

“Dear #nome1#,
here the recap of your subscription.

Plan 1: #type1#
Sports: #sport1#, #sport2#
upgrade: #upgrade1#, #upgrade3#
services: #service2#, #service4#
Name: #name1#
Price: 149 $

Plan 2: #type2#
Sports: #sport2#, #sport4#
upgrade: #upgrade1#, #upgrade4#
services: #service2#, #service4#
Name: #name2#
Price: 100 $

Your total amount: 249 $”

It is possible with zapier?

Thank you very much

"name": "Name1",
"phone": "3478562341",
"mail": "",
"totalprice": 249,
"member": [

"name": "Name1",
"plan": {
"type": "type 1",
"sport": ["sport1", "sport2"],
"upgrade": ["upgrade1", "upgrade3"],
"services": ["service2", "service4"],
"price": 149
"name": "Name2",
"plan": {
"type": "type 2",
"sport": ["sport2", "sport4"],
"upgrade": ["upgrade1", "upgrade4"],
"services": ["service2", "service4"],
"price": 100


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

4 replies

Userlevel 3
Badge +2

Yes, you can process this JSON structure in Zapier to format the email as described. Here's a step-by-step process to help you achieve this:

  1. Webhooks by Zapier: Use this to trigger your Zap whenever your endpoint receives the described JSON payload.

  2. Code by Zapier: Use this action to parse the JSON and loop through the member array to create a formatted string for the email body. Here's an example of Python code you could use for this action:

data = input_data['json_payload']  # assuming you named the incoming webhook data 'json_payload'

email_content = "Dear {},".format(data['name'])
email_content += "\nhere the recap of your subscription.\n"

for index, member in enumerate(data['member']):
    email_content += "\nPlan {}:".format(index + 1)
    email_content += "\nType: {}".format(member['plan']['type'])
    email_content += "\nSports: {}".format(', '.join(member['plan']['sport']))
    email_content += "\nupgrade: {}".format(', '.join(member['plan']['upgrade']))
    email_content += "\nservices: {}".format(', '.join(member['plan']['services']))
    email_content += "\nName: {}".format(member['name'])
    email_content += "\nPrice: {} $\n".format(member['plan']['price'])

email_content += "\nYour total amount: {} $".format(data['totalprice'])

return {'email_body': email_content}

Further you can any email service to send the email or simply use Email by Zapier to send your emails

Userlevel 1

Thanks @communitymember , in the nexts weeks I will try your solution.

Thank you for your suggestions.



Userlevel 1

Hi @communitymember ,

i’m trying to use your script, but “code by zapier” don’t allow to map the whole json object,
I can map only the properties.

How can I loop the array object in this case?


Thank you

Userlevel 1

ok, I solved it by using “catch row hook” instead of “catch hook” by zapier.

Thank you 😊