{
  "name": "PF \u2013 WF-03 Social Media Auto-Post",
  "nodes": [
    {
      "parameters": {
        "content": "## PF \u2013 WF-03 Social Media Auto-Post v4\n\n**Ablauf:**\nSharePoint (Status=Freigegeben)\n\u2192 Felder aufbereiten\n\u2192 Claude API + Canva MCP:\n   \u2022 Template DAHJW-GJz68 duplizieren\n   \u2022 [THEMA] ersetzen\n   \u2022 Als JPG exportieren\n   \u2022 URL zur\u00fcckgeben\n\u2192 Instagram: Media Container + Ver\u00f6ffentlichen\n\u2192 Facebook: Beitrag\n\u2192 SharePoint: Status = Ver\u00f6ffentlicht\n\u2192 Teams: Erfolgsmeldung\n\n**Judith muss NUR:**\n1. Thema + Caption in SharePoint eintragen\n2. Status auf Freigegeben setzen\n\u2192 Alles andere l\u00e4uft automatisch!\n\n**Environment Variables:**\nANTHROPIC_API_KEY = sk-ant-...\nSHAREPOINT_SITE_ID = ...\nSHAREPOINT_LIST_ID = ...\nFB_PAGE_ID = ...\nTEAMS_TEAM_ID = ...\nTEAMS_CHANNEL_ID = ...",
        "height": 300,
        "width": 1060,
        "color": 5
      },
      "id": "sticky-main",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "content": "**Changelog:**\n\nv4 \u2013 2026-05-11\n\u2022 Claude API + Canva MCP\n\u2022 Template DAHJW-GJz68\n\u2022 Vollautomatisch!\n\u2022 Kein manueller Export\n\nv3 \u2013 2026-05-11\n\u2022 Manueller Export n\u00f6tig\n\u2022 Medienbruch\n\nv2 \u2013 2026-05-11\n\u2022 Canva OAuth Problem\n\nv1 \u2013 2026-05-11\n\u2022 Autofill (Enterprise)",
        "width": 220,
        "color": 6
      },
      "id": "sticky-changelog",
      "name": "Changelog v4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        2600,
        260
      ]
    },
    {
      "parameters": {
        "content": "**\u26a0\ufe0f Canva Template vorbereiten:**\n\n1. Design DAHJW-GJz68 in Canva \u00f6ffnen\n2. Text-Element f\u00fcr das Thema\n   exakt so beschriften: [THEMA]\n3. Design auf PUBLIC stellen\n   (Teilen \u2192 \u00d6ffentlich)\n\nClaude ersetzt [THEMA] automatisch\nmit dem Wert aus field_1 (Thema).",
        "width": 280,
        "color": 3
      },
      "id": "sticky-canva-prep",
      "name": "Canva Vorbereitung",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1120,
        0
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1,
                3,
                5
              ],
              "triggerAtHour": 9,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "trigger-schedule",
      "name": "Trigger: Mo/Mi/Fr 9:00 Uhr",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        240,
        400
      ]
    },
    {
      "parameters": {
        "resource": "listItem",
        "operation": "getAll",
        "siteId": "={{ $env.SHAREPOINT_SITE_ID }}",
        "listId": "={{ $env.SHAREPOINT_LIST_ID }}",
        "returnAll": true,
        "simplify": true,
        "options": {}
      },
      "id": "sp-get-items",
      "name": "SharePoint: Freigegebene Posts",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "typeVersion": 1,
      "position": [
        460,
        400
      ],
      "credentials": {
        "microsoftSharePointOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false
          },
          "conditions": [
            {
              "id": "check-status",
              "leftValue": "={{ $json.fields?.field_6 ?? $json.field_6 }}",
              "rightValue": "Freigegeben",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "check-thema",
              "leftValue": "={{ $json.fields?.field_1 ?? $json.field_1 }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "if-freigegeben",
      "name": "Pr\u00fcfe: Freigegeben + Thema?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        680,
        400
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "item_id",
              "value": "={{ $json.id }}",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "thema",
              "value": "={{ $json.fields?.field_1 ?? $json.field_1 }}",
              "type": "string"
            },
            {
              "id": "a3",
              "name": "caption",
              "value": "={{ $json.fields?.field_3 ?? $json.field_3 }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "felder-aufbereiten",
      "name": "Felder aufbereiten",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        900,
        280
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.anthropic.com/v1/messages",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $env.ANTHROPIC_API_KEY }}"
            },
            {
              "name": "anthropic-version",
              "value": "2023-06-01"
            },
            {
              "name": "anthropic-beta",
              "value": "mcp-client-2025-04-04"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "bodyContentType": "json",
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"claude-sonnet-4-20250514\",\n  \"max_tokens\": 1024,\n  \"system\": \"Du bist ein Canva-Automatisierungsassistent f\u00fcr Physio Fuchs. F\u00fchre exakt die angeforderten Canva-Aktionen aus. Gib am Ende NUR die Export-Download-URL zur\u00fcck \u2013 keinen anderen Text, keine Erkl\u00e4rungen, nur die URL.\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"F\u00fchre folgende Schritte f\u00fcr Physio Fuchs Instagram-Post aus:\\n\\n1. \u00d6ffne das Design mit ID: DAHJW-GJz68\\n2. Starte eine Editing-Transaktion\\n3. Ersetze den Text [THEMA] durch: {{ $json.thema }}\\n4. Committe die Transaktion\\n5. Exportiere das Design als JPG (h\u00f6chste Qualit\u00e4t)\\n6. Gib NUR die Download-URL zur\u00fcck\\n\\nNur die URL, kein anderer Text.\"\n    }\n  ],\n  \"mcp_servers\": [\n    {\n      \"type\": \"url\",\n      \"url\": \"https://mcp.canva.com/mcp\",\n      \"name\": \"canva\"\n    }\n  ]\n}",
        "options": {}
      },
      "id": "claude-canva-export",
      "name": "Claude + Canva: Design exportieren",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        280
      ]
    },
    {
      "parameters": {
        "jsCode": "// Claude API Response verarbeiten\nconst response = $input.item.json;\n\n// Text aus content blocks extrahieren\nlet imageUrl = '';\n\nif (response.content && Array.isArray(response.content)) {\n  for (const block of response.content) {\n    if (block.type === 'text' && block.text) {\n      const text = block.text.trim();\n      // URL extrahieren (beginnt mit https://)\n      const urlMatch = text.match(/https:\\/\\/[^\\s]+/);\n      if (urlMatch) {\n        imageUrl = urlMatch[0];\n        break;\n      }\n    }\n  }\n}\n\nif (!imageUrl) {\n  throw new Error('Keine Bild-URL in Claude Response gefunden: ' + JSON.stringify(response.content));\n}\n\nreturn {\n  image_url: imageUrl,\n  caption: $('Felder aufbereiten').item.json.caption,\n  thema: $('Felder aufbereiten').item.json.thema,\n  item_id: $('Felder aufbereiten').item.json.item_id\n};"
      },
      "id": "url-extrahieren",
      "name": "Bild-URL extrahieren",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1340,
        280
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://graph.facebook.com/v25.0/17841461169626096/media",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi",
        "sendBody": true,
        "bodyContentType": "json",
        "specifyBody": "fieldsBelow",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image_url",
              "value": "={{ $json.image_url }}"
            },
            {
              "name": "caption",
              "value": "={{ $json.caption }}"
            }
          ]
        },
        "options": {}
      },
      "id": "ig-media-container",
      "name": "Instagram: Media Container erstellen",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1560,
        280
      ],
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "amount": 15,
        "unit": "seconds"
      },
      "id": "warten-ig",
      "name": "Warten 15s (Instagram Processing)",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1780,
        280
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://graph.facebook.com/v25.0/17841461169626096/media_publish",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi",
        "sendBody": true,
        "bodyContentType": "json",
        "specifyBody": "fieldsBelow",
        "bodyParameters": {
          "parameters": [
            {
              "name": "creation_id",
              "value": "={{ $('Instagram: Media Container erstellen').item.json.id }}"
            }
          ]
        },
        "options": {}
      },
      "id": "ig-publish",
      "name": "Instagram: Post ver\u00f6ffentlichen",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2000,
        200
      ],
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://graph.facebook.com/v25.0/{{ $env.FB_PAGE_ID }}/photos",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi",
        "sendBody": true,
        "bodyContentType": "json",
        "specifyBody": "fieldsBelow",
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $('Bild-URL extrahieren').item.json.image_url }}"
            },
            {
              "name": "message",
              "value": "={{ $('Bild-URL extrahieren').item.json.caption }}"
            }
          ]
        },
        "options": {}
      },
      "id": "fb-publish",
      "name": "Facebook: Beitrag ver\u00f6ffentlichen",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2000,
        360
      ],
      "credentials": {
        "facebookGraphApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "listItem",
        "operation": "update",
        "siteId": "={{ $env.SHAREPOINT_SITE_ID }}",
        "listId": "={{ $env.SHAREPOINT_LIST_ID }}",
        "itemId": "={{ $('Bild-URL extrahieren').item.json.item_id }}",
        "dataToSend": "defineBelow",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "field_6",
              "fieldValue": "Ver\u00f6ffentlicht"
            }
          ]
        }
      },
      "id": "sp-update-status",
      "name": "SharePoint: Status Ver\u00f6ffentlicht",
      "type": "n8n-nodes-base.microsoftSharePoint",
      "typeVersion": 1,
      "position": [
        2220,
        280
      ],
      "credentials": {
        "microsoftSharePointOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "create",
        "teamId": "={{ $env.TEAMS_TEAM_ID }}",
        "channelId": "={{ $env.TEAMS_CHANNEL_ID }}",
        "content": "=\u2705 **Post ver\u00f6ffentlicht!**\n\n\ud83d\udccc **Thema:** {{ $('Bild-URL extrahieren').item.json.thema }}\n\ud83d\udcf8 **Instagram:** {{ $('Instagram: Post ver\u00f6ffentlichen').item.json.id }}\n\ud83d\udcd8 **Facebook:** {{ $('Facebook: Beitrag ver\u00f6ffentlichen').item.json.id }}\n\ud83d\udd50 {{ $now.format('DD.MM.YYYY') }} um {{ $now.format('HH:mm') }} Uhr\n\n_Automatisch via PF Social Media Auto-Post_"
      },
      "id": "teams-success",
      "name": "Teams: Erfolgsbenachrichtigung",
      "type": "n8n-nodes-base.microsoftTeams",
      "typeVersion": 2,
      "position": [
        2440,
        280
      ],
      "credentials": {
        "microsoftTeamsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "end1",
              "name": "info",
              "value": "Kein freigegebener Content oder Thema fehlt",
              "type": "string"
            }
          ]
        }
      },
      "id": "kein-content",
      "name": "Kein Content \u2013 Ende",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        900,
        520
      ]
    }
  ],
  "connections": {
    "Trigger: Mo/Mi/Fr 9:00 Uhr": {
      "main": [
        [
          {
            "node": "SharePoint: Freigegebene Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SharePoint: Freigegebene Posts": {
      "main": [
        [
          {
            "node": "Pr\u00fcfe: Freigegeben + Thema?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pr\u00fcfe: Freigegeben + Thema?": {
      "main": [
        [
          {
            "node": "Felder aufbereiten",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Kein Content \u2013 Ende",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Felder aufbereiten": {
      "main": [
        [
          {
            "node": "Claude + Canva: Design exportieren",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude + Canva: Design exportieren": {
      "main": [
        [
          {
            "node": "Bild-URL extrahieren",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bild-URL extrahieren": {
      "main": [
        [
          {
            "node": "Instagram: Media Container erstellen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram: Media Container erstellen": {
      "main": [
        [
          {
            "node": "Warten 15s (Instagram Processing)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Warten 15s (Instagram Processing)": {
      "main": [
        [
          {
            "node": "Instagram: Post ver\u00f6ffentlichen",
            "type": "main",
            "index": 0
          },
          {
            "node": "Facebook: Beitrag ver\u00f6ffentlichen",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram: Post ver\u00f6ffentlichen": {
      "main": [
        [
          {
            "node": "SharePoint: Status Ver\u00f6ffentlicht",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Facebook: Beitrag ver\u00f6ffentlichen": {
      "main": [
        [
          {
            "node": "SharePoint: Status Ver\u00f6ffentlicht",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SharePoint: Status Ver\u00f6ffentlicht": {
      "main": [
        [
          {
            "node": "Teams: Erfolgsbenachrichtigung",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "v4-2026-05-11",
  "id": "PF-WF03-v4",
  "tags": [
    "physio-fuchs",
    "social-media",
    "canva",
    "claude-api"
  ]
}