Assistance Needed: Email to Task Automation with Zapier, JSON Parsing, and Google Tasks

Hey folks,

I’m stuck on an automation project. I’m trying to turn emails into Google Tasks using Zapier and ChatGPT. Here’s what I’m doing:

  1. Use ChatGPT to find tasks in emails
  2. Turn those tasks into JSON
  3. Parse the JSON with Code by Zapier
  4. Make Google Tasks from the parsed data

But I’m hitting a wall. The JSON parsing step keeps throwing errors like ‘Unexpected token’ or ‘Cannot read properties’. I think the data isn’t getting through right.

I’ve tried:

  • Sending data from Gmail to ChatGPT to Code by Zapier
  • Checking my keys and field mapping

What I need help with:

  • Parsing JSON correctly in Zapier
  • Finding the right key (currently using ‘inputData.json_input’)
  • Getting data from one step to the next

Has anyone done something like this before? Any tips on using Code by Zapier for JSON or connecting it to other steps?

Thanks for any help!

yo, i’ve messed with similar stuff. have u tried using zapier’s formatter step? it’s way easier than code for json. also, check ur chatgpt output - sometimes it adds weird stuff that breaks the json.

for keys, try logging the whole inputData object. might need to use inputData.json_input.body or somethin.

good luck man, json can be a real pain!

I’ve encountered similar issues with JSON parsing in Zapier. One trick that worked for me was using the ‘Utilities’ step to encode the JSON as base64 before passing it to the ‘Code’ step. This preserves the structure and avoids unexpected token errors.

For the key, try logging the entire inputData object as Ryan suggested. In my experience, it’s often nested differently than expected. You might need to use something like inputData.json_input.content or inputData.json_input.parsed_json.

Another approach is to use the ‘Path’ feature in Zapier to directly access nested JSON values without parsing. This can be more reliable for complex structures.

Regarding data flow between steps, consider using Zapier’s ‘Run JavaScript’ action instead of ‘Code by Zapier’. It offers more flexibility and better debugging options.

Don’t forget to validate your JSON output from ChatGPT. Sometimes it generates invalid JSON, which causes parsing issues down the line.

I’ve actually tackled a similar project recently, and I feel your pain with those JSON parsing errors. They can be incredibly frustrating!

One thing that really helped me was using Zapier’s ‘Formatter’ step before the ‘Code’ step. It has a ‘Parse JSON’ option that’s much more forgiving than the native JSON.parse() in JavaScript.

For the key issue, I found that Zapier sometimes adds extra nesting to the data. Try logging the entire inputData object to see its structure. You might need to use something like inputData.json_input.body or even inputData.json_input.json_input.

Also, double-check the output from ChatGPT. Sometimes it might include extra characters or formatting that breaks the JSON structure. You could try adding a cleanup step using regex to remove any non-JSON characters.

Lastly, for getting data between steps, I’ve had success using Zapier’s ‘Storage by Zapier’ app. It’s great for passing complex data between steps without worrying about field mapping issues.

Hope this helps! Let me know if you need any more specifics.