{
  "name": "Create real estate listing video ads with Videotok",
  "nodes": [
    {
      "parameters": {
        "content": "## Create real estate listing video ads with Videotok\n\n### How it works\n\n1. The workflow is manually triggered to start.\n2. Real estate listing details are set up in the workflow.\n3. An ad text is generated using OpenAI's API.\n4. A payload for Videotok is built from the gathered data.\n5. The payload is sent to create a video ad via the Videotok API.\n\n### Setup steps\n\n- [ ] Ensure OpenAI API credentials are configured for the 'Post to OpenAI for Ad Text' node.\n- [ ] Ensure Videotok API credentials are configured for the 'Post to Videotok API' node.\n\n### Customization\n\nModify the 'Set Real Estate Listing Details' node to input your own listing details.",
        "width": 480,
        "height": 624
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-1232, 0],
      "id": "685cad66-c13e-4a5b-8085-77612c238183",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "content": "## Workflow trigger and setup\n\nStarts the workflow and sets the real estate listing details",
        "width": 464,
        "height": 304,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-672, 0],
      "id": "06e73f6a-40bb-4cea-9021-0f6c642f7efa",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "## Generate ad text\n\nUses OpenAI to generate ad copy for the listing",
        "width": 816,
        "height": 272,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-128, 16],
      "id": "bc89c529-e4a6-40a9-87ea-c77ba4651380",
      "name": "Sticky Note2"
    },
    {
      "parameters": {},
      "id": "manual",
      "name": "Manually Initiate Workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-624, 128]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "address",
              "name": "address",
              "type": "string",
              "value": "Via Torino 21, Milan"
            },
            {
              "id": "details",
              "name": "listing_details",
              "type": "string",
              "value": "Bright two-bedroom apartment, renovated kitchen, balcony, close to metro and parks."
            },
            {
              "id": "images",
              "name": "listing_image_urls",
              "type": "array",
              "value": [
                "https://example.com/living-room.jpg",
                "https://example.com/kitchen.jpg"
              ]
            }
          ]
        }
      },
      "id": "listing-source",
      "name": "Set Listing Details",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [-352, 128]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/responses",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$vars.OPENAI_API_KEY}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"model\":\"gpt-4.1-mini\",\"input\":\"Create real-estate video ad JSON. Include title, hook, script, generation_prompt, caption, compliance_notes. Avoid unsupported claims. Input: \" + JSON.stringify($json)}"
      },
      "id": "openai-real-estate",
      "name": "Generate Ad Text with OpenAI",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-80, 128]
    },
    {
      "parameters": {
        "jsCode": "const listing = $('Set Listing Details').first().json;\nconst raw = $input.first().json.output_text || '{}';\nlet brief;\ntry { brief = JSON.parse(raw); } catch { brief = { title: listing.address, generation_prompt: raw, caption: raw }; }\nreturn [{ json: { type: 'video_ad', template_slug: 'viral-video-ads', prompt: brief.generation_prompt, aspect_ratio: '9:16', duration: 8, quality_tier: 'high', reference_image_urls: listing.listing_image_urls || [], brand_kit_id: $vars.VIDEOTOK_BRAND_KIT_ID, idempotency_key: `real-estate-listing-${$execution.id}`, caption: brief.caption, compliance_notes: brief.compliance_notes } }];"
      },
      "id": "prepare-listing",
      "name": "Prepare Videotok Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [224, 128]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://videotok.app/api/v1/generations",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$vars.VIDEOTOK_API_KEY}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "Idempotency-Key",
              "value": "={{$json.idempotency_key}}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{$json}}"
      },
      "id": "create-listing-ad",
      "name": "Create Video Ad in Videotok",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [544, 128]
    }
  ],
  "connections": {
    "Manually Initiate Workflow": {
      "main": [
        [
          {
            "node": "Set Listing Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Listing Details": {
      "main": [
        [
          {
            "node": "Generate Ad Text with OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Ad Text with OpenAI": {
      "main": [
        [
          {
            "node": "Prepare Videotok Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Videotok Data": {
      "main": [
        [
          {
            "node": "Create Video Ad in Videotok",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "tags": ["videotok", "openai", "real estate", "listing ads"],
  "active": false,
  "versionId": "videotok-real-estate-listing-video-ads-1"
}
