// ============================================================ // Careers Gateway — Google Apps Script Webhook // Paste this into Extensions → Apps Script in your Google Sheet // Deploy as: Web App → Execute as: Me → Access: Anyone // ============================================================ const NOTIFY_EMAIL = 'Cgabijendra@gmail.com'; const SHEET_NAME = 'Inquiries'; function doPost(e) { try { var data = JSON.parse(e.postData.contents); appendToSheet(data); sendNotificationEmail(data); return ok(); } catch (err) { return ContentService .createTextOutput(JSON.stringify({ success: false, error: err.message })) .setMimeType(ContentService.MimeType.JSON); } } // Allow CORS preflight function doGet(e) { return ok(); } function appendToSheet(data) { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheetByName(SHEET_NAME); if (!sheet) { sheet = ss.insertSheet(SHEET_NAME); sheet.appendRow([ 'Date (AEST)', 'Full Name', 'Email', 'Phone', 'Service', 'Course Name', 'CRICOS Code', 'Institution', 'Message', 'Source' ]); // Bold the header row sheet.getRange(1, 1, 1, 10).setFontWeight('bold').setBackground('#1a2744').setFontColor('#ffffff'); sheet.setFrozenRows(1); } sheet.appendRow([ data.submittedAt || new Date().toLocaleString('en-AU', { timeZone: 'Australia/Sydney' }), data.fullName || '', data.email || '', data.phone || '', data.service || '', data.courseName || '', data.cricosCode || '', data.provider || '', data.message || '', data.source || 'careersgateway.com.au', ]); } function sendNotificationEmail(data) { var subject = '🔔 New Inquiry: ' + (data.fullName || 'Unknown') + ' — ' + (data.service || 'General'); var body = '