Meal Image Nutrition Analysis Webhook with OpenAI
Loading workflow…
Workflow Description
The workflow receives a POST request on a webhook carrying a base64 meal image, sends it to the OpenAI Vision model (chatgpt-4o-latest) with a detailed nutrition-analysis prompt, then re-formats the model output through an LLM chain (gpt-4o-mini) with a manual structured output parser and auto-fixing wrapper, and finally returns the parsed JSON to the calling app via a response node. The workflow is saved inactive and has no authentication on the webhook.
How it works
- 1.The meal_image_webhoook node accepts HTTP POST at path fb1795ae-7290-48be-8c52-27b50eb32691 with response deferred to the response node.
- 2.The analyze_image node sends the binary property image (base64) to chatgpt-4o-latest with instructions to identify foods, estimate portions, compute nutrition, and return a single JSON object.
- 3.The extract_results chain LLM node uses gpt-4o-mini to convert the analysis text into an object matching a manual JSON schema (mealName, calories, macros, sodium, confidenceScore, healthScore).
- 4.An Auto-fixing Output Parser wraps the Structured Output Parser to retry corrections when output does not match the schema, reusing gpt-4o-mini.
- 5.The respond_to_webhook node returns JSON.stringify($json.output) as the JSON response body.
Use cases
- Backend service for a calorie-tracking app (e.g., Lovable) that uploads meal photos and receives structured nutrition estimates.
- On-demand food-photo analysis endpoint for any frontend that POSTs a base64 image named image.
Requirements
- Valid OpenAI credentials configured for both the analyze_image node and the OpenAI Chat Model node.
- Incoming requests must include the image as binary data under the property name image.
- Manual activation of the workflow, since it is saved with active: false.
Setup and testing in n8n
- Activate the workflow, POST a food photo to the webhook URL with an image field, and confirm a JSON nutrition payload is returned.
- POST a non-food image and verify the response reports confidenceScore 0 and mealName Unidentifiable.
- Check execution logs to confirm the structured parser and auto-fixing step succeed on irregular model output.
Service Value
Ideal as a smart automation service combining integrations and AI to produce ready-to-use results.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (8)
analyze_image
OpenAI
meal_image_webhoook
Webhook
respond_to_webhook
Webhook
extract_results
LLM Chain
OpenAI Chat Model
OpenAI
Structured Output Parser
Output Parser Structured
Auto-fixing Output Parser
Output Parser Autofixing
Sticky Note
Sticky Note
Source and license
Sticky Note
Fresh workflows, straight to your inbox
Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.
- New workflows
- Clear overviews
- Setup guides