{
  "name": "ReelsBuilder: stock video to post-ready output",
  "flow": [
    {
      "id": 1,
      "module": "util:SetVariables",
      "version": 1,
      "parameters": {},
      "mapper": {
        "variables": [
          {
            "name": "api_key",
            "value": "{{var.organization.REELSBUILDER_API_KEY}}"
          },
          {
            "name": "prompt",
            "value": "Why mid-size IT teams are moving to zero-trust networking. End with: Book a demo at acme.com"
          },
          {
            "name": "content_purpose",
            "value": "education"
          },
          {
            "name": "clip_type",
            "value": "tech"
          },
          {
            "name": "duration_sec",
            "value": "30"
          },
          {
            "name": "brand_name",
            "value": "Acme Cloud"
          },
          {
            "name": "brand_website_url",
            "value": "https://acme.com"
          },
          {
            "name": "brand_logo_url",
            "value": "https://acme.com/logo.png"
          },
          {
            "name": "brand_primary_color",
            "value": "#0A66C2"
          },
          {
            "name": "max_price_usd_cents",
            "value": "60"
          },
          {
            "name": "idempotency_key",
            "value": "make-{{var.scenario.id}}-{{var.scenario.executionId}}"
          }
        ],
        "scope": "roundtrip"
      },
      "metadata": {
        "designer": {
          "x": 0,
          "y": 0,
          "name": "Config (edit me)"
        }
      }
    },
    {
      "id": 2,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": {
        "handleErrors": true,
        "useNewZLibDeCompress": true
      },
      "mapper": {
        "url": "https://api.reelsbuilder.ai/api/v1/generate-and-post",
        "serializeUrl": false,
        "method": "post",
        "headers": [
          {
            "name": "Authorization",
            "value": "Bearer {{1.api_key}}"
          },
          {
            "name": "Content-Type",
            "value": "application/json"
          }
        ],
        "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": "{\n  \"dry_run\": true,\n  \"prompt\": \"{{1.prompt}}\",\n  \"content_purpose\": \"{{1.content_purpose}}\",\n  \"clip_type\": \"{{1.clip_type}}\",\n  \"duration_sec\": {{1.duration_sec}},\n  \"aspect_ratio\": \"9:16\",\n  \"include_branding\": false,\n  \"brand\": {\n    \"name\": \"{{1.brand_name}}\",\n    \"website_url\": \"{{1.brand_website_url}}\",\n    \"logo_url\": \"{{1.brand_logo_url}}\",\n    \"primary_color\": \"{{1.brand_primary_color}}\"\n  }\n}"
      },
      "metadata": {
        "designer": {
          "x": 300,
          "y": 0,
          "name": "Quote (dry run, free)"
        }
      }
    },
    {
      "id": 3,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": {
        "handleErrors": true,
        "useNewZLibDeCompress": true
      },
      "mapper": {
        "url": "https://api.reelsbuilder.ai/api/v1/generate-and-post",
        "serializeUrl": false,
        "method": "post",
        "headers": [
          {
            "name": "Authorization",
            "value": "Bearer {{1.api_key}}"
          },
          {
            "name": "Content-Type",
            "value": "application/json"
          },
          {
            "name": "Idempotency-Key",
            "value": "{{1.idempotency_key}}"
          }
        ],
        "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": "{\n  \"prompt\": \"{{1.prompt}}\",\n  \"content_purpose\": \"{{1.content_purpose}}\",\n  \"clip_type\": \"{{1.clip_type}}\",\n  \"duration_sec\": {{1.duration_sec}},\n  \"aspect_ratio\": \"9:16\",\n  \"include_branding\": false,\n  \"brand\": {\n    \"name\": \"{{1.brand_name}}\",\n    \"website_url\": \"{{1.brand_website_url}}\",\n    \"logo_url\": \"{{1.brand_logo_url}}\",\n    \"primary_color\": \"{{1.brand_primary_color}}\"\n  }\n}"
      },
      "metadata": {
        "designer": {
          "x": 600,
          "y": 0,
          "name": "Create video ($0.60)"
        }
      },
      "filter": {
        "name": "Price OK",
        "conditions": [
          [
            {
              "a": "{{2.data.data.valid}}",
              "o": "boolean:equal",
              "b": "true"
            },
            {
              "a": "{{2.data.data.price.usd_cents}}",
              "o": "number:lessorequal",
              "b": "{{1.max_price_usd_cents}}"
            }
          ]
        ]
      }
    },
    {
      "id": 4,
      "module": "builtin:BasicRepeater",
      "version": 1,
      "parameters": {},
      "mapper": {
        "start": "1",
        "repeats": "32",
        "step": "1"
      },
      "metadata": {
        "designer": {
          "x": 900,
          "y": 0,
          "name": "Poll up to ~30 min"
        }
      }
    },
    {
      "id": 5,
      "module": "util:GetVariable2",
      "version": 1,
      "parameters": {},
      "mapper": {
        "name": "rb_done"
      },
      "metadata": {
        "designer": {
          "x": 1200,
          "y": 0,
          "name": "Already finished?"
        }
      }
    },
    {
      "id": 6,
      "module": "util:FunctionSleep",
      "version": 1,
      "parameters": {},
      "mapper": {
        "duration": "{{min(60; 15 + 10 * (4.i - 1))}}"
      },
      "filter": {
        "name": "Not finished yet",
        "conditions": [
          [
            {
              "a": "{{5.rb_done}}",
              "o": "text:notequal",
              "b": "yes"
            }
          ]
        ]
      },
      "metadata": {
        "designer": {
          "x": 1500,
          "y": 0,
          "name": "Backoff sleep"
        }
      }
    },
    {
      "id": 7,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": {
        "handleErrors": true,
        "useNewZLibDeCompress": true
      },
      "mapper": {
        "url": "https://api.reelsbuilder.ai/api/v1/jobs/{{3.data.data.job_id}}",
        "serializeUrl": false,
        "method": "get",
        "headers": [
          {
            "name": "Authorization",
            "value": "Bearer {{1.api_key}}"
          }
        ],
        "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": 1800,
          "y": 0,
          "name": "Get job"
        }
      }
    },
    {
      "id": 8,
      "module": "builtin:BasicRouter",
      "version": 1,
      "mapper": null,
      "metadata": {
        "designer": {
          "x": 2100,
          "y": 0
        }
      },
      "routes": [
        {
          "flow": [
            {
              "id": 9,
              "module": "util:SetVariable2",
              "version": 1,
              "parameters": {},
              "filter": {
                "name": "Completed",
                "conditions": [
                  [
                    {
                      "a": "{{7.data.data.job.status}}",
                      "b": "completed",
                      "o": "text:equal"
                    }
                  ]
                ]
              },
              "mapper": {
                "name": "rb_done",
                "scope": "roundtrip",
                "value": "yes"
              },
              "metadata": {
                "designer": {
                  "x": 2400,
                  "y": -150,
                  "name": "Mark done"
                }
              }
            },
            {
              "id": 10,
              "module": "util:SetVariables",
              "version": 1,
              "parameters": {},
              "mapper": {
                "variables": [
                  {
                    "name": "job_id",
                    "value": "{{3.data.data.job_id}}"
                  },
                  {
                    "name": "video_url",
                    "value": "{{7.data.data.job.artifacts.videoUrl}}"
                  },
                  {
                    "name": "thumbnail_url",
                    "value": "{{7.data.data.job.artifacts.thumbnailUrl}}"
                  },
                  {
                    "name": "title",
                    "value": "{{7.data.data.job.artifacts.title}}"
                  },
                  {
                    "name": "description",
                    "value": "{{7.data.data.job.artifacts.description}}"
                  },
                  {
                    "name": "hashtags",
                    "value": "{{replace(7.data.data.job.artifacts.description; \"/^[\\s\\S]*?((?:#\\w+\\s*)*)$/\"; \"$1\")}}"
                  }
                ],
                "scope": "roundtrip"
              },
              "metadata": {
                "designer": {
                  "x": 2700,
                  "y": -150,
                  "name": "Post-ready output"
                }
              }
            }
          ]
        },
        {
          "flow": [
            {
              "id": 11,
              "module": "util:SetVariable2",
              "version": 1,
              "parameters": {},
              "filter": {
                "name": "Failed / dead_lettered / cancelled",
                "conditions": [
                  [
                    {
                      "a": "{{7.data.data.job.status}}",
                      "b": "failed",
                      "o": "text:equal"
                    }
                  ],
                  [
                    {
                      "a": "{{7.data.data.job.status}}",
                      "b": "dead_lettered",
                      "o": "text:equal"
                    }
                  ],
                  [
                    {
                      "a": "{{7.data.data.job.status}}",
                      "b": "cancelled",
                      "o": "text:equal"
                    }
                  ]
                ]
              },
              "mapper": {
                "name": "rb_done",
                "scope": "roundtrip",
                "value": "yes"
              },
              "metadata": {
                "designer": {
                  "x": 2400,
                  "y": 150,
                  "name": "Mark done"
                }
              }
            },
            {
              "id": 12,
              "module": "util:SetVariables",
              "version": 1,
              "parameters": {},
              "mapper": {
                "variables": [
                  {
                    "name": "job_id",
                    "value": "{{3.data.data.job_id}}"
                  },
                  {
                    "name": "status",
                    "value": "{{7.data.data.job.status}}"
                  },
                  {
                    "name": "error_code",
                    "value": "{{7.data.data.job.error.code}}"
                  },
                  {
                    "name": "error_message",
                    "value": "{{7.data.data.job.error.message}}"
                  },
                  {
                    "name": "retryable",
                    "value": "{{7.data.data.job.error.retryable}}"
                  }
                ],
                "scope": "roundtrip"
              },
              "metadata": {
                "designer": {
                  "x": 2700,
                  "y": 150,
                  "name": "Failure (charge refunded)"
                }
              }
            }
          ]
        }
      ]
    }
  ],
  "metadata": {
    "instant": false,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "slots": null,
      "confidential": true,
      "dataloss": false,
      "dlq": false,
      "freshVariables": false
    },
    "designer": {
      "orphans": []
    },
    "notes": [
      {
        "moduleIds": [
          1
        ],
        "content": "Set the API key as a Make custom variable REELSBUILDER_API_KEY (Organization > Variables), or replace api_key with your key. Never share a blueprint that contains a real key. Avoid double quotes in prompt or use a JSON > Create JSON module. Docs: https://reelsbuilder.ai/docs/api/workflows",
        "isFilterNote": false,
        "metadata": {
          "color": "#9138FE"
        }
      }
    ]
  }
}
