{
  "name": "UTPLA - Scenario 5 - Notifications evenements critiques",
  "flow": [
    {
      "id": 1,
      "module": "gateway:CustomWebHook",
      "version": 1,
      "parameters": {},
      "mapper": {},
      "metadata": {
        "designer": { "x": 0, "y": 0 },
        "restore": {},
        "parameters": [
          { "name": "hook", "type": "hook:gateway-webhook", "label": "Webhook", "required": true }
        ]
      }
    },
    {
      "id": 2,
      "module": "anthropic-claude:createAMessage",
      "version": 1,
      "parameters": {},
      "mapper": {
        "model": "claude-sonnet-4-6",
        "max_tokens": 1000,
        "messages": [
          {
            "role": "user",
            "inputType": "single",
            "content": "Tu es l'assistant operationnel d'UTPLA (biodiversite urbaine). Un evenement important vient de se produire dans notre pipeline commercial.\n\nType d'evenement : {{1.type_event}}\nDetails : {{1.details}}\nContact / entreprise concernee : {{1.contact}}\nValeur estimee / enjeu : {{1.enjeu}}\n\nGenere une synthese claire et actionnable pour la commerciale. Reponds UNIQUEMENT avec un objet JSON valide (aucun texte avant ni apres) :\n{\n  \"priorite\": \"haute|moyenne|basse\",\n  \"resume\": \"3 phrases maximum, factuelles\",\n  \"recommandations\": [\"action 1\", \"action 2\", \"action 3\"],\n  \"delai_conseille\": \"ex: sous 24h, cette semaine...\"\n}"
          }
        ]
      },
      "metadata": {
        "designer": { "x": 300, "y": 0 },
        "restore": {}
      }
    },
    {
      "id": 3,
      "module": "json:ParseJSON",
      "version": 1,
      "parameters": { "type": "" },
      "mapper": { "json": "{{2.content[].text}}" },
      "metadata": {
        "designer": { "x": 600, "y": 0 },
        "restore": {}
      }
    },
    {
      "id": 4,
      "module": "google-email:ActionSendEmail",
      "version": 1,
      "parameters": {},
      "mapper": {
        "to": [ "commerciale@utpla.fr" ],
        "subject": "[{{3.priorite}}] {{1.type_event}} - {{1.contact}}",
        "html": "<h2>Notification evenement UTPLA</h2><p><strong>Priorite :</strong> {{3.priorite}}</p><p><strong>Type :</strong> {{1.type_event}}</p><p><strong>Concerne :</strong> {{1.contact}}</p><h3>Resume</h3><p>{{3.resume}}</p><h3>Recommandations</h3><ul><li>{{3.recommandations[1]}}</li><li>{{3.recommandations[2]}}</li><li>{{3.recommandations[3]}}</li></ul><p><strong>Delai conseille :</strong> {{3.delai_conseille}}</p>"
      },
      "metadata": {
        "designer": { "x": 900, "y": 0 },
        "restore": {}
      }
    },
    {
      "id": 5,
      "module": "google-sheets:addRow",
      "version": 2,
      "parameters": {},
      "mapper": {
        "mode": "map",
        "insertUnformatted": false,
        "spreadsheetId": "REMPLACER_PAR_ID_GOOGLE_SHEET",
        "sheetId": "Log_Notifications",
        "tableFirstRow": "A1:Z1",
        "values": {
          "0": "{{now}}",
          "1": "{{1.type_event}}",
          "2": "{{1.contact}}",
          "3": "{{3.priorite}}",
          "4": "{{3.resume}}",
          "5": "Envoyee"
        }
      },
      "metadata": {
        "designer": { "x": 1200, "y": 0 },
        "restore": {}
      }
    }
  ],
  "metadata": {
    "instant": true,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "confidential": false,
      "dataloss": false,
      "dlq": false,
      "freshVariables": false
    },
    "designer": { "orphans": [] },
    "zone": "eu2.make.com",
    "notes": [
      "DECLENCHEUR : webhook (module 1). PAYLOAD attendu (JSON) : type_event, details, contact, enjeu.",
      "CONNEXIONS A AJOUTER : Anthropic Claude (module 2), Gmail (module 4), Google Sheets (module 5).",
      "GOOGLE SHEET 'Log_Notifications' colonnes A:Date B:Type C:Contact D:Priorite E:Resume F:Statut. Remplacer spreadsheetId du module 5.",
      "{{now}} insere la date/heure d'execution (fonction native Make)."
    ]
  }
}
