8
n8n 中文网amn8n.com

使用 Gemini 和 Pollinations AI 自动生成并发布 AI 图片到 Facebook

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 10 个节点。主要使用 Code, HttpRequest, ScheduleTrigger, FacebookGraphApi, ChainLlm 等节点。 使用 Gemini 和 Pollinations AI 自动生成并发布 AI 图片到 Facebook

前置要求
  • 可能需要目标 API 的认证凭证
  • Facebook Graph API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "ba73835d772fb31a8c93dbcda773c1ef34e21227b9c152c1ee6fdf0eab995f28",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "6dca36b9-725d-4a55-922d-dba546f6770c",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        -660
      ],
      "parameters": {
        "color": 2,
        "width": 400,
        "height": 560,
        "content": "🌟 使用 Gemini 和 Facebook 页面集成的自动化 AI 图像创建"
      },
      "typeVersion": 1
    },
    {
      "id": "6bed68e2-f333-4aa1-9002-5af796b829b1",
      "name": "设置计划",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -180,
        -40
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            },
            {
              "triggerAtHour": 11
            },
            {
              "triggerAtHour": 17
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b5d17183-278b-48a9-a5c8-44dcb9a1c651",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        240,
        160
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-lite-preview-06-17"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "y5KI7bWJDr54AEy4",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c56e9f2d-997c-4eb8-be69-ed46d178c5f5",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -660
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 400,
        "content": "🧱 推荐的节点重命名(为了清晰)"
      },
      "typeVersion": 1
    },
    {
      "id": "d37d6188-6b56-464d-9139-46e6c3b1e317",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        -660
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 260,
        "content": "🛠 发布提示"
      },
      "typeVersion": 1
    },
    {
      "id": "23209c8c-ed9d-492d-9b2b-50b79b814e07",
      "name": "记录计划时间",
      "type": "n8n-nodes-base.code",
      "position": [
        40,
        -40
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      message: \"Schedule Trigger aktif.\",\n      triggeredAt: new Date().toISOString(),\n      time: $json.time || \"Not Found\"\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "81b1a688-f7ec-4f7d-8ab3-106eb7a45df4",
      "name": "生成图像提示(Gemini)",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        240,
        -40
      ],
      "parameters": {
        "text": "=Create 1 random AI image prompt in the style of [cinematic / surreal / steampunk / retro futuristic]. The prompt should be unique, fantastic, and full of imagination. the prompt should be in good and correct English.\n\nOutput Without any additional explanation",
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "dc076be6-7f76-4904-99ce-67d44009eba4",
      "name": "创建 Pollinations URL",
      "type": "n8n-nodes-base.code",
      "position": [
        600,
        -40
      ],
      "parameters": {
        "jsCode": "const width = 1024;\nconst height = 1024;\nconst randomSeed = Math.floor(Math.random() * 100000);\n\nconst finalPrompt = $json.text;\nconst imageUrl = `https://image.pollinations.ai/prompt/${encodeURIComponent(finalPrompt)}.jpg?width=${width}&height=${height}&seed=${randomSeed}&model=flux&nologo=true`;\n\nreturn [\n  {\n    json: {\n      text: finalPrompt,\n      imageUrl\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "10ab3f57-9088-4b47-86a9-88681174d392",
      "name": "获取 AI 图像",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        -40
      ],
      "parameters": {
        "url": "={{ $json.imageUrl }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "e57ca15b-5d39-4a03-8ba7-5830ebdf773e",
      "name": "发布图像到 Facebook",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        1040,
        -40
      ],
      "parameters": {
        "edge": "photos",
        "node": "me",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "prompt",
                "value": "={{ $json.text }}"
              },
              {
                "name": "caption",
                "value": "={{ $json.text }}\n\n\n#FreeImage #AIGeneratedArt #CreativeFreedom #FreeToUse #freeimagegenerator"
              }
            ]
          }
        },
        "sendBinaryData": true,
        "graphApiVersion": "v22.0",
        "httpRequestMethod": "POST",
        "binaryPropertyName": "data"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "np3V4HlSQIPqGUSS",
          "name": "Facebook Graph account 6"
        }
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Fetch AI Image": {
      "main": [
        [
          {
            "node": "Post Image to Facebook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set The Schedule": {
      "main": [
        [
          {
            "node": "Log Schedule Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Schedule Time": {
      "main": [
        [
          {
            "node": "Generate Image Prompt (Gemini)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Pollinations URL": {
      "main": [
        [
          {
            "node": "Fetch AI Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Image Prompt (Gemini)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image Prompt (Gemini)": {
      "main": [
        [
          {
            "node": "Create Pollinations URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 内容创作, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
中级
节点数量10
分类2
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Fahmi Oktafian

Fahmi Oktafian

@fahmi3322

Hi! I’m Fahmi Oktafian, a developer and automation enthusiast with expertise in n8n, Node.js, and API integrations. I specialize in building smart, scalable workflows — from auto-publishing content to WordPress, sending automated Telegram notifications, to processing AI-based summaries and paraphrase. I’m passionate about helping businesses save time, increase efficiency, and automate their digital processes with clean and user-friendly solutions.

外部链接
在 n8n.io 查看

分享此工作流