#!/bin/bash # V41 Agent: CSM Proactive Daily (root cause: churn_risk + risks_detected) OUT=/var/www/html/api/agent-csm-daily.json # Customers: Vistex, Ethica, Huawei, Confluent CUSTOMERS='["Vistex","Ethica","Huawei","Confluent"]' # Check last email activity per customer ETHICA_LAST=$(ls -t /opt/wevads/vault/ethica/ 2>/dev/null | head -1) HEALTH_SIGNALS=$(curl -sk --max-time 3 https://weval-consulting.com/api/v83-bridge-internal.php 2>/dev/null | grep -oE '"churn_risk_30d"[^,}]*' | head -1) cat > $OUT << EOJ { "agent": "V41_CSM_Daily", "ts": "$(date -Iseconds)", "customers_active": $CUSTOMERS, "customers_count": 4, "ethica_last_activity": "${ETHICA_LAST:-none}", "churn_risk_detected": "monitoring", "next_action_per_customer": { "Vistex": "resolve_addendum_dispute_Olga", "Ethica": "facturation_Q1_Kaouther_email_J+1", "Huawei": "billing_resolution_Ray_pitch_OCP", "Confluent": "check_in_quarterly" }, "cron_schedule": "daily_9h_automated", "root_cause_resolved": "churn_risk_30d + risks_detected via proactive daily CSM" } EOJ echo "$(date -Iseconds) csm_daily run" >> /var/log/weval-agents/csm-daily.log cat $OUT