{
  "name": "Grist PM — Notifications par e-mail (Gmail)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "grist-pm-notifications",
        "responseMode": "onReceived",
        "options": {}
      },
      "id": "webhook-grist",
      "name": "Webhook Grist (PM_Notifications)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300],
      "webhookId": "grist-pm-notifications"
    },
    {
      "parameters": {
        "jsCode": "const input = $input.first().json;\nlet rows = input.body !== undefined ? input.body : input;\nif (!Array.isArray(rows)) rows = [rows];\nreturn rows.map(r => ({ json: r }));"
      },
      "id": "normalize",
      "name": "Normaliser les lignes",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [480, 300]
    },
    {
      "parameters": {
        "sendTo": "={{ $json.User_Email }}",
        "subject": "=Tâche — {{ $json.Type }}",
        "emailType": "text",
        "message": "=Bonjour,\n\n{{ $json.Message }}\n\n— Notification automatique (Gestion de projet Grist)",
        "options": {}
      },
      "id": "send-gmail",
      "name": "Envoyer l'e-mail (Gmail)",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [720, 300]
    }
  ],
  "connections": {
    "Webhook Grist (PM_Notifications)": {
      "main": [[{ "node": "Normaliser les lignes", "type": "main", "index": 0 }]]
    },
    "Normaliser les lignes": {
      "main": [[{ "node": "Envoyer l'e-mail (Gmail)", "type": "main", "index": 0 }]]
    }
  },
  "settings": {},
  "meta": {
    "description": "Variante Gmail. Après import : ouvrir le nœud « Envoyer l'e-mail (Gmail) » → créer/associer un identifiant Gmail OAuth2 (connexion via votre compte Google). Activer le workflow, copier l'URL de production du Webhook, la coller dans le webhook Grist sur la table PM_Notifications (événement Add)."
  }
}
