8
n8n 中文网amn8n.com

使用Claude AI从Google Sheets到WordPress生成无障碍替代文本

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 10 个节点。主要使用 If, Code, HttpRequest, GoogleSheets, SplitInBatches 等节点。 使用Claude AI从Google Sheets到WordPress生成无障碍替代文本

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "393ca9e36a1f81b0f643c72792946a5fe5e49eb4864181ba4032e5a408278263",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "b093bb6e-2797-470b-b32f-c4ffe96249bb",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        912,
        -16
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "30695fd4-d335-46c8-9987-119ce068da74",
      "name": "分析图片",
      "type": "@n8n/n8n-nodes-langchain.anthropic",
      "onError": "continueRegularOutput",
      "position": [
        1152,
        0
      ],
      "parameters": {
        "text": "#Tâche \nAnalysez cette image et rédigez une description alternative (alt text) pour l'accessibilité web.\nCritères :\n\n##Caractéristiques\nMaximum 125 caractères\nDécrire les éléments visuels essentiels\nTon neutre et factuel\nCommencer par l'élément principal\n\nInclure : sujet principal, actions significatives, contexte important, texte visible\nÉviter : \"image de\", \"photo de\", détails décoratifs, interprétations\nRéponse : Fournir uniquement la description, sans guillemets.\n\n##Exemples\n\nIncorrect : Photo d'un chat mignon qui dort sur un canapé rouge dans un salon\nCorrect : Chat tigré dormant sur un canapé rouge",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-20250514",
          "cachedResultName": "claude-sonnet-4-20250514"
        },
        "options": {},
        "resource": "image",
        "imageUrls": "={{ $json.URL }}"
      },
      "credentials": {
        "anthropicApi": {
          "id": "WXQf5QsxCs3AyxlW",
          "name": "Anthropic account"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "e981bf45-2b8b-45ae-bce5-f20f6d29941b",
      "name": "在表格中更新行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1568,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "URL": "={{ $('Loop Over Items').item.json.URL }}",
            "Alt text": "={{ $json.content[0].text }}",
            "row_number": 0
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Alt text",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Alt text",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "URL"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Export media"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Send Sheets URL').item.json.chatInput }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "wBRLUCktxqXE6DVJ",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "71cf07ec-7559-4944-a0e6-adf9b85ac4ee",
      "name": "发送表格 URL",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        16,
        0
      ],
      "webhookId": "cb9f34cd-dd44-4859-8a12-4f7a20c32237",
      "parameters": {
        "mode": "webhook",
        "public": true,
        "options": {
          "responseMode": "responseNode"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "1060d6dd-e8c7-4550-bac0-ab2e608b75a1",
      "name": "获取 URL",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        656,
        0
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Export media"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Send Sheets URL').item.json.chatInput }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "wBRLUCktxqXE6DVJ",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "1c82e061-01e3-4efb-861f-b928903ec7ee",
      "name": "获取 WP 密钥 + 网站 URL(不带 https://)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        224,
        0
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Infos client"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $json.chatInput }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "wBRLUCktxqXE6DVJ",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "232776ed-2123-4ff7-96f5-336e85470a99",
      "name": "获取 Base64 密钥",
      "type": "n8n-nodes-base.code",
      "position": [
        448,
        0
      ],
      "parameters": {
        "jsCode": "// Dans une Function/Code node n8n\nconst username = $('Get WP Key + website URL WITHOUT https://').first().json['Admin Name'];\nconst password = $('Get WP Key + website URL WITHOUT https://').first().json.KEY;\nconst credentials = username + ':' + password;\n\n// Encoder en Base64 avec Buffer (Node.js)\nconst encodedCredentials = Buffer.from(credentials).toString('base64');\nconst authHeader = 'Basic ' + encodedCredentials;\n\nreturn {\n  json: {\n    username: username,\n    password: password,\n    credentials: credentials,\n    authHeader: authHeader\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "5ef87414-1e64-443d-925d-fd4c443030d3",
      "name": "更新 WP 图片替代文本",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1792,
        0
      ],
      "parameters": {
        "url": "=https://{{ $('Get WP Key + website URL WITHOUT https://').item.json.Domaine }}/wp-json/wp/v2/media/{{ $('Loop Over Items').item.json.ID }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "alt_text",
              "value": "={{ $('Analyze image').item.json.content[0].text }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "={{ $('Get Base64 key').item.json.authHeader }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3fb66fec-319f-482c-8b04-3a45490bea72",
      "name": "如果",
      "type": "n8n-nodes-base.if",
      "position": [
        1360,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "86ad2ab9-a213-4e16-b81b-b1c4315b6822",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json.error }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7d00b936-879e-45d0-a874-2a40f5b5f6c3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1248,
        -592
      ],
      "parameters": {
        "color": 4,
        "width": 816,
        "height": 1776,
        "content": "以下是带有转义超链接的描述:"
      },
      "typeVersion": 1
    },
    {
      "id": "ccae276a-6fc9-4a8e-94d4-f72a478cf336",
      "name": "完成",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1168,
        -192
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n    \"text\": \"Fin de la rédaction des alt description\"\n } "
      },
      "typeVersion": 1.2
    }
  ],
  "pinData": {},
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Update row in sheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get URLs": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze image": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Base64 key": {
      "main": [
        [
          {
            "node": "Get URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Fin",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Analyze image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Sheets URL": {
      "main": [
        [
          {
            "node": "Get WP Key + website URL WITHOUT https://",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update WP image alt": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row in sheet": {
      "main": [
        [
          {
            "node": "Update WP image alt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get WP Key + website URL WITHOUT https://": {
      "main": [
        [
          {
            "node": "Get Base64 key",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

外部链接
在 n8n.io 查看

分享此工作流