{
  "name": "YouTube Video to Blog Post Converter",
  "nodes": [
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4-turbo",
          "mode": "list",
          "cachedResultName": "GPT-4-TURBO"
        },
        "messages": {
          "values": [
            {
              "content": "You are a helpful writing assistant.",
              "role": "system"
            },
            {
              "content": "Below is a transcript from a video we recorded. Convert this into a blog post in markdown (atx) format. Make it comprehensive, and write in a casual, spartan tone of voice."
            },
            {
              "content": "={{ $json.subtitles[0].plaintext }}"
            }
          ]
        },
        "options": {
          "maxTokens": 4096
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        860,
        240
      ],
      "id": "251170ad-5e6f-459b-993c-4e2685a9f1c5",
      "name": "Transcript to Markdown",
      "retryOnFail": true,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "mode": "markdownToHtml",
        "markdown": "={{ $json.message.content }}",
        "destinationKey": "content",
        "options": {
          "ghCodeBlocks": true,
          "ghCompatibleHeaderId": true,
          "ghMentions": true,
          "tasklists": true
        }
      },
      "type": "n8n-nodes-base.markdown",
      "typeVersion": 1,
      "position": [
        1240,
        240
      ],
      "id": "f4ebef72-7f28-4cca-a299-2c279a0e7064",
      "name": "Markdown to HTML"
    },
    {
      "parameters": {
        "folderId": "YOUR_GOOGLE_FILE_ID",
        "title": "Example Blog Post"
      },
      "type": "n8n-nodes-base.googleDocs",
      "typeVersion": 2,
      "position": [
        1460,
        240
      ],
      "id": "95203d40-9992-456e-88b7-4c40d026fd2d",
      "name": "Create Doc"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/streamers~youtube-scraper/runs",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "webhooks",
              "value": "={{ `[ { \"eventTypes\": [\"ACTOR.RUN.SUCCEEDED\"], \"requestUrl\": \"${$execution.resumeUrl}\" } ]`.base64Encode() }}"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.apify_key }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"downloadSubtitles\": true,\n  \"hasCC\": false,\n  \"hasLocation\": false,\n  \"hasSubtitles\": false,\n  \"is360\": false,\n  \"is3D\": false,\n  \"is4K\": false,\n  \"isBought\": false,\n  \"isHD\": false,\n  \"isHDR\": false,\n  \"isLive\": false,\n  \"isVR180\": false,\n  \"maxResultStreams\": 0,\n  \"maxResults\": 1,\n  \"maxResultsShorts\": 0,\n  \"preferAutoGeneratedSubtitles\": true,\n  \"saveSubsToKVS\": false,\n  \"searchKeywords\": \"Consulting\",\n  \"subtitlesFormat\": \"plaintext\",\n  \"startUrls\": [],\n  \"subtitlesLanguage\": \"any\"\n}",
        "options": {
          "response": {}
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        200,
        240
      ],
      "id": "1dbf9ed7-76a3-4c04-9e98-402a293b24b3",
      "name": "Run Apify Actor"
    },
    {
      "parameters": {
        "url": "=https://api.apify.com/v2/datasets/{{ $json.body.resource.defaultDatasetId }}/items",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "format",
              "value": "json"
            },
            {
              "name": "limit",
              "value": "100"
            },
            {
              "name": "clean",
              "value": "true"
            },
            {
              "name": "simplified",
              "value": "false"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('Edit Fields').item.json.apify_key }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        640,
        240
      ],
      "id": "ada08733-6726-4a52-9d82-6d9df5f55296",
      "name": "Get Apify Dataset",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "resume": "webhook",
        "httpMethod": "POST",
        "options": {}
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        420,
        240
      ],
      "id": "f227df24-3dca-4b46-93e2-ef4a971325c3",
      "name": "Wait Run Succeded",
      "webhookId": "53e91dd3-b1a6-4631-918a-b2f8da61a4c1"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -240,
        240
      ],
      "id": "b412c349-e40a-4f41-8a3e-7be7676426f1",
      "name": "When clicking ‘Test workflow’"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ec46e56a-4427-4ba5-a8e1-f0c5ead2f41f",
              "name": "apify_key",
              "value": "YOUR_APIFY_API_TOKEN",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -20,
        240
      ],
      "id": "9c220c7f-82ba-42f7-b6ce-95e390d78627",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://www.googleapis.com/upload/drive/v3/files/{{ $json.id }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleDocsOAuth2Api",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "uploadType",
              "value": "media"
            },
            {
              "name": "supportsAllDrives",
              "value": "true"
            }
          ]
        },
        "sendBody": true,
        "contentType": "raw",
        "body": "={{ $('Markdown to HTML').item.json.content }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1680,
        240
      ],
      "id": "e4a085b8-4bc4-4604-8cfb-c534f6c22e1b",
      "name": "Add Post in HTML to Doc"
    }
  ],
  "connections": {
    "Transcript to Markdown": {
      "main": [
        [
          {
            "node": "Markdown to HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Markdown to HTML": {
      "main": [
        [
          {
            "node": "Create Doc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Doc": {
      "main": [
        [
          {
            "node": "Add Post in HTML to Doc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Apify Actor": {
      "main": [
        [
          {
            "node": "Wait Run Succeded",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Apify Dataset": {
      "main": [
        [
          {
            "node": "Transcript to Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Run Succeded": {
      "main": [
        [
          {
            "node": "Get Apify Dataset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Run Apify Actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Post in HTML to Doc": {
      "main": [
        []
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false
}
