docs(examples): importable n8n workflow for the API + webhook loop

Form in, signed webhook out, one item per finished clip. The existing
community template (203 views) wires Whisper and Gemini directly and
never calls the OpenShorts API; this is the version worth publishing on
creators.n8n.io, kept in-repo so the template and the API cannot drift.
This commit is contained in:
juancarlos.cavero 2026-08-04 18:58:47 +02:00
parent 9f3bedecde
commit d566b1a9b7
2 changed files with 322 additions and 0 deletions

53
examples/n8n/README.md Normal file
View file

@ -0,0 +1,53 @@
# OpenShorts + n8n
Importable workflow: a video URL goes in through a form, OpenShorts clips it,
and a signed webhook brings back the finished clips. No polling.
## Import
1. In n8n: **Workflows → Import from file** → `openshorts-clip-and-notify.json`.
2. Create a **Header Auth** credential named `OpenShorts API key`:
- Name: `Authorization`
- Value: `Bearer osk_...` (create the key in your account page at
[openshorts.app](https://www.openshorts.app/))
3. Open the **Clips ready (webhook)** node, copy its production URL, and paste
it as `webhook_url` inside the **Start OpenShorts job** node body.
4. Optional: change `webhook_secret`. OpenShorts signs the webhook body with
HMAC-SHA256 and sends it as `X-OpenShorts-Signature: sha256=<hex>`; verify
it in a Code node with:
```javascript
const crypto = require('crypto');
const expected = 'sha256=' + crypto
.createHmac('sha256', 'change-me')
.update(JSON.stringify($json.body))
.digest('hex');
```
## Webhook payload
```json
{
"event": "job.completed",
"job_id": "…",
"status": "completed",
"clips": [
{ "index": 0, "title": "…", "video_url": "…", "download_url": "…" }
]
}
```
Failed jobs fire the same webhook with `"event": "job.failed"` and an `error`
field, so the flow never hangs waiting.
`download_url` is a 24-hour presigned link to the archived clip (hosted
service). On the self-hosted edition the same workflow runs against
`http://localhost:8000` with no API key.
## Publishing the clips
Each item after **One item per clip** is a finished 9:16 clip. Chain whatever
comes next: Slack/email notification, a Sheets log, or direct posting via
`POST /api/social/post`. Full API reference:
[api.openshorts.app/docs](https://api.openshorts.app/docs). Agent-native
version of the same pipeline: [openshorts.app/mcp](https://www.openshorts.app/mcp).

View file

@ -0,0 +1,269 @@
{
"name": "OpenShorts: video URL in, published-ready clips out (no polling)",
"nodes": [
{
"parameters": {
"content": "## OpenShorts + n8n, the whole loop\n\n**One HTTP request starts the job, one signed webhook ends it.** No polling loop, no wait nodes.\n\n### Setup (3 steps)\n1. Create an API key at [openshorts.app](https://www.openshorts.app/) (account page, starts with `osk_`). Add a **Header Auth** credential: name `Authorization`, value `Bearer osk_...`, and select it in the *Start OpenShorts job* node.\n2. Open the *Clips ready* webhook node, copy its **production** URL, and paste it as `webhook_url` in the *Start OpenShorts job* node body.\n3. Optional: set your own `webhook_secret`. OpenShorts signs the body with HMAC-SHA256 in the `X-OpenShorts-Signature` header (`sha256=<hex>`), so you can verify the sender.\n\n### What you get back\n`event`, `job_id`, `status`, and `clips[]` with `title`, `video_url` and a 24h `download_url` per clip. Failed jobs also fire the webhook with an `error` field, so the flow never hangs.\n\nAPI docs: https://api.openshorts.app/docs · Self-hosted works the same on your own machine (MIT).",
"height": 460,
"width": 480
},
"id": "note-setup",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [-560, -80]
},
{
"parameters": {
"formTitle": "Clip a video with OpenShorts",
"formDescription": "Paste a YouTube link (or any public video URL). You get 3-15 vertical clips with subtitles back.",
"formFields": {
"values": [
{
"fieldLabel": "Video URL",
"requiredField": true
}
]
},
"options": {}
},
"id": "form-trigger",
"name": "Video URL form",
"type": "n8n-nodes-base.formTrigger",
"typeVersion": 2,
"position": [-80, 0]
},
{
"parameters": {
"method": "POST",
"url": "https://api.openshorts.app/api/process",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"url\": \"{{ $json['Video URL'] }}\",\n \"acknowledged\": true,\n \"webhook_url\": \"PASTE_THE_PRODUCTION_URL_OF_THE_CLIPS-READY_WEBHOOK_NODE_HERE\",\n \"webhook_secret\": \"change-me\"\n}",
"options": {}
},
"id": "start-job",
"name": "Start OpenShorts job",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [180, 0],
"credentials": {
"httpHeaderAuth": {
"name": "OpenShorts API key"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "a1",
"name": "job_id",
"value": "={{ $json.job_id }}",
"type": "string"
},
{
"id": "a2",
"name": "status",
"value": "={{ $json.status }}",
"type": "string"
}
]
},
"options": {}
},
"id": "job-queued",
"name": "Job queued",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [440, 0]
},
{
"parameters": {
"httpMethod": "POST",
"path": "openshorts-clips-ready",
"options": {}
},
"id": "clips-webhook",
"name": "Clips ready (webhook)",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [-80, 320]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "c1",
"leftValue": "={{ $json.body.event }}",
"rightValue": "job.completed",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "if-completed",
"name": "Job completed?",
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [180, 320]
},
{
"parameters": {
"fieldToSplitOut": "body.clips",
"options": {}
},
"id": "split-clips",
"name": "One item per clip",
"type": "n8n-nodes-base.splitOut",
"typeVersion": 1,
"position": [440, 220]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "b1",
"name": "title",
"value": "={{ $json.title }}",
"type": "string"
},
{
"id": "b2",
"name": "download_url",
"value": "={{ $json.download_url || $json.video_url }}",
"type": "string"
}
]
},
"options": {}
},
"id": "clip-links",
"name": "Clip title + download link",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [700, 220]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "e1",
"name": "job_id",
"value": "={{ $json.body.job_id }}",
"type": "string"
},
{
"id": "e2",
"name": "error",
"value": "={{ $json.body.error }}",
"type": "string"
}
]
},
"options": {}
},
"id": "job-failed",
"name": "Job failed",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [440, 420]
},
{
"parameters": {
"content": "## Do something with the clips\n\nConnect *Clip title + download link* to whatever comes next: a Slack or email notification, a Google Sheet log, or post them directly via `POST /api/social/post`.\n\nEach item here is one finished 9:16 clip with subtitles burned in.",
"height": 220,
"width": 340
},
"id": "note-next",
"name": "Sticky Note 2",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [960, 180]
}
],
"connections": {
"Video URL form": {
"main": [
[
{
"node": "Start OpenShorts job",
"type": "main",
"index": 0
}
]
]
},
"Start OpenShorts job": {
"main": [
[
{
"node": "Job queued",
"type": "main",
"index": 0
}
]
]
},
"Clips ready (webhook)": {
"main": [
[
{
"node": "Job completed?",
"type": "main",
"index": 0
}
]
]
},
"Job completed?": {
"main": [
[
{
"node": "One item per clip",
"type": "main",
"index": 0
}
],
[
{
"node": "Job failed",
"type": "main",
"index": 0
}
]
]
},
"One item per clip": {
"main": [
[
{
"node": "Clip title + download link",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"pinData": {}
}