{
 "name": "GoMotion: sheet topic -> video -> download link",
 "flow": [
  {
   "id": 2,
   "module": "google-sheets:filterRows",
   "version": 2,
   "parameters": {
    "__IMTCONN__": null
   },
   "mapper": {
    "from": "drive",
    "spreadsheetId": "/YOUR_SHEET",
    "sheetId": "Sheet1",
    "includesHeaders": true,
    "tableFirstRow": "A1:Z1",
    "sortOrder": "asc",
    "valueRenderOption": "FORMATTED_VALUE",
    "dateTimeRenderOption": "FORMATTED_STRING",
    "limit": "20",
    "filter": [
     [
      {
       "a": "E",
       "o": "text:notequal",
       "b": "done"
      },
      {
       "a": "E",
       "o": "text:notequal",
       "b": "failed"
      }
     ]
    ]
   },
   "metadata": {
    "designer": {
     "x": 0,
     "y": 0
    }
   }
  },
  {
   "id": 1,
   "module": "builtin:BasicRouter",
   "version": 1,
   "mapper": null,
   "metadata": {
    "designer": {
     "x": 300,
     "y": 0
    }
   },
   "routes": [
    {
     "flow": [
      {
       "id": 14,
       "module": "json:TransformToJSON",
       "version": 1,
       "parameters": {
        "space": ""
       },
       "mapper": {
        "object": "{{2.`2`}}"
       },
       "metadata": {
        "designer": {
         "x": 500,
         "y": -300
        }
       },
       "filter": {
        "name": "New row with a script",
        "conditions": [
         [
          {
           "a": "{{2.`4`}}",
           "o": "text:equal",
           "b": ""
          },
          {
           "a": "{{2.`2`}}",
           "o": "exist"
          }
         ]
        ]
       }
      },
      {
       "id": 15,
       "module": "json:TransformToJSON",
       "version": 1,
       "parameters": {
        "space": ""
       },
       "mapper": {
        "object": "{{substring(ifempty(2.`3`; 2.`0`); 0; 150)}}"
       },
       "metadata": {
        "designer": {
         "x": 650,
         "y": -300
        }
       }
      },
      {
       "id": 3,
       "module": "http:ActionSendData",
       "version": 3,
       "parameters": {
        "handleErrors": false
       },
       "mapper": {
        "url": "https://gomotionai.com/v1/videos",
        "method": "post",
        "headers": [
         {
          "name": "Authorization",
          "value": "Bearer gmk_live_PUT_YOUR_KEY_HERE"
         },
         {
          "name": "Content-Type",
          "value": "application/json"
         },
         {
          "name": "Idempotency-Key",
          "value": "make-video-{{2.`__ROW_NUMBER__`}}-{{substring(md5(2.`2` + 2.`3` + 2.`8` + 2.`7`); 0; 16)}}"
         }
        ],
        "qs": [],
        "bodyType": "raw",
        "parseResponse": true,
        "authUser": "",
        "authPass": "",
        "timeout": "",
        "shareCookies": false,
        "ca": "",
        "rejectUnauthorized": true,
        "followRedirect": true,
        "useQuerystring": false,
        "gzip": true,
        "useMtls": false,
        "followAllRedirects": false,
        "contentType": "application/json",
        "data": "{\"script\": {{14.json}}, \"title\": {{15.json}}, \"voice\": \"{{trim(2.`8`)}}\"}"
       },
       "metadata": {
        "designer": {
         "x": 800,
         "y": -300
        }
       }
      },
      {
       "id": 4,
       "module": "google-sheets:updateRow",
       "version": 2,
       "parameters": {
        "__IMTCONN__": null
       },
       "mapper": {
        "from": "drive",
        "mode": "select",
        "spreadsheetId": "/YOUR_SHEET",
        "sheetId": "Sheet1",
        "rowNumber": "{{2.`__ROW_NUMBER__`}}",
        "includesHeaders": true,
        "valueInputOption": "USER_ENTERED",
        "values": {
         "4": "{{if(3.data.id; \"rendering\"; \"failed\")}}",
         "5": "{{3.data.id}}",
         "7": "{{3.data.error}}"
        }
       },
       "metadata": {
        "designer": {
         "x": 1000,
         "y": -300
        }
       }
      }
     ]
    },
    {
     "flow": [
      {
       "id": 16,
       "module": "json:TransformToJSON",
       "version": 1,
       "parameters": {
        "space": ""
       },
       "mapper": {
        "object": "{{2.`0`}}"
       },
       "metadata": {
        "designer": {
         "x": 500,
         "y": -100
        }
       },
       "filter": {
        "name": "New row with only a topic",
        "conditions": [
         [
          {
           "a": "{{2.`4`}}",
           "o": "text:equal",
           "b": ""
          },
          {
           "a": "{{2.`2`}}",
           "o": "text:equal",
           "b": ""
          },
          {
           "a": "{{2.`0`}}",
           "o": "exist"
          }
         ]
        ]
       }
      },
      {
       "id": 17,
       "module": "json:TransformToJSON",
       "version": 1,
       "parameters": {
        "space": ""
       },
       "mapper": {
        "object": "{{2.`1`}}"
       },
       "metadata": {
        "designer": {
         "x": 650,
         "y": -100
        }
       }
      },
      {
       "id": 5,
       "module": "http:ActionSendData",
       "version": 3,
       "parameters": {
        "handleErrors": false
       },
       "mapper": {
        "url": "https://gomotionai.com/v1/scripts",
        "method": "post",
        "headers": [
         {
          "name": "Authorization",
          "value": "Bearer gmk_live_PUT_YOUR_KEY_HERE"
         },
         {
          "name": "Content-Type",
          "value": "application/json"
         },
         {
          "name": "Idempotency-Key",
          "value": "make-script-{{2.`__ROW_NUMBER__`}}-{{substring(md5(2.`0` + 2.`1` + 2.`7`); 0; 16)}}"
         }
        ],
        "qs": [],
        "bodyType": "raw",
        "parseResponse": true,
        "authUser": "",
        "authPass": "",
        "timeout": "",
        "shareCookies": false,
        "ca": "",
        "rejectUnauthorized": true,
        "followRedirect": true,
        "useQuerystring": false,
        "gzip": true,
        "useMtls": false,
        "followAllRedirects": false,
        "contentType": "application/json",
        "data": "{\"channel_url\": {{17.json}}, \"topic\": {{16.json}}, \"minutes\": 2}"
       },
       "metadata": {
        "designer": {
         "x": 800,
         "y": -100
        }
       }
      },
      {
       "id": 6,
       "module": "google-sheets:updateRow",
       "version": 2,
       "parameters": {
        "__IMTCONN__": null
       },
       "mapper": {
        "from": "drive",
        "mode": "select",
        "spreadsheetId": "/YOUR_SHEET",
        "sheetId": "Sheet1",
        "rowNumber": "{{2.`__ROW_NUMBER__`}}",
        "includesHeaders": true,
        "valueInputOption": "USER_ENTERED",
        "values": {
         "4": "{{if(5.data.id; \"scripting\"; \"failed\")}}",
         "5": "{{5.data.id}}",
         "7": "{{5.data.error}}"
        }
       },
       "metadata": {
        "designer": {
         "x": 1000,
         "y": -100
        }
       }
      }
     ]
    },
    {
     "flow": [
      {
       "id": 7,
       "module": "http:ActionSendData",
       "version": 3,
       "parameters": {
        "handleErrors": false
       },
       "mapper": {
        "url": "https://gomotionai.com/v1/scripts/{{2.`5`}}",
        "method": "get",
        "headers": [
         {
          "name": "Authorization",
          "value": "Bearer gmk_live_PUT_YOUR_KEY_HERE"
         },
         {
          "name": "Content-Type",
          "value": "application/json"
         }
        ],
        "qs": [],
        "bodyType": "",
        "parseResponse": true,
        "authUser": "",
        "authPass": "",
        "timeout": "",
        "shareCookies": false,
        "ca": "",
        "rejectUnauthorized": true,
        "followRedirect": true,
        "useQuerystring": false,
        "gzip": true,
        "useMtls": false,
        "followAllRedirects": false
       },
       "metadata": {
        "designer": {
         "x": 500,
         "y": 100
        }
       },
       "filter": {
        "name": "Script being written",
        "conditions": [
         [
          {
           "a": "{{2.`4`}}",
           "o": "text:equal",
           "b": "scripting"
          }
         ]
        ]
       }
      },
      {
       "id": 18,
       "module": "json:TransformToJSON",
       "version": 1,
       "parameters": {
        "space": ""
       },
       "mapper": {
        "object": "{{7.data.result.script}}"
       },
       "metadata": {
        "designer": {
         "x": 650,
         "y": 100
        }
       },
       "filter": {
        "name": "Script ready",
        "conditions": [
         [
          {
           "a": "{{7.data.status}}",
           "o": "text:equal",
           "b": "succeeded"
          }
         ]
        ]
       }
      },
      {
       "id": 19,
       "module": "json:TransformToJSON",
       "version": 1,
       "parameters": {
        "space": ""
       },
       "mapper": {
        "object": "{{substring(ifempty(2.`3`; 7.data.result.title); 0; 150)}}"
       },
       "metadata": {
        "designer": {
         "x": 800,
         "y": 100
        }
       }
      },
      {
       "id": 8,
       "module": "http:ActionSendData",
       "version": 3,
       "parameters": {
        "handleErrors": false
       },
       "mapper": {
        "url": "https://gomotionai.com/v1/videos",
        "method": "post",
        "headers": [
         {
          "name": "Authorization",
          "value": "Bearer gmk_live_PUT_YOUR_KEY_HERE"
         },
         {
          "name": "Content-Type",
          "value": "application/json"
         },
         {
          "name": "Idempotency-Key",
          "value": "make-video-{{2.`5`}}"
         }
        ],
        "qs": [],
        "bodyType": "raw",
        "parseResponse": true,
        "authUser": "",
        "authPass": "",
        "timeout": "",
        "shareCookies": false,
        "ca": "",
        "rejectUnauthorized": true,
        "followRedirect": true,
        "useQuerystring": false,
        "gzip": true,
        "useMtls": false,
        "followAllRedirects": false,
        "contentType": "application/json",
        "data": "{\"script\": {{18.json}}, \"title\": {{19.json}}, \"voice\": \"{{trim(2.`8`)}}\"}"
       },
       "metadata": {
        "designer": {
         "x": 950,
         "y": 100
        }
       }
      },
      {
       "id": 9,
       "module": "google-sheets:updateRow",
       "version": 2,
       "parameters": {
        "__IMTCONN__": null
       },
       "mapper": {
        "from": "drive",
        "mode": "select",
        "spreadsheetId": "/YOUR_SHEET",
        "sheetId": "Sheet1",
        "rowNumber": "{{2.`__ROW_NUMBER__`}}",
        "includesHeaders": true,
        "valueInputOption": "USER_ENTERED",
        "values": {
         "4": "{{if(8.data.id; \"rendering\"; \"failed\")}}",
         "5": "{{8.data.id}}",
         "7": "{{8.data.error}}"
        }
       },
       "metadata": {
        "designer": {
         "x": 1150,
         "y": 100
        }
       }
      }
     ]
    },
    {
     "flow": [
      {
       "id": 10,
       "module": "http:ActionSendData",
       "version": 3,
       "parameters": {
        "handleErrors": false
       },
       "mapper": {
        "url": "https://gomotionai.com/v1/videos/{{2.`5`}}",
        "method": "get",
        "headers": [
         {
          "name": "Authorization",
          "value": "Bearer gmk_live_PUT_YOUR_KEY_HERE"
         },
         {
          "name": "Content-Type",
          "value": "application/json"
         }
        ],
        "qs": [],
        "bodyType": "",
        "parseResponse": true,
        "authUser": "",
        "authPass": "",
        "timeout": "",
        "shareCookies": false,
        "ca": "",
        "rejectUnauthorized": true,
        "followRedirect": true,
        "useQuerystring": false,
        "gzip": true,
        "useMtls": false,
        "followAllRedirects": false
       },
       "metadata": {
        "designer": {
         "x": 500,
         "y": 300
        }
       },
       "filter": {
        "name": "Video rendering",
        "conditions": [
         [
          {
           "a": "{{2.`4`}}",
           "o": "text:equal",
           "b": "rendering"
          }
         ]
        ]
       }
      },
      {
       "id": 21,
       "module": "builtin:BasicRouter",
       "version": 1,
       "mapper": null,
       "metadata": {
        "designer": {
         "x": 650,
         "y": 300
        }
       },
       "routes": [
        {
         "flow": [
          {
           "id": 11,
           "module": "http:ActionSendData",
           "version": 3,
           "parameters": {
            "handleErrors": false
           },
           "mapper": {
            "url": "https://gomotionai.com/v1/videos/{{2.`5`}}/export",
            "method": "post",
            "headers": [
             {
              "name": "Authorization",
              "value": "Bearer gmk_live_PUT_YOUR_KEY_HERE"
             },
             {
              "name": "Content-Type",
              "value": "application/json"
             },
             {
              "name": "Idempotency-Key",
              "value": "make-export-{{2.`5`}}"
             }
            ],
            "qs": [],
            "bodyType": "raw",
            "parseResponse": true,
            "authUser": "",
            "authPass": "",
            "timeout": "",
            "shareCookies": false,
            "ca": "",
            "rejectUnauthorized": true,
            "followRedirect": true,
            "useQuerystring": false,
            "gzip": true,
            "useMtls": false,
            "followAllRedirects": false,
            "contentType": "application/json",
            "data": "{\"quality\": \"medium\"}"
           },
           "metadata": {
            "designer": {
             "x": 800,
             "y": 250
            }
           },
           "filter": {
            "name": "Video ready",
            "conditions": [
             [
              {
               "a": "{{10.data.status}}",
               "o": "text:equal",
               "b": "succeeded"
              }
             ]
            ]
           }
          },
          {
           "id": 12,
           "module": "http:ActionSendData",
           "version": 3,
           "parameters": {
            "handleErrors": false
           },
           "mapper": {
            "url": "https://gomotionai.com/v1/exports/{{11.data.id}}",
            "method": "get",
            "headers": [
             {
              "name": "Authorization",
              "value": "Bearer gmk_live_PUT_YOUR_KEY_HERE"
             },
             {
              "name": "Content-Type",
              "value": "application/json"
             }
            ],
            "qs": [],
            "bodyType": "",
            "parseResponse": true,
            "authUser": "",
            "authPass": "",
            "timeout": "",
            "shareCookies": false,
            "ca": "",
            "rejectUnauthorized": true,
            "followRedirect": true,
            "useQuerystring": false,
            "gzip": true,
            "useMtls": false,
            "followAllRedirects": false
           },
           "metadata": {
            "designer": {
             "x": 1000,
             "y": 250
            }
           }
          },
          {
           "id": 13,
           "module": "google-sheets:updateRow",
           "version": 2,
           "parameters": {
            "__IMTCONN__": null
           },
           "mapper": {
            "from": "drive",
            "mode": "select",
            "spreadsheetId": "/YOUR_SHEET",
            "sheetId": "Sheet1",
            "rowNumber": "{{2.`__ROW_NUMBER__`}}",
            "includesHeaders": true,
            "valueInputOption": "USER_ENTERED",
            "values": {
             "4": "done",
             "6": "{{12.data.download_url}}"
            }
           },
           "metadata": {
            "designer": {
             "x": 1200,
             "y": 250
            }
           },
           "filter": {
            "name": "MP4 ready",
            "conditions": [
             [
              {
               "a": "{{12.data.status}}",
               "o": "text:equal",
               "b": "succeeded"
              }
             ]
            ]
           }
          }
         ]
        },
        {
         "flow": [
          {
           "id": 20,
           "module": "google-sheets:updateRow",
           "version": 2,
           "parameters": {
            "__IMTCONN__": null
           },
           "mapper": {
            "from": "drive",
            "mode": "select",
            "spreadsheetId": "/YOUR_SHEET",
            "sheetId": "Sheet1",
            "rowNumber": "{{2.`__ROW_NUMBER__`}}",
            "includesHeaders": true,
            "valueInputOption": "USER_ENTERED",
            "values": {
             "4": "failed",
             "7": "{{10.data.error}}"
            }
           },
           "metadata": {
            "designer": {
             "x": 800,
             "y": 450
            }
           },
           "filter": {
            "name": "Video failed or cancelled",
            "conditions": [
             [
              {
               "a": "{{10.data.status}}",
               "o": "text:equal",
               "b": "failed"
              }
             ],
             [
              {
               "a": "{{10.data.status}}",
               "o": "text:equal",
               "b": "cancelled"
              }
             ],
             [
              {
               "a": "{{10.data.status}}",
               "o": "text:equal",
               "b": "interrupted"
              }
             ]
            ]
           }
          }
         ]
        }
       ]
      }
     ]
    }
   ]
  }
 ],
 "metadata": {
  "instant": false,
  "version": 1,
  "scenario": {
   "roundtrips": 1,
   "maxErrors": 3,
   "autoCommit": true,
   "autoCommitTriggerLast": true,
   "sequential": true,
   "confidential": false,
   "dataloss": false,
   "dlq": false,
   "freshVariables": false
  },
  "designer": {
   "orphans": [],
   "notes": [
    {
     "moduleIds": [
      2
     ],
     "content": "Run every 15 minutes. Sheet columns A-I: topic, channel_url, script, title, status, video_id, download_url, error, voice (optional voice id from GET /v1/voices). Put your GoMotion key in the Authorization header of every HTTP module. Each run moves every row one step: new -> (scripting) -> rendering -> done. Docs: https://gomotionai.com/developers"
    }
   ]
  }
 },
 "scheduling": {
  "type": "indefinitely",
  "interval": 900
 }
}