// Logic: Watch for Status Change -> Execute Action
function onEdit(e) {
const range = e.range;
const sheet = range.getSheet();
// Only trigger on 'Pipeline Progress' column changes
if (sheet.getName() === 'Application' && range.getColumn() === PIPELINE_COL) {
const status = e.value;
const row = range.getRow();
const candidate = getCandidateData(row);
if (status === 'Invite to Interview') {
// Check Quiet Hours before sending SMS
if (isQuietHours()) {
scheduleMessageForMorning(candidate);
} else {
sendTwilioSMS(candidate.phone, getTemplate('INVITE_SMS'));
}
}
}
}