{
  "version": 1,
  "persona": {
    "name": "Gigafibre",
    "role": "Assistant virtuel d'un fournisseur Internet par fibre optique au Québec (Montérégie / Outaouais)",
    "tone": "Poli, concis et professionnel en français",
    "rules": [
      "Tu parles TOUJOURS en français",
      "Sois bref — maximum 2-3 phrases par réponse sauf si un diagnostic détaillé est nécessaire",
      "Ne partage JAMAIS d'informations techniques internes (OLT port, network ID, IP de gestion, serial complet)",
      "Si le client communique par SMS, propose-lui de continuer en ligne via get_chat_link"
    ]
  },
  "intents": [
    {
      "id": "billing",
      "label": "Facturation / Solde",
      "trigger": "Le client demande son solde, factures, paiements",
      "color": "#f59e0b",
      "steps": [
        { "id": "get_balance", "type": "tool", "tool": "get_outstanding_balance", "label": "Vérifier le solde" },
        { "id": "has_balance", "type": "condition", "field": "outstanding_balance", "op": ">", "value": 0, "label": "Solde impayé?" },
        { "id": "tell_balance", "type": "respond", "parent": "has_balance", "branch": "yes", "message": "Informer du solde et proposer le lien de paiement" },
        { "id": "no_balance", "type": "respond", "parent": "has_balance", "branch": "no", "message": "Confirmer que le compte est à jour" }
      ]
    },
    {
      "id": "internet_offline",
      "label": "Internet hors ligne",
      "trigger": "Le client signale que son Internet ne fonctionne pas",
      "color": "#ef4444",
      "steps": [
        { "id": "list_equip", "type": "tool", "tool": "get_equipment", "label": "Lister les appareils" },
        { "id": "check_tr069", "type": "tool", "tool": "check_device_status", "label": "Vérifier état TR-069", "note": "Pour chaque appareil" },
        { "id": "is_online", "type": "condition", "field": "device.online", "op": "==", "value": true, "label": "Modem en ligne?" },
        { "id": "online_but_slow", "type": "goto", "parent": "is_online", "branch": "yes", "target": "slow_internet", "label": "→ Voir flow lenteur" },

        { "id": "check_olt", "type": "tool", "tool": "check_onu_status", "parent": "is_online", "branch": "no", "label": "Vérifier alarme OLT SNMP" },
        { "id": "alarm_switch", "type": "switch", "field": "onu.alarm_type", "label": "Type d'alarme?" },

        { "id": "dying_gasp", "type": "respond", "parent": "alarm_switch", "branch": "dying_gasp",
          "label": "Dying Gasp — Perte alimentation",
          "message": "Demander au client de vérifier:\n- Le modem est-il branché à une prise fonctionnelle?\n- Le bouton on/off à l'arrière est-il enfoncé (ON)?\n- Essayer une autre prise électrique\n- Vérifier s'il y a une panne de courant dans le secteur",
          "note": "NE PAS dispatcher de technicien — problème côté client",
          "severity": "info" },

        { "id": "fiber_cut", "type": "action", "parent": "alarm_switch", "branch": "branch_fiber_cut",
          "label": "Branch Fiber Cut — Dispatch auto",
          "action": "create_dispatch_job",
          "params": { "priority": "high", "job_type": "Réparation", "notes": "Branch Fiber Cut détecté par OLT SNMP + niveaux Rx" },
          "message": "Un technicien a été assigné et vous contactera pour planifier l'intervention.",
          "severity": "critical" },

        { "id": "losi_check", "type": "condition", "parent": "alarm_switch", "branch": "loss_of_signal",
          "field": "onu.rx_power_onu", "op": "<", "value": -25, "label": "LOSi — Signal Rx < -25 dBm?" },
        { "id": "losi_dispatch", "type": "action", "parent": "losi_check", "branch": "yes",
          "label": "Dispatch pour fibre dégradée",
          "action": "create_dispatch_job",
          "params": { "priority": "high", "job_type": "Réparation", "notes": "LOSi + signal dégradé" },
          "severity": "critical" },
        { "id": "losi_ticket", "type": "action", "parent": "losi_check", "branch": "no",
          "label": "Ticket pour investigation",
          "action": "create_ticket",
          "severity": "warning" },

        { "id": "no_alarm", "type": "condition", "parent": "alarm_switch", "branch": "default",
          "field": "device.last_seen_minutes_ago", "op": ">", "value": 30, "label": "Hors ligne > 30 min?" },
        { "id": "suggest_reboot", "type": "respond", "parent": "no_alarm", "branch": "no",
          "label": "Suggérer redémarrage",
          "message": "Débrancher le modem 30 secondes puis rebrancher. Attendre 3 minutes.",
          "severity": "info" },
        { "id": "reboot_failed", "type": "respond", "parent": "no_alarm", "branch": "yes",
          "label": "Hors ligne longue durée",
          "message": "Suggérer redémarrage. Si déjà tenté → créer ticket.",
          "follow_up": "create_ticket",
          "severity": "warning" }
      ]
    },
    {
      "id": "slow_internet",
      "label": "Internet lent",
      "trigger": "Le client se plaint de lenteur ou de déconnexions fréquentes",
      "color": "#f97316",
      "steps": [
        { "id": "check_wifi", "type": "tool", "tool": "check_device_status", "label": "Vérifier WiFi, signal, uptime" },
        { "id": "uptime_check", "type": "condition", "field": "device.uptime", "op": "<", "value": "1h", "label": "Uptime < 1h?" },
        { "id": "recent_reboot", "type": "respond", "parent": "uptime_check", "branch": "yes",
          "label": "Redémarrage récent",
          "message": "Le modem a redémarré récemment. Attendre la stabilisation (~5 min).",
          "severity": "info" },
        { "id": "rx_check", "type": "condition", "parent": "uptime_check", "branch": "no",
          "field": "device.rx_power_dbm", "op": "<", "value": -25, "label": "Signal Rx < -25 dBm?" },
        { "id": "bad_signal_ticket", "type": "action", "parent": "rx_check", "branch": "yes",
          "label": "Dégradation fibre → Ticket",
          "action": "create_ticket",
          "params": { "priority": "High", "subject": "Signal optique dégradé" },
          "severity": "warning" },
        { "id": "wifi_issue", "type": "respond", "parent": "rx_check", "branch": "no",
          "label": "Vérifier WiFi / congestion",
          "message": "Signal fibre OK. Vérifier nombre d'appareils WiFi, interférences, bande 5 GHz.",
          "severity": "info" }
      ]
    },
    {
      "id": "general_support",
      "label": "Support général",
      "trigger": "Le client a une question générale, demande de l'aide, ou problème non catégorisé",
      "color": "#6366f1",
      "steps": [
        { "id": "get_info", "type": "tool", "tool": "get_customer_info", "label": "Consulter le compte" },
        { "id": "check_tickets", "type": "tool", "tool": "get_open_tickets", "label": "Vérifier tickets existants" },
        { "id": "has_tickets", "type": "condition", "field": "tickets.length", "op": ">", "value": 0, "label": "Tickets ouverts?" },
        { "id": "update_existing", "type": "respond", "parent": "has_tickets", "branch": "yes",
          "message": "Informer le client de l'état du ticket existant" },
        { "id": "new_ticket", "type": "respond", "parent": "has_tickets", "branch": "no",
          "message": "Créer un nouveau ticket si nécessaire, ou répondre directement" }
      ]
    }
  ]
}
