Skip to content
12.9 KB
Raw Blame
{
  "name": "My workflow 14",
  "nodes": [
    {
      "parameters": {
        "content": "# 📚 [Join our Skool community for support, premium content and more!](https://www.skool.com/ai-agents-az/about?w7)\n\n## Be part of a growing community and help us create more content like this",
        "height": 220,
        "width": 860,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [13160, 4240],
      "id": "44f740f1-7849-4d41-bf55-57bb89ad4c08",
      "name": "Sticky Note6"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [13220, 4940],
      "id": "fc1bbe6e-18d4-4f7f-a37d-275047839477",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "model": "mistral-small3.1:24b-instruct-2503-q8_0",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmOllama",
      "typeVersion": 1,
      "position": [14600, 5380],
      "id": "dab5ca2d-547f-4c97-99d5-aebb66829e60",
      "name": "Ollama Model",
      "credentials": {
        "ollamaApi": {
          "id": "cWXUsJ0LsqnzOEx0",
          "name": "Ollama account"
        }
      }
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n    \"type\": \"object\",\n    \"properties\": {\n        \"video_title\": {\n          \"type\": \"string\",\n          \"description\": \"the title of the video we use on YouTube\"\n        },\n        \"scenes\": {\n            \"type\": \"array\",\n            \"description\": \"the scenes of the video\",\n            \"items\": {\n                \"type\": \"object\",\n                \"properties\": {\n                    \"text\": {\n                        \"type\": \"string\",\n                        \"description\": \"the main content; this will be used to generate speech from\"\n                    },\n                    \"searchTerms\": {\n                        \"type\": \"array\",\n                        \"description\": \"the search terms to use to find background videos on pexels\",\n                        \"items\": {\n                            \"type\": \"string\"\n                        }\n                    }\n                },\n                \"required\": [\n                    \"text\",\n                    \"searchTerms\"\n                ]\n            }\n        }\n    },\n    \"required\": [\n        \"scenes\",\n        \"video_title\"\n    ]\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [14440, 5260],
      "id": "7767fe50-9d62-4913-97f5-3944e2f85774",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a19f9caa-f1aa-4ff0-a270-59248eeb27dd",
              "name": "SERVER_URL",
              "value": "http://host.docker.internal:3123",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [13540, 4940],
      "id": "44055b10-a562-4984-84d3-b14d6f7b8e9a",
      "name": "Configure"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=I'm creating a video programmatically using an API.\nThe API needs scenes to work with.\nEach scene requires a text, that will be transformed to speech, and 2-3 one-word search terms, that would be used to search background videos in the pexels api.\n\nCreate a short, 2 scene video about how good it is to stay in school.",
        "hasOutputParser": true
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [14280, 4940],
      "id": "d393eff0-433f-4b31-bbeb-b479af829fd8",
      "name": "Generate content",
      "retryOnFail": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Configure').item.json.SERVER_URL }}/api/short-video",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"scenes\": {{ JSON.stringify($('Generate content').item.json.output.scenes, null, 2) }},\n  \"config\": {\n    \"paddingBack\": 1500,\n    \"music\": \"{{ $json.output.musicTag }}\"\n  }\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [15220, 4940],
      "id": "e3c1ff07-1489-473e-8a08-d95ce3f62746",
      "name": "Start generating the video"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [15600, 4920],
      "id": "5add0ce3-af27-415c-8443-181609ccb1fe",
      "name": "Wait",
      "webhookId": "fe4501f9-3334-4fc8-b3dd-83ea0ebb14a2"
    },
    {
      "parameters": {
        "url": "=http://host.docker.internal:3123/api/short-video/{{ $('Start generating the video').item.json.videoId }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [16400, 4820],
      "id": "83f1eeae-144d-4fc5-a2d2-68e37a389bfb",
      "name": "Download the video",
      "alwaysOutputData": false,
      "retryOnFail": false
    },
    {
      "parameters": {
        "resource": "video",
        "operation": "upload",
        "title": "={{ $('Generate content').item.json.output.video_title }}",
        "regionCode": "US",
        "categoryId": "24",
        "options": {}
      },
      "type": "n8n-nodes-base.youTube",
      "typeVersion": 1,
      "position": [16640, 4820],
      "id": "4025512b-cb9c-4c1b-a97c-121dbdf1951d",
      "name": "Share on YouTube",
      "credentials": {
        "youTubeOAuth2Api": {
          "id": "EvIEz3KvgFMPW9Ap",
          "name": "YouTube account"
        }
      },
      "disabled": true
    },
    {
      "parameters": {
        "url": "={{ $('Configure').item.json.SERVER_URL }}/api/short-video/{{ $('Start generating the video').item.json.videoId }}/status",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [15820, 4920],
      "id": "619c0f0e-a538-46f4-8197-fd71d53bfcc2",
      "name": "Check video status",
      "alwaysOutputData": false,
      "retryOnFail": false
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "6cc1bd80-2bb7-47b6-950e-be3d6a36a965",
              "leftValue": "={{ $json.status }}",
              "rightValue": "ready",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [16040, 4920],
      "id": "bc015f67-766a-4d1d-b5e5-77898937e4c5",
      "name": "Ready?"
    },
    {
      "parameters": {
        "content": "# Configure the server URL\n",
        "height": 460,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [13500, 4700],
      "id": "447819a7-7df4-46c3-8b47-5e61c13218cd",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "url": "={{ $json.SERVER_URL }}/api/music-tags",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [13820, 4940],
      "id": "be03a505-90fd-4957-a7b6-d8b704088928",
      "name": "Get music tags"
    },
    {
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n    \"type\": \"object\",\n    \"properties\": {\n        \"musicTag\": {\n            \"type\": \"string\",\n            \"description\": \"the selected music tag that goes well with the video\"\n        }\n    },\n    \"required\": [\n        \"musicTag\"\n    ]\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [14900, 5160],
      "id": "2468ffd9-a590-460d-acd0-0ec0a77ea234",
      "name": "Structured Output Parser1"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=I'm generating a video programmatically using an API. I've already generated the scenes, and your task is to find the right music tag for he video.\n\n<VideoScenes>\n{{ $json.output.scenes.map(item => item.text).map(item => `<VideoScene>${item}</VideoScene>`).join('\\n') }}\n</VideoScenes>\n\n<MusicTags>\n{{ $('Group the music tags').item.json.data.map(item => `<MusicTag>${item}</MusicTag>`).join('\\n') }}\n</MusicTags>",
        "hasOutputParser": true
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [14760, 4940],
      "id": "945e46fa-e687-4f39-92a8-be4cb4cd50e7",
      "name": "Pick the right music",
      "retryOnFail": true
    },
    {
      "parameters": {
        "aggregate": "aggregateAllItemData",
        "options": {}
      },
      "type": "n8n-nodes-base.aggregate",
      "typeVersion": 1,
      "position": [14000, 4940],
      "id": "bc28a1c1-8f82-467f-9cfb-527e8c9c3648",
      "name": "Group the music tags"
    },
    {
      "parameters": {
        "content": "# Set me up",
        "height": 360,
        "width": 200
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [15560, 4740],
      "id": "156de771-0429-4ed3-bbfc-46baf4d0e2b0",
      "name": "Sticky Note1"
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Configure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate content",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Pick the right music",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Generate content",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Configure": {
      "main": [
        [
          {
            "node": "Get music tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate content": {
      "main": [
        [
          {
            "node": "Pick the right music",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Check video status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download the video": {
      "main": [
        [
          {
            "node": "Share on YouTube",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start generating the video": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check video status": {
      "main": [
        [
          {
            "node": "Ready?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ready?": {
      "main": [
        [
          {
            "node": "Download the video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get music tags": {
      "main": [
        [
          {
            "node": "Group the music tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Pick the right music",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Pick the right music": {
      "main": [
        [
          {
            "node": "Start generating the video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Group the music tags": {
      "main": [
        [
          {
            "node": "Generate content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1fbd84d5-ed35-46b4-830c-84dea19669ba",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "636db6b6ab21a21c6458e2137f340e33dc3e49f5a1c560c8d1e2372c227cf40e"
  },
  "id": "ucEHSGg73IPzhX1n",
  "tags": []
}