Files
html/api/nps-campaign.php

35 lines
1.7 KiB
PHP

<?php
header('Content-Type: application/json');
$action = isset($_GET['action']) ? $_GET['action'] : 'status';
$emails_json = @file_get_contents('/var/www/html/api/email-drafts-registry.json');
$emails = $emails_json ? json_decode($emails_json, true) : array();
$nps_campaign = array(
'campaign' => 'V45_NPS_Q1_2026',
'ts' => date('c'),
'status' => 'READY_TO_DEPLOY',
'targets' => array(
array('customer' => 'Vistex', 'contact' => 'Olga Rumilly', 'email' => 'olga@vistex.com'),
array('customer' => 'Ethica', 'contact' => 'Kaouther Najar', 'email' => 'kaouther@ethica.tn'),
array('customer' => 'Huawei', 'contact' => 'Ray Chen', 'email' => 'ray.chen@huawei.com'),
array('customer' => 'Confluent', 'contact' => 'Kafka Team', 'email' => 'partnership@confluent.io'),
),
'nps_question' => 'On a scale 0-10, how likely are you to recommend WEVAL Consulting to a peer?',
'follow_up' => 'What is the primary reason for your score?',
'delivery_method' => 'email via WEVADS PMTA',
'target_responses' => 4,
'target_nps_score' => 50,
);
$cmd = "PGPASSWORD=admin123 psql -h 10.1.0.3 -U admin -d paperclip -tAc \"SELECT count(*) FROM public.weval_leads WHERE status='active_customer'\" 2>/dev/null";
$active = intval(trim(shell_exec($cmd)));
$out = array(
'ok' => true,
'v' => 'V45-nps-campaign',
'campaign' => $nps_campaign,
'paperclip_active_customers' => $active,
'email_drafts_available' => count($emails),
'email_drafts_list' => array_keys($emails),
'next_step' => 'send_nps_survey_campaign_via_wevads',
'root_cause_resolved' => 'nps_score pending_survey - campaign ready to deploy',
);
echo json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);