Guides
Guide · n8n automation · 7 min read
How to auto-post to Facebook and Instagram with n8n
At the end you will have a Telegram bot that turns "Spring AC tune-up, 20% off" into an approved image post on your Facebook Page and Instagram account. Setup takes about 30 to 45 minutes the first time.
The workflow: Generate and publish AI image posts to Facebook and Instagram from Telegram (n8n template).
By MD Faizan Uzzaman · Verified n8n Creator · Published 10 Oct 2026
Before you start
| Need | Detail |
|---|---|
| Facebook Page | You must be an admin of the Page |
| Instagram account | Must be a Business or Creator account, linked to that Page |
| n8n | Cloud or self-hosted, with HTTPS (Telegram needs an HTTPS webhook) |
| Google account | For Drive (image hosting) and Sheets (log) |
Step 1: Switch Instagram to a professional account and link it to your Page
- Instagram app > Settings > Account type and tools > Switch to professional account (Business).
- Facebook Page > Settings > Linked accounts > Instagram > Connect.
- Check: the Page shows your Instagram account under linked accounts.
Step 2: Create a Meta app
- Go to developers.facebook.com > My Apps > Create app.
- Choose the use case for managing Pages and Instagram content (labels change often, pick the one that lists pages and instagram permissions).
- Add the Instagram product and the Facebook Login product if prompted.
- Keep the app in Development mode. You do not need app review to post to your own Page and your own Instagram account when you are an admin or tester of the app.
Step 3: Generate a Page access token
- Open the Graph API Explorer.
- Select your app. Request these permissions:
pages_show_list,pages_read_engagement,pages_manage_posts,instagram_basic,instagram_content_publish,business_management. - Generate a User token, then call
me/accountsto get your Page access token. - Exchange it for a long-lived token (Access Token Debugger > Extend). Page tokens made from a long-lived user token do not expire.
- Paste the Page token into the n8n Facebook Graph API credential.
Step 4: Find your two IDs
| ID | How to get it | Goes in |
|---|---|---|
| Facebook Page ID | Page > About > Page transparency, or call me/accounts | fb_page_id in Set Brand Context |
| Instagram Business account ID | Call {page-id}?fields=instagram_business_account | ig_user_id in Set Brand Context |
Step 5: API keys for the AI steps
- Gemini: aistudio.google.com > Get API key. In n8n create a Header Auth credential, name
x-goog-api-key, value your key. - Cloudflare Workers AI: Cloudflare dashboard > Workers AI > create an API token. Create a Header Auth credential, name
Authorization, valueBearer YOUR_TOKEN. - Copy your Cloudflare account ID (dashboard sidebar) and paste it into the Generate Image URL, replacing
YOUR_CLOUDFLARE_ACCOUNT_ID.
Step 6: Telegram, Drive and Sheets
- Telegram: message @BotFather, send
/newbot, copy the token into the n8n Telegram credential. - Google Drive and Google Sheets: connect OAuth in n8n.
- Create a sheet with a tab named
Logand columnstimestamp,prompt,image_url,status. Select it in the Log to Sheet node.
Step 7: Test
- Open the workflow and click Execute workflow on the Telegram Trigger, then message your bot.
- Approve the caption, then the image.
- Confirm the post on Facebook and Instagram and a new row in the Log tab.
- Activate the workflow.
Want this built around your business?
Your tone, your approval flow, your channels. Book a free 30 minute call.
Book a free 30 minute callTroubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Instagram error about media type | Image is not JPEG | Keep the Convert to JPEG node in place |
| Instagram cannot fetch image | Drive file not public or link is a preview link | Keep Make File Public and the direct-download URL node |
| (#10) permission error | Missing instagram_content_publish or wrong token | Regenerate token with all permissions in Step 3 |
| Container never reaches FINISHED | Image too large or wrong ratio | Keep 1:1 and the 1440 px resize |
| Telegram trigger does not fire | n8n not on HTTPS | Use an HTTPS domain or a tunnel |
| Token stopped working | Short-lived token used | Extend to long-lived and regenerate the Page token |
Safety notes
- Drive images are shared with "anyone with the link" so Meta can fetch them. Use a dedicated folder and delete old images.
- Never paste tokens into a shared workflow or template.