8
n8n 中文网amn8n.com

Telegram AI 食谱生成器(从图片或文本)

高级

这是一个自动化工作流,包含 16 个节点。主要使用 If, Set, Telegram, Agent, TelegramTrigger 等节点。 使用GPT-4 Vision和Telegram从冰箱照片生成食谱

前置要求
  • Telegram Bot Token

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "t0pM31b82LN8h8EX",
  "meta": {
    "instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d",
    "templateCredsSetupCompleted": true
  },
  "name": "Telegram AI 食谱生成器(从图片或文本)",
  "tags": [],
  "nodes": [
    {
      "id": "if_node_001",
      "name": "检查输入类型",
      "type": "n8n-nodes-base.if",
      "position": [
        400,
        -16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "condition_001",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json.message.text }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ai_agent_vision_001",
      "name": "AI 视觉代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        704,
        -128
      ],
      "parameters": {
        "text": "=Please analyze this food image and identify all visible ingredients. List them clearly.\n\nImage URL: {{ $json.body.events[0].message.id }}",
        "options": {
          "systemMessage": "=You are a food ingredient identification expert. Analyze food images and identify all visible ingredients accurately. Return a structured list of ingredients."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "openai_vision_model_001",
      "name": "OpenAI 视觉模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        672,
        16
      ],
      "parameters": {
        "model": "openai/gpt-4-vision-preview",
        "options": {
          "temperature": 0.3
        }
      },
      "credentials": {
        "openRouterApi": {
          "id": "D1q69WNrqGh2Tmie",
          "name": "OpenRouter 使える"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "output_parser_001",
      "name": "成分解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        896,
        16
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"ingredients\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"List of identified ingredients\"\n    }\n  },\n  \"required\": [\"ingredients\"]\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "set_ingredients_001",
      "name": "格式化成分",
      "type": "n8n-nodes-base.set",
      "position": [
        1088,
        -128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "assignment_001",
              "name": "ingredients_text",
              "type": "string",
              "value": "={{ $json.output.ingredients.join(', ') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "set_text_ingredients_001",
      "name": "获取文本成分",
      "type": "n8n-nodes-base.set",
      "position": [
        688,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "assignment_002",
              "name": "ingredients_text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "recipe_generator_001",
      "name": "食谱生成器",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1264,
        144
      ],
      "parameters": {
        "text": "=Based on these ingredients: {{ $json.ingredients_text }}\n\nPlease suggest 3 delicious recipes that can be made with these ingredients. Consider both Japanese and international cuisine options. Text is Japanese.",
        "options": {
          "systemMessage": "You are a professional chef and recipe expert. Create detailed, easy-to-follow recipes based on available ingredients. Include both traditional Japanese dishes and international cuisine. Always provide cooking time, difficulty level, and step-by-step instructions."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "openai_recipe_model_001",
      "name": "OpenAI 食谱模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1264,
        320
      ],
      "parameters": {
        "model": "openai/gpt-4o-mini",
        "options": {
          "temperature": 0.7
        }
      },
      "credentials": {
        "openRouterApi": {
          "id": "D1q69WNrqGh2Tmie",
          "name": "OpenRouter 使える"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "recipe_parser_001",
      "name": "食谱解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1456,
        320
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"recipes\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"name\": {\n            \"type\": \"string\",\n            \"description\": \"Recipe name\"\n          },\n          \"cuisine\": {\n            \"type\": \"string\",\n            \"description\": \"Cuisine type (e.g., Japanese, Italian)\"\n          },\n          \"difficulty\": {\n            \"type\": \"string\",\n            \"description\": \"Difficulty level (Easy, Medium, Hard)\"\n          },\n          \"cookingTime\": {\n            \"type\": \"string\",\n            \"description\": \"Total cooking time\"\n          },\n          \"servings\": {\n            \"type\": \"number\",\n            \"description\": \"Number of servings\"\n          },\n          \"ingredients\": {\n            \"type\": \"array\",\n            \"items\": {\n              \"type\": \"string\"\n            },\n            \"description\": \"Full ingredient list with quantities\"\n          },\n          \"instructions\": {\n            \"type\": \"array\",\n            \"items\": {\n              \"type\": \"string\"\n            },\n            \"description\": \"Step-by-step cooking instructions\"\n          }\n        },\n        \"required\": [\"name\", \"cuisine\", \"difficulty\", \"cookingTime\", \"servings\", \"ingredients\", \"instructions\"]\n      },\n      \"description\": \"Array of recipe suggestions\"\n    }\n  },\n  \"required\": [\"recipes\"]\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "format_response_001",
      "name": "格式化响应",
      "type": "n8n-nodes-base.set",
      "position": [
        1680,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "response_004",
              "name": "message",
              "type": "string",
              "value": "={{\n(() => {\n  return $json.output.recipes.map((r, index) => {\n    return (\n      `📖 レシピ${index + 1}:${r.name}\\n` +\n      `🌐 ジャンル:${r.cuisine}\\n` +\n      `⏱ 調理時間:${r.cookingTime}\\n` +\n      `🎚 難易度:${r.difficulty}\\n` +\n      `👥 目安人数:${r.servings}人分\\n\\n` +\n      `🛒 材料:\\n${r.ingredients.map(i => `- ${i}`).join(\"\\n\")}\\n\\n` +\n      `👣 手順:\\n${r.instructions.map((step, i) => `${i + 1}. ${step}`).join(\"\\n\")}`\n    );\n  }).join(\"\\n\\n------------------------\\n\\n\");\n})()\n}}\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "684b387e-b22d-47a2-8db3-5367850fa33d",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        176,
        -16
      ],
      "webhookId": "76cdce48-d78e-40cd-b034-a0cf3ed053be",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "download": true
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "Ikb8BOl71y5C8wqu",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "812b9b19-c320-4a6b-a28f-7bf80a7863bd",
      "name": "发送文本消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1872,
        144
      ],
      "webhookId": "fc292b17-c612-4a76-9ad7-c4e1f62cb6e5",
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "Ikb8BOl71y5C8wqu",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a9e0f1b2-c3d4-e5f6-a7b8-c9d0e1f2a3b4",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -320
      ],
      "parameters": {
        "color": 6,
        "width": 500,
        "height": 260,
        "content": "### 阶段 1:通过 Telegram 的用户输入"
      },
      "typeVersion": 1
    },
    {
      "id": "b1c2d3e4-f5a6-b7c8-d9e0-f1a2b3c4d5e6",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        -448
      ],
      "parameters": {
        "color": 3,
        "width": 500,
        "height": 380,
        "content": "### 阶段 2:成分提取(双路径)"
      },
      "typeVersion": 1
    },
    {
      "id": "c3d4e5f6-a7b8-c9d0-e1f2-a3b4c5d6e7f8",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        -192
      ],
      "parameters": {
        "color": 5,
        "width": 500,
        "height": 360,
        "content": "### 阶段 3:AI 食谱生成"
      },
      "typeVersion": 1
    },
    {
      "id": "d5e6f7a8-b9c0-d1e2-f3a4-b5c6d7e8f9a0",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1648,
        -128
      ],
      "parameters": {
        "color": 4,
        "width": 500,
        "height": 280,
        "content": "### 阶段 4:格式化并发送响应"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "timezone": "Asia/Tokyo",
    "errorWorkflow": "",
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true,
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "all"
  },
  "versionId": "30c406be-b5d8-4ba8-873f-8ae990fdbcb9",
  "connections": {
    "Recipe Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Recipe Generator",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "AI Vision Agent": {
      "main": [
        [
          {
            "node": "Format Ingredients",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Input Type": {
      "main": [
        [
          {
            "node": "AI Vision Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Text Ingredients",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recipe Generator": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Check Input Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ingredient Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Vision Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Format Ingredients": {
      "main": [
        [
          {
            "node": "Recipe Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Recipe Model": {
      "ai_languageModel": [
        [
          {
            "node": "Recipe Generator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Vision Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Vision Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get Text Ingredients": {
      "main": [
        [
          {
            "node": "Recipe Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量16
分类-
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
YUSUKE YAMAMOTO

YUSUKE YAMAMOTO

@yusuke-yamamoto

Business creator from Tokyo. Designing AI-driven automations that enhance marketing, reporting, and daily operations. I turn complex workflows into simple, elegant automations with n8n.

外部链接
在 n8n.io 查看

分享此工作流