AI sedang berpikir...
Masri.Cloud
AI
Wealth
Coach
Coach keuangan berbasis AI untuk pelajar, guru, & UMKM Indonesia 🇮🇩
1
Profil
2
Mode
3
Hasil
👤
Profil Kamu
Tipe Pengguna
Pilih tipe…
🎓 Siswa / Mahasiswa
📚 Guru / Dosen
🛍️ Pelaku UMKM
💼 Karyawan
🖥️ Freelancer
Rentang Penghasilan
Pilih rentang…
Di bawah Rp 1 juta
Rp 1 – 3 juta
Rp 3 – 5 juta
Rp 5 – 10 juta
Di atas Rp 10 juta
Tujuan Keuangan
Pilih tujuan…
💰 Mulai menabung
📈 Mulai investasi
🔓 Bebas dari utang
🛡️ Bangun dana darurat
🚀 Cari penghasilan tambahan
🏖️ Pensiun dini
Waktu Tersedia per Hari
Pilih waktu…
Kurang dari 30 menit
30 – 60 menit
1 – 2 jam
Lebih dari 2 jam
No. WhatsApp (untuk reminder)
+62
Lanjut →
← Kembali
⚡
Pilih Mode AI
🧠
Mindset
Ubah pola pikir keuangan
💵
Income
Strategi tambah penghasilan
🔍
Opportunity
Temukan peluang terbaik
📈
Investment
Panduan investasi pemula
🗓️
Routine
Bangun kebiasaan harian
🌟
Vision
Klarifikasi tujuan hidup
🤖 Generate Insight AI
← Mode Lain
✨
Hasil Coaching
—
Insight
—
Checklist Aksi
Aksi Hari Ini
→
—
Contoh Nyata
—
📲
Reminder WhatsApp terkirim ke nomor kamu!
💾 Simpan Progres
// ── CONFIG ────────────────────────────────────────────────── // Replace with your deployed Google Apps Script URL const GAS_URL = 'https://script.google.com/macros/s/AKfycbyQqdBtkDfnPhhNm0gyIKAE-c17BL8fvII2CWiepcR2uGDEpR3ddPcoPPTb7oQDvsiZoQ/exec'; // ── STATE ──────────────────────────────────────────────────── let userProfile = {}; let selectedMode = null; let lastResult = null; let userId = null; // ── STEP NAVIGATION ────────────────────────────────────────── function setStep(n) { ['step1','step2','step3'].forEach((id,i) => { document.getElementById(id).classList.toggle('hidden', i+1 !== n); }); // Stepper UI for(let i=1;i<=3;i++){ const s = document.getElementById('s'+i); s.classList.remove('active','done'); if(i < n) s.classList.add('done'); if(i === n) s.classList.add('active'); if(i < 3){ const l = document.getElementById('l'+i); l.classList.toggle('done', i < n); } } window.scrollTo({top:0,behavior:'smooth'}); } function goStep1() { setStep(1); } function goStep2() { setStep(2); } // ── VALIDATE & GO STEP 2 ───────────────────────────────────── function goStep2from1() { const fields = ['user_type','income_level','goal','time_available']; for(const f of fields){ if(!document.getElementById(f).value){ toast('Lengkapi semua field dulu ya! 😊','error'); return; } } userProfile = { user_type: document.getElementById('user_type').value, income_level: document.getElementById('income_level').value, goal: document.getElementById('goal').value, time_available: document.getElementById('time_available').value, phone: document.getElementById('phone').value, }; setStep(2); } // Override goStep2 to validate first function goStep2() { goStep2from1(); } // ── MODE SELECT ────────────────────────────────────────────── function selectMode(mode, el) { document.querySelectorAll('.mode-btn').forEach(b => b.classList.remove('selected')); el.classList.add('selected'); selectedMode = mode; } // ── GENERATE AI ────────────────────────────────────────────── async function generateAI() { if (!selectedMode) { toast('Pilih mode AI dulu! ⚡','error'); return; } showLoading(true); // First save user profile try { const saveRes = await postGAS({ action: 'save_user', ...userProfile }); if (saveRes && saveRes.user_id) userId = saveRes.user_id; } catch(e) { console.warn('save_user failed silently:', e); } // Generate AI try { const body = { action: 'generate_ai', mode: selectedMode, ...userProfile }; const res = await postGAS(body); if (!res || !res.insight) throw new Error('Invalid response from AI'); lastResult = res; renderResult(res); setStep(3); // Send WA if phone provided if (userProfile.phone && userId) { sendWA(userProfile.phone, userId); } } catch(err) { toast('Gagal generate AI. Coba lagi! 😓','error'); console.error(err); } finally { showLoading(false); } } // ── RENDER RESULT ──────────────────────────────────────────── function renderResult(data) { const modeLabels = { mindset:'🧠 Mindset', income:'💵 Income', opportunity:'🔍 Opportunity', investment:'📈 Investment', routine:'🗓️ Routine', vision:'🌟 Vision' }; document.getElementById('modeBadge').textContent = modeLabels[selectedMode] || selectedMode; document.getElementById('resInsight').textContent = data.insight || '—'; document.getElementById('resAction').textContent = data.action_today || '—'; document.getElementById('resExample').textContent = data.example || '—'; const cl = document.getElementById('resChecklist'); cl.innerHTML = ''; const items = Array.isArray(data.checklist) ? data.checklist : []; items.forEach((item, i) => { const id = 'chk'+i; cl.innerHTML += `
${item}
`; }); } // ── SAVE ACTIVITY ──────────────────────────────────────────── async function saveActivity() { if (!lastResult) return; showLoading(true); try { await postGAS({ action: 'save_activity', user_id: userId || 'anon', mode: selectedMode, result_json: JSON.stringify(lastResult), status: 'done' }); toast('Progres tersimpan! 🎉','success'); } catch(e) { toast('Gagal simpan, coba lagi','error'); } finally { showLoading(false); } } // ── SEND WA ────────────────────────────────────────────────── async function sendWA(phone, uid) { try { await postGAS({ action: 'send_wa', phone: '62' + phone.replace(/^0/,''), user_id: uid }); document.getElementById('waNote').style.display = 'flex'; } catch(e) { console.warn('WA send failed:', e); } } // ── HTTP HELPER ────────────────────────────────────────────── async function postGAS(body) { const res = await fetch(GAS_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }); if (!res.ok) throw new Error('HTTP ' + res.status); return res.json(); } // ── LOADING ────────────────────────────────────────────────── function showLoading(show) { document.getElementById('loading').classList.toggle('show', show); } // ── TOAST ──────────────────────────────────────────────────── function toast(msg, type='info') { const wrap = document.getElementById('toastWrap'); const el = document.createElement('div'); el.className = `toast ${type}`; const icons = { success:'✓', error:'✕', info:'ℹ' }; el.innerHTML = `
${icons[type]||'ℹ'}
${msg}
`; wrap.appendChild(el); setTimeout(() => { el.classList.add('hide'); setTimeout(() => el.remove(), 350); }, 3200); }