Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

AI Facebook Post Automation (n8n)

banner

An n8n workflow that researches, drafts, and publishes Facebook posts on a schedule or on-demand — with a human approval step and built-in duplicate-content detection.

What it does

  • Triggers on a 12-hour schedule or an on-demand Telegram message
  • Authenticates incoming Telegram messages against an allow-listed chat ID; everything else is silently ignored
  • Researches a current, relevant news item or statistic via SerpApi before writing
  • Generates a post with an LLM agent (GPT-4.1), following a fixed voice/structure/length spec
  • Checks for duplicates against the last 20 published posts (stored in workflow static data) — both an exact-text pass and a "same opening hook" pass
  • Sends the draft to Telegram for approval, flagging any possible duplicate, with a 24-hour response window
  • Publishes to Facebook via the Zernio API (Previously Late API) only after approval, then logs the post to history
  • Notifies you on Telegram for every outcome: published, rejected, or failed to publish

Flow overview

Trigger (Telegram msg OR schedule)
  → Auth check (Telegram only)
  → Normalize input
  → Load recent post history
  → Generate post (LLM agent + news search tool)
  → Duplicate check
  → Send to Telegram for approval
      → Approved  → Publish to Facebook → Log to history → Notify success
      → Rejected  → Notify rejection
      → Publish error → Notify failure (post text included so you can post manually)

Screeshot

screenshot

Requirements

  • An n8n instance (cloud or self-hosted) with LangChain nodes enabled
  • API credentials for:
    • OpenAI (post generation)
    • Telegram Bot API (approval flow + notifications)
    • SerpApi (news/trend search)
    • Late API (Facebook publishing) — or swap in your own Facebook-publishing node/integration

Setup

  1. Import autopost_facebook.json into n8n.
  2. Attach your own credentials to each node that references one (OpenAI, Telegram, SerpApi, Late).
  3. Replace every occurrence of YOUR_TELEGRAM_CHAT_ID with your personal Telegram chat ID:
    • If Chat Authorized (the comparison value)
    • Notify Published, Notify Rejected, Notify Publish Failed, Request Approval (the chatId field)
  4. Replace YOUR_FACEBOOK_ACCOUNT_ID in the Create post node with your Late-connected Facebook page/account ID.
  5. Adjust the system prompt in Generate Facebook Post to match your niche, tone, and posting themes — it currently defaults to an AI-automation-agency voice.
  6. Activate the workflow.

To trigger a post on demand, just message your Telegram bot from the authorized chat.

Deduplication notes

Recent posts are stored in n8n's built-in workflow static data — no external database required. This is fine for single-instance, moderate-volume use, but it's tied to this specific workflow's JSON. If you plan to duplicate or version this workflow, or want persistent analytics, swap the storage for Airtable, Postgres, or Google Sheets. Future commits will work on this.

Error handling

The Create post node uses continueErrorOutput, so a failed Facebook publish doesn't crash the run — it instead sends you a Telegram alert with the full post text so you can publish manually if needed.

Customizing content

The generation prompt (system message on Generate Facebook Post) controls topic themes, tone, structure, and constraints (no fake stats, no hard-sell language, etc.). Edit it directly to fit your brand.

Acknowledgments

Built together with Abdelrahman TC — thanks for your help.

License

MIT — see LICENSE.

About

n8n workflow that auto-generates and publishes Facebook posts with LLM-driven content, duplicate detection, and human-in-the-loop approval via Telegram.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors