Automate Weekly Meal Planning with n8n and Mealie API

Save hours planning weekly family dinners by automating meal plan creation using n8n with the Mealie API. This workflow picks random recipes and schedules them efficiently to reduce decision fatigue.
scheduleTrigger
httpRequest
code
+3
Workflow Identifier: 1542
NODES in Use: Schedule Trigger, Set, HTTP Request, Code, Manual Trigger, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

Opening Problem Statement

Meet Sarah, a busy mom who juggles work, kids, and household duties. Every Friday evening, Sarah spends over an hour staring at recipe books and cooking apps, trying to piece together a family meal plan for the coming week. She often wastes time deciding what to cook, repeats the same meals, or ends up ordering takeout because she had no plan. This routine not only wastes her precious time but also makes grocery shopping inefficient and meal prep stressful. Sarah wishes she could automate this mundane task and get a fresh, varied meal plan every week without lifting a finger.

What This Automation Does

This n8n workflow connects with your Mealie meal management system API to automate weekly dinner planning. Once set up and triggered (either on schedule or manually), it:

  • Fetches up to 100 recipes from Mealie, optionally filtered by category to match dietary preferences or cuisine types.
  • Randomly selects a configurable number of recipes (default is 5) to create diverse and fresh meal plans.
  • Schedules each selected recipe as a “dinner” for consecutive days starting from a defined offset (default 3 days ahead).
  • Uses the Mealie API to create these meal plans automatically within your household account.
  • Can be triggered on a set weekly schedule (e.g., Fridays at 8 PM), ensuring you get your new meal plan right before the weekend.
  • Includes manual trigger options for on-demand plan generation and configuration flexibility.

This saves Sarah hours each week, eliminates repetitive menus, and helps her manage meals with less stress and more variety.

Prerequisites ⚙️

  • n8n Account: To build and run this workflow.
  • Mealie Meal Management API: Your self-hosted or cloud Mealie instance URL and API token.
  • HTTP Header Authentication Credential: Set up in n8n for your Mealie API token.

Step-by-Step Guide

Step 1: Create a Credential for Mealie API Access

In n8n, go to Credentials > New Credential > choose HTTP Header Auth. Enter your Mealie API token in the header as specified by Mealie (usually under “Authorization”). Save this credential named something like “Mealie Header Auth.” This credential will authenticate requests in the HTTP Request nodes.

Expected outcome: Your API requests will now be authorized.

Common mistake: Forgetting to apply this credential to the HTTP nodes causes authorization errors.

Step 2: Configure the Workflow Settings Node

Locate the Config node. Input these values:
mealieBaseUrl: Your Mealie instance URL, e.g., http://192.168.1.5:9925
numberOfRecipes: How many recipes to include in the meal plan (default 5).
offsetPlanDays: How many days from today to start the plan (default 3).
mealieCategoryId: (Optional) Recipe category ID to filter recipes. Leave blank to include all.

Expected outcome: These settings dynamically control recipe fetching and scheduling.

Common mistake: Typo in URLs or invalid category IDs will cause API fetch failures.

Step 3: Set Up the Schedule Trigger

Open the Friday 8pm node. This is a Schedule Trigger node set to run every Friday at 20:00 (8 PM). Adjust days/hours if you want a different schedule.
Trigger ensures your meal plan updates automatically weekly.

Expected outcome: Workflow auto-starts weekly without manual intervention.

Common mistake: Forgetting to activate the workflow means no auto-run.

Step 4: Manual Trigger for Testing

The node named When clicking “Test workflow” lets you run the flow manually anytime for debugging or quick plan creation.

Expected outcome: Immediate meal plan generation on demand.

Step 5: Fetch Recipes from Mealie API

The Get Recipes node is an HTTP Request node configured to GET recipes from Mealie using the base URL and category filter. Query parameters limit results to 100 per call.
You don’t need to change this unless your API endpoint changes.

Expected outcome: A list of recipe JSON objects is returned and passed to the next node.

Common mistake: Missing or wrong authentication credential here causes 401 errors.

Step 6: Randomly Pick Recipes with Code Node

The Generate Random Items node uses JavaScript code to randomly select recipes to compose the meal plan.

Code walkthrough:

const numberOfRecipes = $('Config').first().json.numberOfRecipes;
const offsetPlanDays = $('Config').first().json.offsetPlanDays;
const items = $input.first().json.items;

let planFirstDate = new Date();
planFirstDate.setDate(planFirstDate.getDate() + offsetPlanDays);

const recipeList = [];
const randomNums = [];
let currentItem = 0;

while (recipeList.length < numberOfRecipes) {
  const randomNum = Math.floor(Math.random() * Math.floor(items.length));

  if (!randomNums.includes(randomNum)) {
    const thisRecipe = items[randomNum];

    const newDate = new Date(planFirstDate);
    newDate.setDate(planFirstDate.getDate() + currentItem);
  
    const planDate = [
      newDate.getFullYear(),
      ('0' + (newDate.getMonth() + 1)).slice(-2),
      ('0' + newDate.getDate()).slice(-2)
    ].join('-');
  
    const planDay = {
      "date": planDate,
      "entryType": "dinner",
      "recipeId": thisRecipe.id,
      "name": thisRecipe.name
    };

    currentItem++;
    recipeList.push(planDay);
    randomNums.push(randomNum);
  }
}

return recipeList;

This code:

  • Grabs config values for number of recipes and start day offset
  • Randomly picks unique recipes from the fetched list
  • Assigns each a date starting offset days from today
  • Formats a meal plan list for creation

Expected outcome: A nicely formatted array of meal plan days with recipe ids and dates.

Step 7: Create Meal Plan via Mealie API

The Create Meal Plan node is an HTTP Request POST that sends the random recipe plan to Mealie’s meal plan endpoint, using your API credentials.

Expected outcome: New meal plan entries appear in your Mealie household account.

Common mistake: Misformatted JSON body or invalid API endpoint URL causes failure.

Customizations ✏️

  • Change Number of Recipes: In the Config node, modify the numberOfRecipes value to plan for fewer or more meals per week.
  • Adjust Start Date Offset: Change the offsetPlanDays to start meal planning immediately (0) or further ahead.
  • Use Different Recipe Categories: Update the mealieCategoryId in Config to target specific types of meals, such as vegetarian or desserts.
  • Change Schedule Timing: Modify the Friday 8pm schedule trigger node to run on your preferred day and time.
  • Add Notifications: Link a messaging node like Slack or Email after plan creation to get notified weekly of the new meal plan.

Troubleshooting 🔧

Problem: 401 Unauthorized when fetching recipes

Cause: API token not properly set or credential not linked in the HTTP Request nodes.

Solution: Open the Get Recipes and Create Meal Plan HTTP nodes, verify the Credentials tab has your Mealie Header Auth selected.

Problem: Meal plan not created or empty in Mealie

Cause: JSON body formatting issue or API URL error.

Solution: Check the Generate Random Items code node’s output. Use the n8n Debug panel to inspect the JSON sent to Create Meal Plan. Confirm the endpoint URL in Config is correct.

Pre-Production Checklist ✅

  • Verify Mealie API URL and token are correct and reachable.
  • Run manual trigger node to generate a sample meal plan and inspect results.
  • Confirm recipe category ID if filtering is used is valid.
  • Make sure the Friday 8pm schedule is activated if you want automatic weekly runs.
  • Backup your existing meal plans before first full run, in case of overwrite.

Deployment Guide

Once you have tested the workflow via the manual trigger and confirmed the results, activate the workflow in n8n by toggling the enable switch. This will allow the Friday 8pm schedule trigger to execute automatically every week.
Keep an eye on the n8n execution logs and workflow history to monitor successful runs and catch any errors early. Set up alerting or notifications if preferred for meal plan creation failures.

FAQs

Can I use a different meal planning app instead of Mealie?

This workflow is specifically designed for Mealie’s API. You would need to adapt the HTTP Request nodes and authentication for other apps with similar REST APIs.

Will this workflow use up API quota or tokens?

This workflow makes two API calls per run: one to fetch recipes and one to create meal plans. If your Mealie instance has limits, consider the schedule frequency accordingly.

Is my meal data secure?

Yes, n8n only transmits data between your configured credentials and Mealie. Ensure your API tokens are kept private and your n8n instance is secured.

Conclusion

By following this guide, you automated the weekly task of meal planning using n8n and your Mealie meal management system. Sarah now saves over an hour every Friday, enjoys varied dinners, and feels less stressed around meal prep.
Why stop here? You could add grocery list automation by integrating Mealie with Google Sheets or your favorite shopping app next, or create notifications to remind the family of the week’s plan.
This workflow illustrates the power of connecting APIs with automation tools like n8n to reclaim time and reduce daily hassles. Happy automating!

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free