Automatisierung von Instagram- und Facebook-Postings mit Meta Graph API und Systemnutzertoken

Experte

Dies ist ein Social Media-Bereich Automatisierungsworkflow mit 22 Nodes. Hauptsächlich werden Code, Wait, HttpRequest, ManualTrigger, ScheduleTrigger und andere Nodes verwendet. Automatisierung von Instagram- und Facebook-Beiträgen durch Meta Graph API und Systembenutzer-Token

Voraussetzungen
  • Möglicherweise sind Ziel-API-Anmeldedaten erforderlich
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "meta": {
    "instanceId": "805a1da4490c39f62729f8489b312a775cb04286f77152b4febdc1f1642e5967",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "4fccdc64-1eb2-43a6-82c5-5ebcea2b801b",
      "name": "Bei Klick auf 'Workflow ausführen'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -560,
        480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "738fabc1-5282-442b-a275-a3943bff890e",
      "name": "Beitrag an Instagram senden",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -300,
        480
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/<YOUR PAGE ID HERE>/media",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image_url",
              "value": "<YOUR IMAGE URL HERE>"
            },
            {
              "name": "caption",
              "value": "<YOUR CAPTION HERE>"
            }
          ]
        },
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "szDaIQHhZqLlJHII",
          "name": "Facebook Graph account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "da899479-cfaa-4771-bc31-bdb0d4e4a3b7",
      "name": "instagram-Beitrag veröffentlichen",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        100,
        480
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/17841404935066235/media_publish",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "creation_id",
              "value": "={{ $json.id }}"
            }
          ]
        },
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "szDaIQHhZqLlJHII",
          "name": "Facebook Graph account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b6cd01bd-f98f-4092-81f2-1b8f6e6c4b27",
      "name": "Haftnotiz",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1320,
        -300
      ],
      "parameters": {
        "width": 540,
        "height": 1900,
        "content": "**How to Generate a Facebook Short-Lived Access Token for Instagram + Facebook Page Posting**\n\n### What You Need\n\n* A **Facebook account**\n* A **Facebook Page** (must be linked to an Instagram Business account if you plan to post to IG)\n* Access to [Meta for Developers](https://developers.facebook.com/)\n\n---\nStep-by-Step: How to Generate Your Short-Lived Token\n\n#### 1. Go to Meta for Developers\n\n* Visit: [https://developers.facebook.com/apps](https://developers.facebook.com/apps)\n* Log in with your Facebook credentials\n\n#### 2. Create a New App\n\n* Click the blue **Create App** button\n* Choose **Other** as the app type\n* On the next screen, select **Business**\n* Enter an app name and contact email, then click **Create App**\n\n#### 3. Open the App Dashboard\n\n* After creation, you’ll be redirected to the app’s dashboard\n* This is where you’ll manage products, permissions, and tokens\n\n#### 4. Add Products\n\n* In the left sidebar, scroll down to **Add Product**\n* Click **Set Up** on both:\n\n  * **Instagram Graph API**\n  * **Facebook Graph API** (If missing it is automatically setup when you create the app) \n\n>  If you do not see the \"Add Product\" section, your app may already be locked to a specific template or be in Live mode. You can still continue to the Graph API Explorer.\n\n#### 5. Go to the Graph API Explorer\n\n* Visit: [https://developers.facebook.com/tools/explorer/](https://developers.facebook.com/tools/explorer/)\n* In the top-right dropdown, select your app\n* Under \"User or Page\", keep **User Token** selected\n\n#### 6. Generate a User Access Token\n\n* Click **Get Token** > **Get User Access Token**\n* A permissions dialog will appear\n\n#### 7. Select the Required Permissions (Scopes)\n\nCheck the following boxes:\n\n* `pages_show_list`\n* `pages_read_engagement`\n* `pages_manage_posts`\n* `instagram_basic`\n* `instagram_content_publish`\n\n> These allow you to post to both Facebook Pages and Instagram accounts. Some may require approval for production use.\n\n#### 8. Authenticate and Authorize\n\n* A pop-up will prompt you to log into Facebook and approve the app\n* Be sure to authorize access to your Facebook Page and linked Instagram account\n\n#### 9. Copy the Short-Lived Token\n\n* After successful login, the Graph API Explorer will refresh\n* Your new **short-lived token** will appear in the top bar\n* **Copy it immediately** — this token is valid for 1–2 hours\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "fe0a05a4-5e13-4109-86c1-1da8fc5e7a9a",
      "name": "Haftnotiz1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -300
      ],
      "parameters": {
        "width": 1460,
        "height": 540,
        "content": "Facebook will only give you a \"Long Live Token\" if you are verified. If you are testing or not verified you can use the below method.\nThe initial token will only last a few hours, you can use the below to get the one that last for 2 months. Once you have the 2 month token you can put it in here and set the schedule to run every 30-60 days which will refresh and be saved in the static data.\n\n\n##Please note static Data does not run on a test, you can use a form submitted node to activate the flow.\n##Please note this is just a work around for testing and not practical for permanent use. "
      },
      "typeVersion": 1
    },
    {
      "id": "cce6d146-599e-439a-bff6-fc0870a8df02",
      "name": "Token aktualisieren",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -300,
        -120
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/oauth/access_token",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "grant_type",
              "value": "fb_exchange_token"
            },
            {
              "name": "client_id",
              "value": "<Your Client ID>"
            },
            {
              "name": "client_secret",
              "value": "<Your Secret Here>"
            },
            {
              "name": "fb_exchange_token",
              "value": "<your short token>"
            }
          ]
        },
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "szDaIQHhZqLlJHII",
          "name": "Facebook Graph account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e93d120b-ef7b-491c-bfcf-3d6a1ec62786",
      "name": "Zeitplan-Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -680,
        -120
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "daysInterval": 30,
              "triggerAtHour": 1
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "097bde34-8787-4e0d-9dec-90f2de9c0aa1",
      "name": "Aktuelles Token abrufen",
      "type": "n8n-nodes-base.code",
      "position": [
        -500,
        -120
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\nreturn [{\n  json: {\n    token: staticData.fb_token\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "75f115f5-eee8-4e85-bd35-8c70ac4c13c5",
      "name": "An statische Daten senden",
      "type": "n8n-nodes-base.code",
      "position": [
        -80,
        -120
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\nstaticData.fb_token = $json.access_token;\n\nreturn [{\n  json: {\n    status: 'Token saved to static data',\n    token: staticData.fb_token\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "95439d8f-c568-497a-901f-69b2cfd7172f",
      "name": "Token aus statischen Daten abrufen",
      "type": "n8n-nodes-base.code",
      "position": [
        -640,
        60
      ],
      "parameters": {
        "jsCode": "const staticData = $getWorkflowStaticData('global');\nreturn [{\n  json: {\n    token: staticData.fb_token\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "b13db71d-0620-46d4-a9f9-17b693930af4",
      "name": "An Instagram1 senden",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -420,
        60
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/<Instagram Page ID>/media",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image_url",
              "value": "<Your Image Url>"
            },
            {
              "name": "caption",
              "value": "<Your Caption>"
            },
            {
              "name": "access_token",
              "value": "={{ $json.token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "72bb812b-7ccf-4703-8d6d-35feb3576792",
      "name": "instagram-Beitrag1 veröffentlichen",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -60,
        60
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/<your instagram page id>/media_publish",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "creation_id",
              "value": "={{ $json.id }}"
            },
            {
              "name": "access_token",
              "value": "={{ $('Get Token from static Data').item.json.token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "5a279b05-d40f-47b6-a7f1-56daa21ff773",
      "name": "Beitrag an Facebook senden",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        780,
        480
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/266271423823110/photos",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "https://images.pexels.com/photos/5475816/pexels-photo-5475816.jpeg?auto=compress&cs=tinysrgb&fit=crop&h=627&w=1200"
            },
            {
              "name": "caption",
              "value": "This is the caption for the post"
            },
            {
              "name": "access_token",
              "value": "={{ $json.data[0].access_token }}"
            }
          ]
        },
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "szDaIQHhZqLlJHII",
          "name": "Facebook Graph account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "395e1149-cb03-45f3-97b1-1a5fe8e4ac06",
      "name": "Systemtoken zum Abrufen des Seiten-Tokens verwenden",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        320,
        480
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/me/accounts",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "facebookGraphApi"
      },
      "credentials": {
        "facebookGraphApi": {
          "id": "szDaIQHhZqLlJHII",
          "name": "Facebook Graph account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "926c9774-6e9b-427f-8916-3ccf4ce30012",
      "name": "Haftnotiz3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        340
      ],
      "parameters": {
        "color": 5,
        "width": 1760,
        "height": 360,
        "content": "Using the permanant never expire token"
      },
      "typeVersion": 1
    },
    {
      "id": "1ef57c3d-fc04-4107-82e3-3faf0dcfe2ce",
      "name": "Haftnotiz4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1080,
        -80
      ],
      "parameters": {
        "width": 680,
        "height": 1220,
        "content": " How to Create a Permanent System User Token (Recommended)\n\nThis token doesn’t expire and is best for automation use cases\n\n1. Verify Your Business\n\nGo to https://business.facebook.com/settings/info\n\nComplete business verification under Business Info tab\n\nSubmit your business documents and wait for approval (Sometimes you just have to submit an EIN/Tax-ID.\n\nApproval can take 1-5 Business days\n\nOnce Approved do the following.\n\n2. Create a System User\n\nIn Business Settings\n\nGo to System Users > Click Add\n\nAssign a name (e.g. n8n-bot) and select Admin access\n\n3. Assign Assets to System User\n\nIn the same System User view, assign:\n\nYour Facebook Page (with Full Control)\n\nYour Instagram Account (linked via Page)\n\nYour App\n\n4. Generate a Token\n\nClick Generate Token\n\nSelect your App\n\nSet expiration to Never\n\nGrant these permissions:\n\npages_show_list\n\npages_read_engagement\n\npages_manage_posts\n\ninstagram_basic\n\ninstagram_content_publish\n\n-If instagram_content_publish is not visible, you may need to request it via App Review under the App dashboard.\n\n5. Use This Token\n\nStore it in the Facebook Graph API\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4eaa4823-7601-49d1-9cec-da232ac7ee62",
      "name": "Korrektes Seiten-Token abrufen",
      "type": "n8n-nodes-base.code",
      "position": [
        560,
        480
      ],
      "parameters": {
        "jsCode": "const page = $json.data.find(p => p.id === '266271423823110');\nreturn [{ json: { access_token: page.access_token } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "abb870c7-9241-4503-9fb1-348dcbf29dad",
      "name": "2 Sekunden warten",
      "type": "n8n-nodes-base.wait",
      "position": [
        -120,
        480
      ],
      "webhookId": "c40b180e-016c-4648-898a-5942b8a9b00d",
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "70120c0d-d21a-4fa2-b8d5-81931c198c65",
      "name": "2 Sekunden warten1",
      "type": "n8n-nodes-base.wait",
      "position": [
        -240,
        60
      ],
      "webhookId": "c40b180e-016c-4648-898a-5942b8a9b00d",
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "4cde11f4-c12f-4827-94ce-9ee9d11d821d",
      "name": "Systemtoken zum Abrufen des Seiten-Tokens1 verwenden",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        160,
        60
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/me/accounts",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "access_token",
              "value": "={{ $('Get Token from static Data').item.json.token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f7581a1c-d095-4fe9-951c-cc6b6108156a",
      "name": "Korrektes Seiten-Token1 abrufen",
      "type": "n8n-nodes-base.code",
      "position": [
        380,
        60
      ],
      "parameters": {
        "jsCode": "const page = $json.data.find(p => p.id === '<YOUR PAGE ID HERE>');\nreturn [{ json: { access_token: page.access_token } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "306bb9bb-5ba0-4ecd-96a8-33e3ec292526",
      "name": "An Facebook1 senden",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        580,
        60
      ],
      "parameters": {
        "url": "https://graph.facebook.com/v19.0/<YOUR PAGE ID HERE>/photos",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "<YOUR IMAGE URL HERE>"
            },
            {
              "name": "caption",
              "value": "<YOUR CAPTION  HERE>"
            },
            {
              "name": "access_token",
              "value": "={{ $json.data[0].access_token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    }
  ],
  "pinData": {},
  "connections": {
    "cce6d146-599e-439a-bff6-fc0870a8df02": {
      "main": [
        [
          {
            "node": "75f115f5-eee8-4e85-bd35-8c70ac4c13c5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "abb870c7-9241-4503-9fb1-348dcbf29dad": {
      "main": [
        [
          {
            "node": "da899479-cfaa-4771-bc31-bdb0d4e4a3b7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "70120c0d-d21a-4fa2-b8d5-81931c198c65": {
      "main": [
        [
          {
            "node": "72bb812b-7ccf-4703-8d6d-35feb3576792",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e93d120b-ef7b-491c-bfcf-3d6a1ec62786": {
      "main": [
        [
          {
            "node": "097bde34-8787-4e0d-9dec-90f2de9c0aa1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "097bde34-8787-4e0d-9dec-90f2de9c0aa1": {
      "main": [
        [
          {
            "node": "cce6d146-599e-439a-bff6-fc0870a8df02",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "738fabc1-5282-442b-a275-a3943bff890e": {
      "main": [
        [
          {
            "node": "abb870c7-9241-4503-9fb1-348dcbf29dad",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b13db71d-0620-46d4-a9f9-17b693930af4": {
      "main": [
        [
          {
            "node": "70120c0d-d21a-4fa2-b8d5-81931c198c65",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4eaa4823-7601-49d1-9cec-da232ac7ee62": {
      "main": [
        [
          {
            "node": "5a279b05-d40f-47b6-a7f1-56daa21ff773",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "da899479-cfaa-4771-bc31-bdb0d4e4a3b7": {
      "main": [
        [
          {
            "node": "395e1149-cb03-45f3-97b1-1a5fe8e4ac06",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f7581a1c-d095-4fe9-951c-cc6b6108156a": {
      "main": [
        [
          {
            "node": "306bb9bb-5ba0-4ecd-96a8-33e3ec292526",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "72bb812b-7ccf-4703-8d6d-35feb3576792": {
      "main": [
        [
          {
            "node": "4cde11f4-c12f-4827-94ce-9ee9d11d821d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "95439d8f-c568-497a-901f-69b2cfd7172f": {
      "main": [
        [
          {
            "node": "b13db71d-0620-46d4-a9f9-17b693930af4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "395e1149-cb03-45f3-97b1-1a5fe8e4ac06": {
      "main": [
        [
          {
            "node": "4eaa4823-7601-49d1-9cec-da232ac7ee62",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4cde11f4-c12f-4827-94ce-9ee9d11d821d": {
      "main": [
        [
          {
            "node": "f7581a1c-d095-4fe9-951c-cc6b6108156a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4fccdc64-1eb2-43a6-82c5-5ebcea2b801b": {
      "main": [
        [
          {
            "node": "738fabc1-5282-442b-a275-a3943bff890e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Experte - Soziale Medien

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Experte
Anzahl der Nodes22
Kategorie1
Node-Typen6
Schwierigkeitsbeschreibung

Für fortgeschrittene Benutzer, komplexe Workflows mit 16+ Nodes

Autor

specializing in automation, AI integrations, and workflow optimization. I build high-impact n8n workflows that connect Salesforce, Outlook, RingCentral, and more. Reach out if you need help making your systems talk to each other.

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34