Most restaurant owners know their best-selling dishes by name, not by margin. They remember what customers order on busy Friday nights and what sits untouched on the Monday lunch menu. But intuition is a poor substitute for data, especially when supplier costs fluctuate weekly and competitors adjust prices daily. The result: menus that leave thousands of pounds on the table each year because pricing decisions are made in a vacuum, disconnected from actual sales velocity and ingredient costs. The good news is that building an automated system to analyse sales data, cross-reference supplier costs, and regenerate menu recommendations takes a weekend, not a consultant's retainer. By wiring together a data notebook, a recipe AI, a task management system, and a bit of orchestration glue, you can have weekly menu optimisation running entirely on its own. No manual exports, no spreadsheet juggling, no forgotten analyses. This workflow pulls your point-of-sale data, maps it against live supplier pricing, runs profitability calculations, and generates recipe tweaks with fresh costing, all without a human touching a file in between.
The Automated Workflow
We'll use n8n as the orchestration layer because it handles both scheduled triggers and HTTP requests well, plays nicely with Python, and doesn't require webhooks to be publicly exposed if you self-host. If you prefer a managed service, Zapier works too, though you'll pay more per task. The flow works like this: 1. Weekly trigger pulls sales data from your POS system (we'll assume Square, Toast, or similar with an API).
-
Data flows into a Deepnote notebook that calculates item-level profitability and identifies underperforming dishes.
-
Results are passed to Tastebuds AI to regenerate those recipes with cost-optimised ingredient swaps.
-
Payman AI handles any manual review tasks (e.g. chef approval of new recipes) without breaking automation.
-
A summary is compiled and emailed to ownership.
Step 1: Set up the n8n workflow trigger and POS connection.
Create a new n8n workflow with a Cron trigger set to run weekly on Monday morning at 06:00 UTC. Then add an HTTP Request node to fetch data from your POS API.
{ "workflow": { "name": "Menu Optimisation Weekly", "trigger": "cron", "schedule": "0 6 * * 1", "nodes": [ { "name": "Fetch POS Data", "type": "http", "method": "GET", "url": "https://api.square.com/v2/locations/{{ locationId }}/orders", "headers": { "Authorization": "Bearer {{ squareApiKey }}", "Square-Version": "2025-03-19" }, "params": { "begin_time": "{{ dateLastWeek }}", "end_time": "{{ dateToday }}" } } ] }
}
Adjust the endpoint URL and parameters for your POS system. Square, Toast, and most modern systems expose this data; you just need API credentials stored in n8n's credential manager.
Step 2: Transform POS data into a structured format for Deepnote.
Add a second node that normalises the POS response into JSON with the schema that Deepnote expects: item name, quantity sold, revenue, category, date. Use a code node in n8n or a simple JavaScript transformation.
{ "node": { "name": "Normalise POS Data", "type": "code", "language": "javascript", "code": "return items = $response.body.orders.map(order => {\n return order.line_items.map(item => ({\n name: item.name,\n quantity: item.quantity,\n revenue: item.gross_sales_money.amount / 100,\n category: item.catalog_object_id,\n date: order.created_at\n }))\n}).flat();" }
}
Step 3: Send data to Deepnote via webhook and trigger analysis.
Deepnote projects expose webhooks that can trigger notebook runs and pass parameters. Create a webhook trigger in Deepnote, then call it from n8n.
{ "node": { "name": "Trigger Deepnote Analysis", "type": "http", "method": "POST", "url": "https://deepnote.com/api/v1/projects/{{ deepnoteProjectId }}/notebooks/{{ notebookId }}/webhooks/{{ webhookId }}", "headers": { "Authorization": "Bearer {{ deepnoteApiKey }}", "Content-Type": "application/json" }, "body": { "sales_data": "{{ normalizedPosData }}", "supplier_costs": "{{ supplierCosts }}" } }
}
Inside your Deepnote notebook, add cells that: - Load the incoming sales data and supplier costs.
-
Calculate gross profit margin for each menu item: (revenue - COGS) / revenue.
-
Flag items with <20% margin as candidates for redesign.
-
Identify your top 10% revenue generators and bottom 10% performers. Use pandas for grouping and Plotly for visualisation. Export the results as JSON to a temporary file or write them to a shared bucket (S3, GCS).
python
import pandas as pd
import requests # Load incoming data from n8n
sales_data = pd.read_json(incoming_sales_json)
supplier_data = pd.read_json(incoming_suppliers_json) # Merge on item name
merged = sales_data.merge(supplier_data, on='name', how='left') # Calculate margin
merged['margin_percent'] = ( (merged['revenue'] - merged['cogs']) / merged['revenue'] * 100
).round(2) # Flag low-margin items
low_margin = merged[merged['margin_percent'] < 20].sort_values('margin_percent') # Write results for next step
output_json = low_margin[['name', 'revenue', 'cogs', 'margin_percent', 'quantity']].to_json()
Step 4: Call Tastebuds AI to regenerate recipes for flagged items.
For each low-margin dish, pass the current recipe and COGS to Tastebuds. Request ingredient substitutions that maintain flavour but reduce cost. Include cost targets and any dietary constraints. Since Tastebuds doesn't have a native API in most setups, call it via an HTTP wrapper or use Claude Opus 4.6 with a custom prompt if you don't have Tastebuds access; the prompt asks for recipe optimisation given cost and nutrition constraints.
{ "node": { "name": "Optimise Recipes", "type": "http", "method": "POST", "url": "https://tastebuds-api.example.com/v1/optimise-recipe", "headers": { "Authorization": "Bearer {{ tastebudsApiKey }}", "Content-Type": "application/json" }, "body": { "dish_name": "{{ item.name }}", "current_recipe": "{{ item.recipe }}", "current_cogs": "{{ item.cogs }}", "target_cogs": "{{ item.cogs * 0.85 }}", "nutrition_constraints": { "maintain_calories": true, "maintain_allergen_flags": true } } }
}
The response includes suggested ingredient swaps, new prep times, and revised COGS estimates. Store these suggestions.
Step 5: Route suggestions to Payman AI for chef approval.
Rather than forcing changes through unvetted, create a Payman task for each recipe change. Payman handles microtasks; set up a task asking your head chef to review and approve or reject each new recipe. Payman handles payments and keeps the workflow moving.
{ "node": { "name": "Create Review Tasks", "type": "http", "method": "POST", "url": "https://api.payman.ai/v1/tasks", "headers": { "Authorization": "Bearer {{ paymanApiKey }}", "Content-Type": "application/json" }, "body": { "title": "Review optimised recipe: {{ item.name }}", "description": "Current COGS: £{{ item.cogs }}. Suggested new ingredients reduce COGS to £{{ item.new_cogs }}. New recipe: {{ item.new_recipe }}. Approve or reject.", "reward": 10, "required_approvals": 1, "form_fields": [ { "name": "decision", "type": "select", "options": ["approve", "reject", "modify"] }, { "name": "notes", "type": "text" } ] } }
}
Step 6: Poll Payman for responses and update menu database.
Add a second n8n workflow that runs every 6 hours, checks Payman for completed tasks, and if decisions exist, updates your menu database (or exports a report for manual menu updates in your POS).
{ "node": { "name": "Fetch Payman Decisions", "type": "http", "method": "GET", "url": "https://api.payman.ai/v1/tasks?status=completed&workflow_id={{ workflowId }}", "headers": { "Authorization": "Bearer {{ paymanApiKey }}" } }
}
Parse the responses, collect approved recipes, and send an email to the POS manager with a formatted list of menu updates (new pricing, ingredient changes, removals).
Step 7: Generate and email the weekly report.
Use n8n's Email node or a service like SendGrid to compose a summary email containing: - Top 5 highest-margin items (to feature in marketing).
-
Bottom 5 lowest-margin items and recommended changes.
-
Total estimated margin uplift if all approved changes are implemented.
-
Chef approval status.
The Manual Alternative
If you don't want to automate the chef approval step, you can run this weekly yourself in 20 minutes. Set up the n8n workflow to stop after step 3 (Deepnote analysis). Every Monday, log into Deepnote, review the low-margin flagged items, manually check Tastebuds suggestions or ask your head chef via Slack, and update pricing in your POS. This removes Payman from the stack but keeps data collection and analysis automated.
Pro Tips
Handle POS API rate limits gracefully.
Most POS systems allow 300-600 requests per minute.
Your weekly pull should never hit this, but if you expand to daily runs, add exponential backoff in n8n's HTTP node: if you receive a 429 response, wait 30 seconds before retrying.
Store supplier cost data separately and refresh weekly.
Don't hardcode supplier prices into your Deepnote notebook. Maintain a Google Sheet or CSV in a bucket that your supplier uploads to or that you pull from their API. Deepnote can load this on each run, so cost changes are picked up automatically.
Account for seasonal swings in ingredient availability.
Tomato prices in January differ from July. If Tastebuds or Claude suggests a swap that's seasonal, flag it for chef review. Payman's task form can include a date range for when changes take effect.
Test the workflow with dummy data first.
Before connecting live POS data, run the entire flow with sample sales and supplier CSVs. Verify calculations in Deepnote are correct before you trust margin percentages.
Set margin thresholds by category.
Beverages often have higher margins than food. Use Deepnote to calculate category-specific thresholds rather than one global 20% rule. Update the threshold in n8n as a configurable variable.
Cost Breakdown
| Tool | Plan Needed | Monthly Cost | Notes |
|---|---|---|---|
| n8n | Cloud (self-hosting is free but requires DevOps) | £25–£100 | Depends on workflow complexity and execution count. 10,000 executions/month included in mid-tier plan. |
| Deepnote | Free tier or Student (paid tier £17–£150) | £0–£150 | Free tier sufficient for weekly runs on small datasets. Student plan includes better hardware. |
| Tastebuds AI | Varies (usage-based or subscription) | £20–£100 | Check their pricing; many offer pay-as-you-go. Estimate 10–20 recipe optimisations per week. |
| Payman AI | Task-based (£0.10–£1 per task depending on complexity) | £10–£50 | Depends on number of dishes reviewed. Budget £1 per dish review. |
| Email service (SendGrid, Mailgun, etc.) | Free or low-cost | £0–£20 | Included with n8n Cloud or separate. |
| POS API access | Already included in your POS subscription | £0 | No additional cost; uses existing API quota. |