{
  "nodes": [
    {
      "id": "66851ee6-ce40-453e-b264-8fdf0955a4a4",
      "name": "When New Video",
      "type": "n8n-nodes-base.rssFeedReadTrigger",
      "position": [
        176,
        0
      ],
      "parameters": {
        "feedUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=123",
        "pollTimes": {
          "item": [
            {
              "hour": 10
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5e818051-bc8d-4a09-91f5-0782a5d3e4b5",
      "name": "Create a clip",
      "type": "@reka-ai/n8n-nodes-reka.rekaVision",
      "position": [
        384,
        0
      ],
      "parameters": {
        "video_urls": "={{ $json.link }}",
        "requestOptions": {},
        "additionalFields": {
          "subtitles": true
        }
      },
      "credentials": {
        "rekaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6c235203-45e5-448b-baa6-c52b734e4419",
      "name": "Counter Init",
      "type": "n8n-nodes-base.set",
      "position": [
        576,
        0
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"counter\": 0\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "b76b2bdc-d5b4-43fb-aef5-a09fd474ca30",
      "name": "Counter +1",
      "type": "n8n-nodes-base.set",
      "position": [
        1184,
        0
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"my_field_1\": {{ $('Counter Init').item.json.counter +1 }} \n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "ed358c41-6ded-4a52-9f6f-a7427c443d80",
      "name": "If MAX Reached",
      "type": "n8n-nodes-base.if",
      "position": [
        1520,
        208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "154cd90a-9814-46bc-aa7d-1078fdc14d00",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $('Counter Init').item.json.counter }}",
              "rightValue": 10
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "54ed1b10-9d61-4e5b-b4a6-8b19eeaff265",
      "name": "If Completed",
      "type": "n8n-nodes-base.if",
      "position": [
        1360,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e9b91fbc-9116-425c-910b-116648c733ed",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Get Job Status').item.json.status }}",
              "rightValue": "completed"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "75a0419c-c020-4ea4-9b9c-4db862d9aca0",
      "name": "Send Failure EMail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1728,
        192
      ],
      "parameters": {
        "sendTo": "me@example.com",
        "message": "=Hi,\nThere is a problem with the creation of your clip for the video: {{ $('When New Video').item.json.link }}\n\nIt takes longer then planned, we invite you to look for more details in your 8n8 automation.",
        "options": {},
        "subject": "Oops..."
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "bed33d40-f47c-454c-a9c1-00ecd0ea597c",
      "name": "Send Clip Ready EMail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1728,
        -16
      ],
      "parameters": {
        "sendTo": "me@example.com",
        "message": "=Hello! Your clip is ready to be downloded. \n\nTitle: {{ $('Get Job Status').item.json.output[0].title }}  \n\nDownload it here: {{ $('Get Job Status').item.json.output[0].video_url }} \n\nDescription: {{ $('Get Job Status').item.json.output[0].caption }}\n\n",
        "options": {},
        "subject": "Your Clip is ready"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "d0d5b094-f5d4-484d-a38a-e8c6a0e1831f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        224
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 112,
        "content": "## Looping\n- After 15 minutes check if the job status is equal to \"completed\"\n- Exit after 10 checks to avoid an infinite loop"
      },
      "typeVersion": 1
    },
    {
      "id": "653c478e-9cf4-4841-880e-b76c813bd841",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        -208
      ],
      "parameters": {
        "color": 7,
        "width": 544,
        "height": 192,
        "content": "## Customize\n- **When New Video**: Set the Feed URL to the YouTube channel you want to follow (ex: https://www.youtube.com/feeds/videos.xml?channel_id=UCAr20GBQayL-nFPWFnUHNAA )\n- **Create a clip**: Change the prompt and adjust the setting to your preferences\n- **Send ___ EMail**: Personalize the email the way you like."
      },
      "typeVersion": 1
    },
    {
      "id": "dc436486-677f-470e-a6ac-1527043b6b43",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        -304
      ],
      "parameters": {
        "width": 624,
        "height": 816,
        "content": "## Try It Out!\n**This n8n template demonstrates how to use Reka Vision to automatically generate a customized video clip from a YouTube video using AI. The workflow keeps you informed by sending an email when the work is done, ready to be published on social!**\n\n### How it works\n- Looking at the RSS feed of a YouTube channel, the flow will be triggered when there is a new video published.\n- Using Reka's Community Node we will submit a request to create a clip using AI. You can customize: \n  - The template used\n  - The prompt to generate the clip\n  - If you want captions or not\n  - The minimum or maximum duration of the clip\n- Wait a little while, the magic happens.\n- Check if the job status is **completed**\n  - If **yes**, it send an success **email**\n  - If **no**, it will **loop**\n  - As a failsafe, after 10 iterations in the loop, it will send an error email \n\n### Getting Started\nEdit those nodes with your settings and credentials.\n- **When New Video**: Set the Feed URL to the YouTube channel you want to follow (ex: \n- **Create a clip**: Add your credential. Change the prompt and adjust the setting to your preferences\n- **Send ___ EMail**: Personalize the email the way you like.\n\n\n### Requirements\n- Reka AI API key (it's free! Get yours from [here from Reka](https://link.reka.ai/free))\n- Gmail account (feel free to change it to another email provider)\n\n### Need Help?\nJoin the [Discord](https://link.reka.ai/discord)\n\nHappy clipping!\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7c6725c4-625b-482b-800d-817076d710b4",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        -224
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 192,
        "content": "## \ud83d\udca1 Waiting\nGenerating the clip can take time. The video needs to be downloaded to your Reka\u2019s library, analyzed, edited, and then rendered. Adjust the waiting duration according to the duration of your video.\n#### Example\nFor 5-8 minutes, videos wait 15 minutes."
      },
      "typeVersion": 1
    },
    {
      "id": "b0ba5cbc-e3f7-465f-bffe-a6fc1c8ec9a6",
      "name": "Wait 10 minutes",
      "type": "n8n-nodes-base.wait",
      "position": [
        832,
        0
      ],
      "parameters": {
        "unit": "minutes",
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "b607adde-348a-4045-b136-fc6b74c592bc",
      "name": "Get Job Status",
      "type": "@reka-ai/n8n-nodes-reka.rekaVision",
      "position": [
        1008,
        0
      ],
      "parameters": {
        "jobId": "={{ $('Create a clip').item.json.id }}",
        "operation": "getJobtatus",
        "requestOptions": {}
      },
      "credentials": {
        "rekaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Counter +1": {
      "main": [
        [
          {
            "node": "If Completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Counter Init": {
      "main": [
        [
          {
            "node": "Wait 10 minutes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Completed": {
      "main": [
        [
          {
            "node": "Send Clip Ready EMail",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If MAX Reached",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a clip": {
      "main": [
        [
          {
            "node": "Counter Init",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Job Status": {
      "main": [
        [
          {
            "node": "Counter +1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If MAX Reached": {
      "main": [
        [
          {
            "node": "Send Failure EMail",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10 minutes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When New Video": {
      "main": [
        [
          {
            "node": "Create a clip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10 minutes": {
      "main": [
        [
          {
            "node": "Get Job Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}