clipwright/examples/n8n/README.md
pedro-bento d56455e555
All checks were successful
CI / backend-tests (push) Successful in 32s
CI / frontend-build (push) Successful in 31s
fix(publish): channel-by-id selection, DD/MM/YYYY scheduling, app-first boot (#1)
- Postiz publishing now selects exact channels by integration id; identifier
  mapping fixes instagram-standalone (was 'not connected') and multiple channels
  per network (was first-only); settings.__type uses the real identifier
- Publish modal lists all channels, DD/MM/YYYY + HH:MM scheduling with validation,
  surfaces backend errors and a success confirmation
- Remove AWS/S3 clip backup and ElevenLabs voice dubbing (server, UI, tests, docs)
- Boot straight into the app; remove the landing/launch screen
- CI backend-tests runs in a python:3.11-slim container (Forgejo has no 3.11 cache)

Reviewed-on: #1
Co-authored-by: pedro-bento <mail@pbento.pt>
Co-committed-by: pedro-bento <mail@pbento.pt>
2026-10-04 20:07:42 +01:00

5 KiB

Clipwright + n8n

Two importable workflows, from a one-shot clipper to a channel watcher.

Both run against a self-hosted Clipwright instance (point them at your base URL, default http://localhost:8000) and publish through a self-hosted Postiz instance. No Clipwright API key is required, but the server needs a Google Gemini key for the AI stages, and Postiz needs the target channels connected. The publishing, queue and analytics calls need the instance configured with POSTIZ_URL / POSTIZ_API_KEY (or an X-Postiz-Key header sent per request); the workflow nodes hold no credential of their own.

Workflow What it does Credentials
clipwright-clip-and-notify.json A video URL goes in through a form, clips come back on a signed webhook. No polling. None (self-hosted)
clipwright-content-machine.json Watches your YouTube channel: daily clipping, approval buttons in Telegram, drip-scheduled posting through Postiz, weekly analytics digest. Telegram bot

Shared setup

  1. In n8n: Workflows → Import from file → pick the workflow.

  2. Set CLIPWRIGHT_URL / the request base URL to your instance (http://localhost:8000).

  3. Open the Clips ready (webhook) node, copy its production URL, and paste it as webhook_url inside the Start Clipwright job node body.

  4. Optional: change webhook_secret. Clipwright signs the webhook body with HMAC-SHA256 and sends it as X-Clipwright-Signature: sha256=<hex>; verify it in a Code node with:

    const crypto = require('crypto');
    const expected = 'sha256=' + crypto
      .createHmac('sha256', 'change-me')
      .update(JSON.stringify($json.body))
      .digest('hex');
    

The Content Machine

clipwright-content-machine.json runs your channel in four acts:

  1. Watch — once a day it reads your channel's RSS feed (https://www.youtube.com/feeds/videos.xml?channel_id=UC...) and clips one video: the newest upload if there is one, otherwise the next unprocessed video from your back catalog. One video a day keeps processing predictable.
  2. Approve from your phone — every finished clip lands in Telegram with ✅ Publish / ❌ Skip buttons. Clips over Telegram's ~20 MB URL limit fall back to a link message with the same buttons.
  3. Drip-publish — each approved clip takes the next free daily slot and is scheduled through POST /api/postiz/post to the connected Postiz channels. The example node uses the legacy platforms list; swap it for integration_ids (from GET /api/postiz/integrations) to target an exact channel, since several channels of the same network are distinct entries. Approve five clips today, fill five days of content. The slot comes from the queue the server actually holds (GET /api/postiz/scheduled), so two clips approved seconds apart cannot book the same one.
  4. Sunday digest — once a week it lists the channels connected in Postiz (GET /api/postiz/integrations) and reports each channel's impressions over the last 7 days (GET /api/postiz/analytics?integration=<id>&days=7).

Machine-specific setup, all inside sticky notes on the canvas:

  • Put your channel id in the Channel RSS feed node.
  • Create a Telegram bot with @BotFather, add the Telegram bot credential, and replace YOUR_TELEGRAM_CHAT_ID in the notification nodes (message your bot, then check api.telegram.org/bot<token>/getUpdates for your chat id).
  • Connect your social accounts in your self-hosted Postiz instance — the posting step uses them directly; no extra social credentials in n8n.

Note: the machine remembers which videos it already processed in n8n workflow static data, which only persists for production executions — test runs in the editor won't advance it. Scheduling deliberately does not use that mechanism (see act 3).

Webhook payload

{
  "event": "job.completed",
  "job_id": "…",
  "status": "completed",
  "clips": [
    { "index": 0, "title": "…", "video_url": "…" }
  ]
}

Failed jobs fire the same webhook with "event": "job.failed" and an error field, so the flow never hangs waiting.

Each video_url is relative to your instance unless the server sets PUBLIC_API_URL; point it at a host Telegram can reach (a localhost instance is not reachable from Telegram's servers).

Publishing and analytics API

Direct posting: POST /api/postiz/post (accepts scheduled_date, ISO-8601). Prefer integration_ids from GET /api/postiz/integrations to pick an exact channel (multiple channels per network are supported); platforms is the legacy fallback. Connected channels: GET /api/postiz/integrations. Publishing queue: GET /api/postiz/scheduled, and DELETE /api/postiz/scheduled/{id} to cancel one before it goes out. Analytics: GET /api/postiz/analytics?integration=<id>&days=7 (one channel) and GET /api/postiz/analytics/posts?post_id=<id>&days=7 (one post) — both the channel and the post id are required. Full API reference: /docs (OpenAPI) on your instance.