{
 "name": "S09 - Smart Inbox",
 "flow": [
  {
   "id": 1,
   "module": "google-email:triggerWatchNewEmails",
   "version": 4,
   "parameters": {
    "__IMTCONN__": null
   },
   "mapper": {
    "folder": "INBOX",
    "criteria": "UNSEEN",
    "maxResults": 5
   },
   "metadata": {
    "designer": {
     "x": 0,
     "y": 0,
     "name": "מיילים חדשים"
    }
   }
  },
  {
   "id": 2,
   "module": "regexp:HTMLToText",
   "version": 1,
   "parameters": {},
   "mapper": {
    "html": "{{1.html}}"
   },
   "metadata": {
    "designer": {
     "x": 300,
     "y": 0,
     "name": "HTML ← טקסט"
    }
   }
  },
  {
   "id": 3,
   "module": "openai-gpt-3:CreateCompletion",
   "version": 1,
   "parameters": {
    "__IMTCONN__": null
   },
   "mapper": {
    "select": "chat",
    "model": "gpt-4.1-mini",
    "temperature": "0.1",
    "max_tokens": "800",
    "response_format": "json_object",
    "messages": [
     {
      "role": "system",
      "content": "אתה מסווג מיילים נכנסים. קטגוריות: lead, support, invoice, spam, other. אל תמציא — שדה חסר = null. החזר JSON בלבד: {\"category\":\"\",\"urgency\":\"low|medium|high\",\"summary\":\"\",\"lead\":{\"name\":null,\"company\":null,\"phone\":null,\"budget\":null},\"reply\":\"\"}"
     },
     {
      "role": "user",
      "content": "מאת: {{1.from.address}}\nנושא: {{1.subject}}\n{{substring(2.text; 0; 4000)}}"
     }
    ]
   },
   "metadata": {
    "designer": {
     "x": 600,
     "y": 0,
     "name": "סיווג + חילוץ"
    }
   }
  },
  {
   "id": 4,
   "module": "json:ParseJSON",
   "version": 1,
   "parameters": {
    "type": ""
   },
   "mapper": {
    "json": "{{3.choices[].message.content}}"
   },
   "metadata": {
    "designer": {
     "x": 900,
     "y": 0,
     "name": "Parse JSON"
    }
   },
   "onerror": [
    {
     "id": 5,
     "module": "builtin:Ignore",
     "version": 1,
     "parameters": {},
     "mapper": {},
     "metadata": {
      "designer": {
       "x": 900,
       "y": 200,
       "name": "Ignore"
      }
     }
    }
   ]
  },
  {
   "id": 8,
   "module": "builtin:BasicRouter",
   "version": 1,
   "parameters": {},
   "mapper": null,
   "metadata": {
    "designer": {
     "x": 1200,
     "y": 0,
     "name": "לפי קטגוריה"
    }
   },
   "routes": [
    {
     "flow": [
      {
       "id": 6,
       "module": "google-email:createADraft",
       "version": 4,
       "parameters": {
        "__IMTCONN__": null
       },
       "mapper": {
        "to": [
         "{{1.from.address}}"
        ],
        "subject": "Re: {{1.subject}}",
        "bodyType": "rawHtml",
        "contentType": "html",
        "content": "<div dir=\"rtl\">{{4.reply}}</div>"
       },
       "metadata": {
        "designer": {
         "x": 1500,
         "y": -150,
         "name": "טיוטת תשובה"
        }
       },
       "filter": {
        "name": "lead / support",
        "conditions": [
         [
          {
           "a": "{{4.category}}",
           "o": "text:equal",
           "b": "lead"
          }
         ],
         [
          {
           "a": "{{4.category}}",
           "o": "text:equal",
           "b": "support"
          }
         ]
        ]
       }
      }
     ]
    },
    {
     "flow": [
      {
       "id": 7,
       "module": "placeholder:Placeholder",
       "version": 1,
       "parameters": {},
       "mapper": {},
       "metadata": {
        "designer": {
         "x": 1500,
         "y": 150,
         "name": "ספאם ← Gmail: Add a label (הוסיפו מודול)"
        }
       },
       "filter": {
        "name": "spam",
        "conditions": [
         [
          {
           "a": "{{4.category}}",
           "o": "text:equal",
           "b": "spam"
          }
         ]
        ]
       }
      }
     ]
    }
   ]
  }
 ],
 "metadata": {
  "instant": false,
  "version": 1,
  "scenario": {
   "roundtrips": 1,
   "maxErrors": 3,
   "autoCommit": true,
   "autoCommitTriggerLast": true,
   "sequential": false,
   "slots": null,
   "confidential": false,
   "dataloss": false,
   "dlq": true,
   "freshVariables": false
  },
  "designer": {
   "orphans": []
  },
  "zone": "eu1.make.com"
 }
}