-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkflow.js
More file actions
173 lines (173 loc) · 6.47 KB
/
Workflow.js
File metadata and controls
173 lines (173 loc) · 6.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
{
"name": "My workflow",
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-816,
-208
],
"id": "2f3c89a6-8713-4fe2-a4ab-3bce660d042e",
"name": "When clicking ‘Execute workflow’"
},
{
"parameters": {
"method": "POST",
"url": "https://router.huggingface.co/v1/chat/completions",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_HUGGINGFACE_API_KEY_HERE"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"model\": \"meta-llama/Llama-3.2-3B-Instruct\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are recording a YouTube Short right now. Speak directly to the camera. Do not describe what you're doing - just speak naturally as if you're filming. No titles, no descriptions, no meta-text. Just talk.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"You are filming a {{ $json.videoStyle }} YouTube Short about {{ $json.topic }}. Start speaking now (60 seconds max):\"\n }\n ],\n \"max_tokens\": 300,\n \"temperature\": 0.8\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-656,
-16
],
"id": "977f2acd-b189-4b09-bb9a-3044d0a4ab20",
"name": "HTTP Request"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "81081b0d-c3e8-485c-835f-b86c33db7739",
"name": "topic",
"value": "5 Amazing Facts About Genshin Impact",
"type": "string"
},
{
"id": "df691218-044b-4b3e-ab83-5c458c363f74",
"name": "videoStyle",
"value": "Funny and engaging",
"type": "string"
},
{
"id": "35f082bb-d23e-4faa-952c-89305cf633c4",
"name": "duration",
"value": "60 seconds",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-512,
-208
],
"id": "1dbd872a-94d7-40f4-b5a1-5b577f13d97d",
"name": "Edit Fields"
},
{
"parameters": {
"jsCode": "// Get the AI-generated script\nlet script = $input.first().json.choices[0].message.content;\n\n// Find the first sentence that looks like actual content (starts with caps or common words)\nconst lines = script.split('\\n');\nlet startIndex = 0;\n\n// Skip lines that contain meta keywords\nfor (let i = 0; i < lines.length; i++) {\n const line = lines[i].toLowerCase();\n if (!line.includes('script') && \n !line.includes('youtube') && \n !line.includes('short') &&\n !line.includes('calming') &&\n !line.includes('style') &&\n !line.includes('60-second') &&\n line.trim().length > 20) {\n startIndex = i;\n break;\n }\n}\n\n// Take everything from that point on\nconst cleanedLines = lines.slice(startIndex);\nlet finalScript = cleanedLines.join(' ').replace(/\\*\\*/g, '').trim();\n\nconst sentences = finalScript.match(/[^\\.!\\?]+[\\.!\\?]+/g) || [finalScript];\n\nreturn [{\n json: {\n fullScript: finalScript,\n sentences: sentences,\n sentenceCount: sentences.length,\n debug: `Skipped ${startIndex} lines`\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-416,
-16
],
"id": "36090292-3ba8-4913-806b-f63f15ee4a35",
"name": "Code in JavaScript"
},
{
"parameters": {
"url": "https://api.pexels.com/v1/search?query=yoga&per_page=1&orientation=portrait",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "YOUR_PEXELS_API_KEY_HERE"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-880,
256
],
"id": "02fa31e7-418b-4849-bea3-802ec742e11b",
"name": "Generate Scene Image"
},
{
"parameters": {
"url": "={{ $json.photos[0].src.large }}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-672,
256
],
"id": "96a2ae52-187b-4556-8034-0bea6389d182",
"name": "Download Image"
},
{
"parameters": {
"method": "POST",
"url": "https://api.sws.speechify.com/v1/audio/speech",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "Bearer YOUR_SPEECHIFY_API_KEY_HERE"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "{\n \"input\": \"Script for a 60-second YouTube Short on Morning Yoga for Productivity in a Calming and Upbeat Style. WAKE UP, SLEEPYHEAD! Morning yoga is the secret to a productive day. Start your day with 5-minute morning yoga routine that boosts energy and focus.\",\n \"voice_id\": \"henry\",\n \"audio_format\": \"mp3\"\n}",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
-192,
528
],
"id": "3110da4e-1396-497f-900f-f2590ce4f3d3",
"name": "HTTP Request1"
}
],
"connections": {
"When clicking ‘Execute workflow’": { "main": [[{"node": "Edit Fields","type": "main","index": 0}]] },
"Edit Fields": { "main": [[{"node": "HTTP Request","type": "main","index": 0}]] },
"HTTP Request": { "main": [[{"node": "Code in JavaScript","type": "main","index": 0}]] }
},
"active": false,
"settings": { "executionOrder": "v1" },
"versionId": "634b76ea-a7d9-4554-a4b2-8a4607c739a2",
"id": "jUu7LOMepFFiDtUK",
"tags": [{"updatedAt": "2025-12-19T19:09:40.476Z","createdAt": "2025-12-19T19:09:40.476Z","id": "cLxtIs2tq0m6MHHu","name": "Youtube Automation"}]
}