Simplify your recipe collection with ChatGPT and N8N

Simplify the chaos of online recipe collection with ChatGPT. Create a clean, easy-to-read format including nutritional and weight information by setting up an N8N workflow.


Sat Jul 01 2023 - 5 min read
chatgptautomation

Like everyone else on this planet I've been trying to get ChatGPT to optimise things. One of the things that I like to do is collect recipes from all over the internet and then not try cooking them. I like having them though so I like for this process to be efficient. It has of course been written many times about how recipes on the internet are hard to read these days. They all start with a long anecdote about how the person discovered this kind of pizza from their grandpa who used to work for NASA. Then you get to the actual recipe ands everything is in weird formatting and bad units like cups. I want my recipes to have weights so that I can use the kitchen scale that I overpaid for. I also want to have nutritional information, portion size, and some kind of beverage pairing option if possible.

I use Notion to store my recipes and I would like for them to look good on the greasy Ipad.

So what if we just use ChatGPT to get rid of all the anecdotes and then transform the recipe into something that I can actually read?

So take this:

And turn it into this:

This way I can add my own rambling anecdote about a trip to Israel.
Optional: Have ChatGPT write the anecdote for me as well.


Isn't this nice? It's clean, the cooking guide is easy to read, it has weights and proper numbers for everything, and a portion guide. OK 215 kcal and some avocado slices is perhaps not enough for most adults, but it's still better! Perhaps ChatGPT has not invented bread yet.

Turns out that this is pretty easy to do with ChatGPT. All you need is a good prompt and some patience. Here's the one I use:

Take a recipe and extract the ingredients in a table.
Each row should contain the name, amount, weight in grams, kcal, protein, carbs, and fat
Data should be for the entire amount and not per 100g or per serving.
Also add a row at the end with the sum of the entire recipe.
If there is no weight listed then calculate it from the ingredient and amount.
Make it short and don't add explanations. If there are natural sections in the recipe then add a table for each section and a header to explain what it is. Add a header at the top with the name of the recipe.
If the recipe is not in English then translate it to English. Do not keep the other language
The ingredients should also be translated.
Add a step-by-step cooking guide below the ingredients table.
Also add a reasonable portion of this and the nutritional value of said portion.
If you have a serving suggestion then add that as well to the portion table.
At the end add a alcoholic beverage pairing. Add both beer and wine suggestions if available. Only add this for non-breakfast foods

This is perhaps not optimal but it seems to get the job done. Post that into the ChatGPT and then copy-paste the recipe body into that. It should spit out something reasonable. You can then simply ask it to make adjustments like "portion size should be 1/6 of the recipe, not 1/4" or "please remove the cyanide from the ingredients list; you can't fool me!".

Now let's turn up the lazy a few more notches, shall we? An N8N workflow can automate this further. Add an HTTP Request Node to fetch the data and then an HTML Node to parse the body. Then simply feed this into ChatGPT using an OpenAI node. You can of course use your low-code framework of choice. I like N8N so that is what I use.

If you need a cheap and solid server to run N8N on then feel free to use my referral code to get €20 in credit at Hetzner. Read my review for more information.

Ok! Now we have a workflow in N8N that can be started using a webhook. It will grab the supplied URL and extract/format the recipe as above. Why stop here though? I added another OpenAI node to write a nice name for the recipe and a custom Node using readability to extract an image to use for the recipe. I then used martian to turn the markdown into Notion blocks for formatting. Finally I added another HTTP Request Node to save the recipe to Notion. (The request you have to do is too custom to use the N8N Notion node). Now I have a fully automated workflow that takes a URL and saves the formatted recipe to my recipe bank in Notion. The finished workflow looks like this:

Now all I needed was a way to trigger this webhook with a URL in my browser. I wanted to browse recipes and then click something to save them. This turned out to be a hassle. I couldn't find something simple that took the current URL and posted it to a defined webhook. I ended up using the Zapier Chrome extension to trigger a Zapier workflow that triggered the N8N workflow. Surely there must a simpler way? It does work though so I'm content.

And there we have it. A complete way to create a recipe bank in Notion using N8N and the ChatGPT API. Large language models solved another problem for me!

Get awesome stuff in your Inbox

I care about the protection of your data. Read my  Privacy Policy.