← Back to directory

Monitor Facebook post safety with Apify, Google Gemini and Telegram alerts

unverified

geminitelegramn8n-template

Install Guide

Draft — community verifying

Generated by claude-sonnet-auto · 5/26/2026

Prerequisites

Before you begin, ensure you have the following:

  • n8n (self-hosted or cloud) — version 1.0 or later recommended
  • An Apify account for scraping Facebook posts (apify.com)
  • A Google Gemini API-enabled Google Cloud account
  • A Telegram account to receive alerts
  • A Telegram bot created via @BotFather
  • Basic familiarity with n8n workflows and JSON

Get Your API Keys

1. Apify API Token

  1. Sign in at console.apify.com
  2. Click your profile avatar → SettingsIntegrations
  3. Under API tokens, click + Create new token
  4. Name it (e.g., n8n-facebook-monitor) and copy the token immediately

2. Google Gemini API Key

  1. Go to Google AI Studio
  2. Sign in with your Google account
  3. Click Create API key
  4. Select an existing Google Cloud project or create a new one
  5. Copy the generated API key and store it securely

Note: Ensure the Generative Language API is enabled in your Google Cloud Console.

3. Telegram Bot Token

  1. Open Telegram and search for @BotFather
  2. Send /newbot and follow the prompts (provide a name and username)
  3. Copy the bot token (format: 123456789:ABCdefGhIJKlmNoPQRstuVWXyz)
  4. To get your Chat ID:
    • Start a conversation with your bot
    • Send /start
    • Visit https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates in your browser
    • Find the "chat": {"id": ...} value in the response

Installation

Option A: n8n Cloud

  1. Log in at app.n8n.cloud
  2. Navigate to WorkflowsImport
  3. Paste the workflow JSON or upload the .json file

Option B: Self-Hosted n8n (Docker)

# Pull and run n8n with Docker
docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -v ~/.n8n:/home/node/.n8n \
  n8nio/n8n

Option C: Self-Hosted n8n (npm)

# Install n8n globally
npm install -g n8n

# Start n8n
n8n start

Once n8n is running, import the workflow:

# If you have the workflow JSON file locally
# Go to http://localhost:5678 → Workflows → Import from file

Configuration

Set up credentials inside n8n for each service. Navigate to SettingsCredentials in the n8n UI.

| Variable / Credential | Description | Where to get it | |-----------------------|-------------|-----------------| | APIFY_API_TOKEN | Authenticates requests to Apify scrapers | Apify Console → Settings → Integrations | | GEMINI_API_KEY | Authenticates requests to Google Gemini | Google AI Studio → API Keys | | TELEGRAM_BOT_TOKEN | Identifies your Telegram bot | @BotFather on Telegram | | TELEGRAM_CHAT_ID | Target chat/user to receive safety alerts | getUpdates API call (see above) | | FACEBOOK_PAGE_URL | The Facebook page or post URL(s) to monitor | The target Facebook page/post | | APIFY_ACTOR_ID | The Apify Actor used for Facebook scraping (e.g., apify/facebook-posts-scraper) | Apify Store |

Within n8n, create credentials as follows:

  • Apify: Use the HTTP Header Auth credential type, with header Authorization and value Bearer <YOUR_APIFY_TOKEN>
  • Google Gemini: Use the Google Gemini(PaLM) Api built-in credential type and paste your API key
  • Telegram: Use the built-in Telegram credential type and paste your bot token

Running the Bot

Development / Manual Testing

  1. Open n8n at http://localhost:5678
  2. Open the imported workflow
  3. Click Execute Workflow to trigger a manual run
  4. Check the execution log on the right-hand panel for each node's output

Production / Scheduled Mode

  1. In the workflow, locate the Schedule Trigger node (or Cron node)
  2. Set your desired interval (e.g., every 30 minutes)
  3. Click the Activate toggle (top-right of the workflow editor) to switch it ON
  4. n8n will now run the workflow automatically on schedule
# If running self-hosted, ensure n8n stays alive with a process manager
npm install -g pm2
pm2 start n8n -- start
pm2 save
pm2 startup

Testing

Smoke Test

  1. Trigger manually: With the workflow open, click Execute Workflow
  2. Check Apify node: Verify the Facebook scraper node returns post data (green check, non-empty output)
  3. Check Gemini node: Confirm the AI analysis node returns a safety classification in its output panel
  4. Check Telegram node: You should receive a test message in your Telegram chat within a few seconds

Verify Telegram delivery

Send a test message directly to confirm your bot token and chat ID are correct:

curl -s -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/sendMessage" \
  -d chat_id="<YOUR_CHAT_ID>" \
  -d text="n8n test message — bot is connected"

You should see the message appear in your Telegram chat immediately.


Troubleshooting

| Problem | Likely cause | Fix | |---------|-------------|-----| | Apify node returns empty results or 401 error | Invalid or missing Apify API token | Re-check the token in n8n Credentials; ensure it has not expired and the Actor ID is correct | | Gemini node returns 403 Forbidden | Generative Language API not enabled or wrong API key | Visit the Google Cloud Console and enable the API; verify the key matches the correct project | | Telegram message not delivered | Incorrect CHAT_ID or bot has never been messaged by the user | Visit https://api.telegram.org/bot<TOKEN>/getUpdates to confirm the chat ID; send /start to your bot first to initiate the conversation | | Workflow activates but never runs on schedule | n8n process was restarted and workflow was deactivated | Re-open the workflow in the editor and toggle Active back on; if using Docker/npm, ensure the container/process is persistent | | Facebook scraper returns rate-limit or access errors | Apify Actor hit Facebook's rate limits or the page is private | Increase the scraper interval, use a different Apify Actor, or verify the target Facebook page is publicly accessible | | Gemini returns unexpected safety classifications | Prompt or post content is ambiguous | Review and refine the Gemini prompt in the AI node; add explicit instructions for edge cases |

Sign in to leave feedback on this guide.

Language
n8n-workflow
Author
nguyenthieutoan
Stars
398
Source
n8n
Added
5/25/2026
Found something off? Email meow@cheesyboy.dev and we'll update the entry.