{
  "nodes": [
    {
      "id": "73ea2951-e7dd-4f7c-81cd-78be7ef9b912",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -720,
        520
      ],
      "parameters": {
        "options": {},
        "formTitle": "Instagram to MP4",
        "formFields": {
          "values": [
            {
              "fieldLabel": "URL",
              "placeholder": "https://instagram.com/",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Instagram to MP4 Converter"
      },
      "typeVersion": 2.2
    },
    {
      "id": "0995485e-76cb-408c-b23b-bc908ffdd1a4",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        960,
        320
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "323532c9-796f-4fd0-9595-dafbff9428d4",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -200,
        540
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bcc58e3d-9609-4ec3-adb9-bc6098205818",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "success"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "03ab7c27-ec4a-4d5c-b447-0a70bd9ca951",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        140,
        780
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "8bd40b8e-ebea-40c9-b206-f2b2b38a0672",
      "name": "Google Drive Set Permission",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        620,
        240
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "resource": "file",
        "operation": "share",
        "permissionsUi": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "1562303f-831d-43e2-a2ab-c5fdb1a0933e",
      "name": "Upload To Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        320,
        240
      ],
      "parameters": {
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "1e588ad2-260f-4540-8e46-2eeb455aab95",
      "name": "Google Sheets Append Row",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        620,
        780
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "c6703dc6-ed48-41eb-ad85-594fdf819e0a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        240
      ],
      "parameters": {
        "height": 500,
        "content": "## \ud83d\udfe2 **1. On form submission**\n- **Purpose:** Acts as the trigger for the workflow.  \n- **Functionality:** Displays a form with a single field (`URL`) where users can enter the instagram video link.  \n- **Output:** Passes the entered URL to the next node for processing."
      },
      "typeVersion": 1
    },
    {
      "id": "700f9fa7-5914-45c4-83cb-f62de6cf5400",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -540,
        240
      ],
      "parameters": {
        "height": 500,
        "content": "## \ud83c\udf10 **2.Instagram Downloader API Request**\n- **Purpose:** Fetch downloadable MP4 link.  \n- **Functionality:** Sends a `POST` request to **Instagram Video Downloader API**, passing the URL from the form.  \n- **Output:** Receives a JSON response containing downloadable media links.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "62b9b97a-0281-49b3-92ef-b1861ccc22a3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -260,
        240
      ],
      "parameters": {
        "height": 500,
        "content": "## \ud83d\udd0d **3. If**\n- **Purpose:** Check for API errors.  \n- **Functionality:** Evaluates if the response contains an `error` field.  \n- **Output:** \n  - \u2705 **True Path:** Proceeds to download the MP4.  \n  - \u274c **False Path:** Goes to error handling (Wait + Sheets logging).\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1f2524e9-d5f1-47f3-b53e-774846700adb",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "height": 440,
        "content": "## \u2b07\ufe0f **4. MP4 Downloader**\n- **Purpose:** Download the video file.  \n- **Functionality:** Uses the media URL from the previous API response to download the MP4 video.  \n- **Output:** Stores the raw MP4 binary for upload.\n\n-"
      },
      "typeVersion": 1
    },
    {
      "id": "8fb52ee3-5af6-47b1-85f1-22e815cc7dbb",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        260,
        0
      ],
      "parameters": {
        "height": 400,
        "content": "## \u2601\ufe0f **5. Upload To Google Drive**\n- **Purpose:** Store video in Google Drive.  \n- **Functionality:** Uploads the downloaded MP4 into the specified Drive folder.  \n- **Output:** Returns a file ID for the uploaded file.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ccf032b8-e2c6-468d-9441-8814d6f90235",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        540,
        0
      ],
      "parameters": {
        "height": 380,
        "content": "## \ud83d\udd11 **6. Google Drive Set Permission**\n- **Purpose:** Make the file publicly accessible.  \n- **Functionality:** Sets file permissions to `Anyone with the link can view`.  \n- **Output:** Provides a sharable `webViewLink`.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "85411455-f2f5-4cb0-8e75-2dec95783723",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        20
      ],
      "parameters": {
        "height": 460,
        "content": "## \ud83d\udcc4 **7. Google Sheets**\n- **Purpose:** Log successful conversions.  \n- **Functionality:** Appends a row with:\n  - `URL` \u2192 Original Instagram link  \n  - `Drive_URL` \u2192 Sharable Google Drive MP4 link  \n- **Output:** Saves a permanent log of successful downloads."
      },
      "typeVersion": 1
    },
    {
      "id": "8caff77e-012c-4742-922f-6f5f2b004f46",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        540
      ],
      "parameters": {
        "height": 360,
        "content": "## \u23f1\ufe0f **8. Wait**\n- **Purpose:** Delay before logging failures.  \n- **Functionality:** Pauses workflow execution to avoid instant sheet logging when API errors occur.  \n- **Output:** Prevents rapid consecutive writes to Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "a7c6d5a3-1e4a-47a3-8b56-3c8db4d2d541",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        540,
        420
      ],
      "parameters": {
        "height": 480,
        "content": "## \ud83d\udcd1 **9. Google Sheets Append Row**\n- **Purpose:** Log failed conversions.  \n- **Functionality:** Appends a row with:\n  - `URL` \u2192 Original Instagram link  \n  - `Drive_URL` \u2192 `N/A` (indicating download failure)  \n- **Output:** Tracks failed attempts separately.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5ee123ce-c57c-4dae-b4a0-254986cc1da4",
      "name": "MP4 Downloader",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        60,
        260
      ],
      "parameters": {
        "url": "={{ $json.data[0].downloadUrl }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "1475e1e1-f06d-42ab-aab8-2efa657cfaa7",
      "name": "Instagram Downloader API Request",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        -500,
        520
      ],
      "parameters": {
        "url": "https://instagram-downloader51.p.rapidapi.com/download.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.URL }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "instagram-downloader51.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "yourkey"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "24f49a97-8191-4778-9782-fb86ab86f816",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1920,
        -300
      ],
      "parameters": {
        "width": 1000,
        "height": 1200,
        "content": "# \ud83d\udce5 Instagram to MP4 Converter Workflow\n\nThis **n8n workflow** automates the process of converting Instagram video URLs into downloadable MP4 files and storing them in **Google Drive**, while maintaining a detailed log of success and failure cases in **Google Sheets**.\n\n---\n\n## \ud83d\udd27 Key Features\n\n- \ud83d\udcdd **Form Input**  \n  Accepts Instagram video links through a user-friendly web form.\n\n- \ud83c\udf10 **Instagram Downloader API**  \n  Sends a `POST` request to retrieve downloadable video links via a third-party API.\n\n- \u2b07\ufe0f **Video Download**  \n  Downloads the MP4 file from the extracted media link.\n\n- \u2601\ufe0f **Google Drive Upload**  \n  Uploads the video to a Google Drive folder and sets public viewing permissions.\n\n- \ud83d\udcc4 **Success Logging**  \n  Appends successful conversions (original URL + sharable Drive link) to a Google Sheet.\n\n- \u274c **Failure Handling**  \n  If the download fails, logs the original URL with a `Drive_URL` marked as `N/A` in a separate Google Sheets row.\n\n- \u23f1\ufe0f **Wait Node**  \n  Adds a delay before logging failures to avoid rapid writes or API rate issues.\n\n---\n\n## \u2705 Success Path\n1. Form submission \u2192  \n2. API returns video link \u2192  \n3. Video downloaded \u2192  \n4. Uploaded to Google Drive \u2192  \n5. Share link generated \u2192  \n6. Logged to Google Sheets.\n\n## \u274c Failure Path\n1. API fails or returns error \u2192  \n2. Wait \u2192  \n3. Log failed attempt in Google Sheets with `N/A` Drive link.\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "MP4 Downloader",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Google Sheets Append Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MP4 Downloader": {
      "main": [
        [
          {
            "node": "Upload To Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Instagram Downloader API Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload To Google Drive": {
      "main": [
        [
          {
            "node": "Google Drive Set Permission",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Set Permission": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram Downloader API Request": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}