通过Gmail、表单和AI聊天模型的自动化食谱助手
这是一个Personal Productivity, Multimodal AI领域的自动化工作流,包含 10 个节点。主要使用 Code, Gmail, FormTrigger, GmailTrigger, Agent 等节点。 使用Ollama和Llama 3.2根据Gmail和表单请求生成食谱
- •Google 账号和 Gmail API 凭证
{
"id": "xgtoa8r5NBx43ldC",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "通过 Gmail、表单和 AI 聊天模型的自动化食谱助手",
"tags": [],
"nodes": [
{
"id": "2825d5b3-bc93-4c3f-979b-9f4db3ed4198",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
-180
],
"parameters": {
"height": 540,
"content": "当用户发送 Gmail 或提交包含食谱请求的表单时启动"
},
"typeVersion": 1
},
{
"id": "a7b23e86-2fc1-4591-bf52-99aa637aef1c",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
220,
-180
],
"parameters": {
"color": 3,
"width": 280,
"height": 620,
"content": "理解用户查询并生成食谱"
},
"typeVersion": 1
},
{
"id": "4e8e32c7-f6bc-4810-b390-f5e28ee7df74",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
540,
-180
],
"parameters": {
"color": 5,
"width": 180,
"height": 520,
"content": "格式化食谱(例如:食材、步骤)"
},
"typeVersion": 1
},
{
"id": "503dd57d-ea7c-425d-a12c-8c7ff01d68c2",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
760,
-180
],
"parameters": {
"color": 4,
"width": 200,
"height": 520,
"content": "将格式化后的食谱发送回用户"
},
"typeVersion": 1
},
{
"id": "cc323bc4-2d4a-4ffc-9c03-b660309676ff",
"name": "食谱请求 - Gmail",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
0,
0
],
"parameters": {
"filters": {},
"pollTimes": {
"item": [
{
"mode": "everyX",
"unit": "minutes"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "PcTqvGU9uCunfltE",
"name": "Gmail account - test"
}
},
"typeVersion": 1.2
},
{
"id": "39138c17-7dd2-4d25-acdb-093ac7241c68",
"name": "食谱请求 - 网页表单",
"type": "n8n-nodes-base.formTrigger",
"position": [
0,
200
],
"webhookId": "c050d793-62e8-4b33-a824-99226b2ad004",
"parameters": {
"options": {},
"formTitle": "🍳 Ask the AI Chef!",
"formFields": {
"values": [
{
"fieldLabel": "Hey Dude, Tell Me fast.",
"placeholder": "\"What is a pizza recipe?\",\"How do I make butter chicken?\"",
"requiredField": true
}
]
},
"formDescription": "✨ Type any food name, ingredient, or dish, and our AI Chef will give you the perfect recipe in seconds!"
},
"typeVersion": 2.2
},
{
"id": "077be9f8-16cf-4c0e-9564-b4f4ffd51b7f",
"name": "Ollama 食谱生成器",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
220,
100
],
"parameters": {
"text": "=You are a vibrant and professional chef AI tasked with creating a delicious, visually appealing recipe based on user inputs. The user has provided:\n\nQuestion: {{ $json.snippet }}\nIngredients: [Insert ingredients from form submission]\nRecipe Details: [Insert recipe details, e.g., dish name, cuisine type, dietary preferences]\nSpecial Add-Ons: [Insert special add-ons, e.g., garnishes, sauces, or twists]\n\nYour task is to:\n\nCreate a complete recipe using the provided ingredients and special add-ons.\n\nAlign the recipe with the recipe details (e.g., cuisine, dietary preferences).\n\nGenerate a catchy, descriptive title for the dish.\n\nList all ingredients with estimated quantities. Write each on a new line with no symbols or formatting characters (do not use *, -, #, or any bullet points — just plain text).\n\nProvide clear, step-by-step cooking instructions written for a beginner cook. Use numbered steps only (e.g., 1, 2, 3) with no other symbols before or after the numbers.\n\nIncorporate the special add-ons creatively, such as in garnishes, sauces, or flavor twists, listed clearly without any symbols or formatting characters.\n\nSuggest one side dish or pairing to complement the recipe with a short description.\n\nUse emojis to make the output fun and engaging (e.g., 🍕 for pizza, 🔥 for spicy, 🥗 for sides), but do not overuse them.\n\nFormat the output in Markdown using the structure below. Do not use bold (`**`) or heading (`#`) symbols anywhere in the output. Instead, write section titles in uppercase letters only.\n\nEnsure the output is concise, professional, and visually appealing with thoughtful emoji use.\n\nIf ingredients are unclear or incompatible, suggest minor adjustments and list them under a Chef’s Note section.\n\nOutput Format (in Markdown):\n\n🍽️ [RECIPE TITLE]\n\nSERVINGS: [Estimate, e.g., 2-4] 👥 \nCOOk TIME: [Estimate in minutes] 🔥\n\nINGREDIENTS \n✪.Ingredient 1 with quantity \n✪.Ingredient 2 with quantity \n...\n\nINSTRUCTIONS \n1. Step one \n2. Step two \n...\n\nSPECIAL ADD-ONS \n- Describe how add-on 1 is used \n- Describe how add-on 2 is used \n...\n\nSUGGESTED PAIRING \n- Side dish or pairing suggestion with brief description\n\nCHEF’S NOTE (if applicable) \n- Note any substitutions, adjustments, or tips\n\nRULES\n- Bold all main section titles like INGREDIENTS, INSTRUCTIONS, SPECIAL ADD-ONS, SUGGESTED PAIRING, and CHEF’S NOTE using double asterisks (e.g., INGREDIENTS) but do not bold anything else.\n\n- strictly follow output formate \n\n-Make the output visually delightful by adding a few more relevant emojis to enhance each section's personality and structure. Use line spacing and section breaks to make the output look well-organized, professional, and scroll-stopping for email readers. Ensure it feels premium, exciting, and clear.\n\n\nEnsure no symbols (*, -, #, or **) are used in the ingredient list, special add-ons, or instructions. Each item must be on a new line without any prefix symbols.\n",
"options": {},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "45e7c74a-c0d0-4d7e-95b5-4a75c20b220d",
"name": "Llama 3.2 - 厨师模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOllama",
"position": [
300,
320
],
"parameters": {
"model": "llama3.2-16000:latest",
"options": {}
},
"credentials": {
"ollamaApi": {
"id": "vDhjHnEfhHheDgd6",
"name": "Ollama-vrushti"
}
},
"typeVersion": 1
},
{
"id": "df6b755f-fa56-4b3a-bae3-3c606e4250ec",
"name": "格式化食谱输出",
"type": "n8n-nodes-base.code",
"position": [
580,
100
],
"parameters": {
"jsCode": "const raw = $json[\"output\"] || \"\";\n\nfunction formatSection(title, content) {\n if (!content) return \"\";\n return `<strong>${title}</strong><br>${content}<br><br>`;\n}\n\n// Replace \\n with <br> for final formatting\nlet html = raw.replace(/\\n/g, \"<br>\");\n\n// Extract section content from RAW text\nfunction extractFromRaw(title) {\n const regex = new RegExp(`${title}\\\\s*:?\\\\s*\\\\n([\\\\s\\\\S]*?)(\\\\n\\\\n|\\\\n[A-Z ]{3,}|$)`, \"i\");\n const match = raw.match(regex);\n return match && match[1] ? match[1].trim().replace(/\\n/g, \"<br>\") : \"\";\n}\n\n// Extract Servings and Cook Time\nfunction extractDetails() {\n let servingsMatch = raw.match(/Servings\\s*[:\\-]?\\s*(.+)/i);\n let cookTimeMatch = raw.match(/Cook\\s*Time\\s*[:\\-]?\\s*(.+)/i);\n let servings = servingsMatch ? `SERVINGS: ${servingsMatch[1].trim()} 👥` : \"\";\n let cookTime = cookTimeMatch ? `COOK TIME: ${cookTimeMatch[1].trim()} 🔥` : \"\";\n return [servings, cookTime].filter(Boolean).join(\"<br>\");\n}\n\n\n// Title Line — also handles **Markdown bold** if exists\nconst firstLineRaw = raw.split(\"\\n\")[0].replace(\"🍽️ \", \"\").trim();\nconst firstLine = firstLineRaw.replace(/\\*\\*(.*?)\\*\\*/g, \"<strong>$1</strong>\");\n\nconst formatted = `\n<div style=\"font-family:Arial, sans-serif; line-height:1.6\">\n <p>🍽️ ${firstLine}</p><br>\n ${formatSection(\"DETAILS\", extractDetails())}\n ${formatSection(\"INGREDIENTS\", extractFromRaw(\"INGREDIENTS\"))}\n ${formatSection(\"INSTRUCTIONS\", extractFromRaw(\"INSTRUCTIONS\"))}\n ${formatSection(\"SPECIAL ADD-ONS\", extractFromRaw(\"SPECIAL ADD-ONS\"))}\n ${formatSection(\"SUGGESTED PAIRING\", extractFromRaw(\"SUGGESTED PAIRING\"))}\n ${formatSection(\"CHEF'S NOTE\", extractFromRaw(\"CHEF'S NOTE\"))}\n</div>\n`;\n\nreturn [\n {\n json: {\n formattedHtml: formatted\n }\n }\n];\n"
},
"typeVersion": 2
},
{
"id": "11c32fd2-8844-410e-bbae-a81e267f34da",
"name": "通过邮件发送食谱",
"type": "n8n-nodes-base.gmail",
"onError": "continueRegularOutput",
"position": [
800,
100
],
"webhookId": "a8bc0090-8b98-4a15-8449-194516ec6e90",
"parameters": {
"sendTo": "={{ $('Recipe Request - Gmail').item.json.To }}",
"message": "={{ $json.formattedHtml }}",
"options": {
"appendAttribution": false
},
"subject": "🔥 Ready to Cook? Here’s Your Recipe from AI Chef"
},
"credentials": {
"gmailOAuth2": {
"id": "PcTqvGU9uCunfltE",
"name": "Gmail account - test"
}
},
"executeOnce": true,
"typeVersion": 2.1,
"alwaysOutputData": true
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "8bf21cb0-edf4-4908-9c46-46363df9ade8",
"connections": {
"Format Recipe Output": {
"main": [
[
{
"node": "Send Recipe via Email",
"type": "main",
"index": 0
}
]
]
},
"Llama 3.2 - Chef Model": {
"ai_languageModel": [
[
{
"node": "Ollama Recipe Generator",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Recipe Request - Gmail": {
"main": [
[
{
"node": "Ollama Recipe Generator",
"type": "main",
"index": 0
}
]
]
},
"Ollama Recipe Generator": {
"main": [
[
{
"node": "Format Recipe Output",
"type": "main",
"index": 0
}
]
]
},
"Recipe Request - Web Form": {
"main": [
[
{
"node": "Ollama Recipe Generator",
"type": "main",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 个人效率, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
分享此工作流