{
  "name": "SinoDossier — Notion AI Product Research Radar & Shopify Drafts",
  "flow": [
    {
      "id": 1,
      "module": "gateway:CustomWebHook",
      "version": 1,
      "parameters": {
        "hook": 0,
        "maxResults": 1
      },
      "mapper": {},
      "metadata": {
        "designer": {
          "x": 0,
          "y": 0,
          "name": "1. Receive Winning Ad / Product URL"
        }
      }
    },
    {
      "id": 2,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": {
        "handleErrors": true,
        "useNewZLibDeCompress": true
      },
      "mapper": {
        "url": "https://api.apify.com/v2/acts/apify~e-commerce-scraping-tool/run-sync-get-dataset-items?token=YOUR_APIFY_API_TOKEN",
        "method": "post",
        "headers": [
          {
            "name": "Content-Type",
            "value": "application/json"
          }
        ],
        "bodyType": "raw",
        "parseResponse": true,
        "contentType": "application/json",
        "data": "{\"detailsUrls\":[{\"url\":\"{{1.product_url}}\"}],\"additionalProperties\":true,\"maxReviews\":50}"
      },
      "metadata": {
        "designer": {
          "x": 300,
          "y": 0,
          "name": "2. Apify Scrape Product & 1-3 Star Reviews"
        }
      }
    },
    {
      "id": 3,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": {
        "handleErrors": true,
        "useNewZLibDeCompress": true
      },
      "mapper": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "post",
        "headers": [
          {
            "name": "Authorization",
            "value": "Bearer YOUR_OPENAI_API_KEY"
          },
          {
            "name": "Content-Type",
            "value": "application/json"
          }
        ],
        "bodyType": "raw",
        "parseResponse": true,
        "contentType": "application/json",
        "data": "{\"model\":\"gpt-4o-mini\",\"response_format\":{\"type\":\"json_object\"},\"messages\":[{\"role\":\"system\",\"content\":\"You are the SinoDossier ecom-product-radar Skill. Score this ecommerce product 0-100 across Wow Factor, Margin, Review Gap, Evergreen Demand, and Shipping Friendliness. Output strict JSON with keys: product_name, category, viability_score, verdict, est_retail_price, top_pain_points, differentiation_angle, shopify_title, shopify_body_html, ad_hooks_text.\"},{\"role\":\"user\",\"content\":\"Analyze this product data: {{2.data}}\"}]}"
      },
      "metadata": {
        "designer": {
          "x": 600,
          "y": 0,
          "name": "3. Run AI Product Radar Skill (LLM)"
        }
      }
    },
    {
      "id": 4,
      "module": "json:ParseJSON",
      "version": 1,
      "parameters": {
        "type": ""
      },
      "mapper": {
        "json": "{{3.data.choices[1].message.content}}"
      },
      "metadata": {
        "designer": {
          "x": 900,
          "y": 0,
          "name": "4. Parse Scored JSON Output"
        }
      }
    },
    {
      "id": 5,
      "module": "notion:createADatabaseItem",
      "version": 1,
      "parameters": {
        "__IMTCONN__": 0
      },
      "mapper": {
        "database": "YOUR_NOTION_DATABASE_ID",
        "fields": {
          "Product Name": "{{4.product_name}}",
          "Score": "{{4.viability_score}}",
          "Verdict": "{{4.verdict}}",
          "Est Retail Price": "{{4.est_retail_price}}",
          "Top 3 Competitor Complaints": "{{4.top_pain_points}}",
          "Shopify Draft Copy": "{{4.shopify_title}} — {{4.ad_hooks_text}}",
          "Source Ad URL": "{{1.product_url}}",
          "Status": "{{if(4.viability_score >= 80; \"Approved\"; \"Needs Review\")}}"
        }
      },
      "metadata": {
        "designer": {
          "x": 1200,
          "y": 0,
          "name": "5. Add Card to Notion Product Radar"
        }
      }
    },
    {
      "id": 6,
      "module": "builtin:BasicRouter",
      "version": 1,
      "mapper": null,
      "metadata": {
        "designer": {
          "x": 1500,
          "y": 0,
          "name": "6. Route Winners (Score >= 80)"
        }
      },
      "routes": [
        {
          "flow": [
            {
              "id": 7,
              "module": "http:ActionSendData",
              "version": 3,
              "parameters": {
                "handleErrors": true,
                "useNewZLibDeCompress": true
              },
              "filter": {
                "name": "Viability Score >= 80",
                "conditions": [
                  [
                    {
                      "a": "{{4.viability_score}}",
                      "b": "80",
                      "o": "number:greaterOrEqual"
                    }
                  ]
                ]
              },
              "mapper": {
                "url": "https://YOUR_STORE.myshopify.com/admin/api/2025-01/products.json",
                "method": "post",
                "headers": [
                  {
                    "name": "X-Shopify-Access-Token",
                    "value": "YOUR_SHOPIFY_ADMIN_ACCESS_TOKEN"
                  },
                  {
                    "name": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "bodyType": "raw",
                "parseResponse": true,
                "contentType": "application/json",
                "data": "{\"product\":{\"title\":\"{{4.shopify_title}}\",\"body_html\":\"{{4.shopify_body_html}}\",\"product_type\":\"{{4.category}}\",\"status\":\"draft\",\"tags\":\"ai-radar,score-{{4.viability_score}}\"}}"
              },
              "metadata": {
                "designer": {
                  "x": 1800,
                  "y": -80,
                  "name": "7. Create Shopify Product Draft"
                }
              }
            }
          ]
        }
      ]
    }
  ],
  "metadata": {
    "instant": true,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "confidential": false,
      "dataloss": false,
      "dlq": false
    },
    "designer": {
      "orphans": []
    }
  }
}
