DJM
ToInvested AI Coach
Online — Ask me anything

One quick thing —
Drop your email to start chatting. David sends occasional investor strategy. Unsubscribe anytime.

You've used your 5 free messages.
Unlock unlimited AI coaching with Wealth Builder.

Join Wealth Builder — $79/mo → Use the free analyzers instead
// ══════════════════════════════════════════ const TI_MODEL = 'claude-sonnet-4-20250514'; const TI_FREE_LIMIT = 5; const STORAGE_EMAIL = 'ti_coach_email'; const STORAGE_COUNT = 'ti_coach_count'; const COACH_SYSTEM = `You are the ToInvested AI Coach — built on the expertise of David J. Moore, MBA, President & CEO of YPN Inc. David has 20+ years in real estate investing, mortgage consulting, luxury residential, commercial development, and investor education. Your role: Answer real estate investing, finance, tax strategy, legal structure, and wealth-building questions in a clear, direct, friendly way. You speak like David — experienced, honest, no fluff, genuinely helpful. Guidelines: - Keep responses concise (3-5 sentences max unless complexity requires more) - Use plain English — no unnecessary jargon - When relevant, mention ToInvested free tools: /property-analyzer/ /flip-analyzer/ /brrrr-analyzer/ /renovation-analyzer/ /stock-analyzer/ /bitcoin-analyzer/ - For deep personal analysis, invite them to /consulting/ - Never give specific legal, tax, or financial advice — recommend licensed professionals - Be honest about risks — don't hype any asset class - Plain text responses only — no markdown, no asterisks, no headers - Warm and encouraging but always truthful`; let tiHistory = []; let tiOpen = false; let tiGated = !!localStorage.getItem(STORAGE_EMAIL); let tiMsgCount = parseInt(localStorage.getItem(STORAGE_COUNT) || '0'); function tiCoachToggle() { tiOpen = !tiOpen; const win = document.getElementById('ti-coach-window'); if (tiOpen) { win.classList.add('open'); document.getElementById('ti-coach-btn').textContent = '✕'; if (tiHistory.length === 0) tiGreet(); } else { tiCoachClose(); } } function tiCoachClose() { tiOpen = false; document.getElementById('ti-coach-window').classList.remove('open'); document.getElementById('ti-coach-btn').textContent = '💬'; } function tiGreet() { const gateEl = document.getElementById('ti-coach-gate'); const inputRow = document.getElementById('ti-coach-input-row'); const paywallEl = document.getElementById('ti-coach-paywall'); if (!tiGated) { gateEl.style.display = 'block'; inputRow.style.display = 'none'; } else if (tiMsgCount >= TI_FREE_LIMIT) { paywallEl.style.display = 'block'; inputRow.style.display = 'none'; } else { gateEl.style.display = 'none'; inputRow.style.display = 'flex'; } tiAddMsg('ai', "Hey! I'm David's AI Coach — 20+ years of real estate and investing expertise, available 24/7. Ask me about deals, DSCR, entity structure, tax strategy, or anything else on your mind."); } function tiGateSubmit() { const email = document.getElementById('ti-gate-email').value.trim(); const err = document.getElementById('ti-gate-err'); if (!email || !email.includes('@') || !email.includes('.')) { err.style.display = 'block'; err.textContent = 'Please enter a valid email.'; return; } localStorage.setItem(STORAGE_EMAIL, email); tiGated = true; document.getElementById('ti-coach-gate').style.display = 'none'; document.getElementById('ti-coach-input-row').style.display = 'flex'; tiAddMsg('ai', "Perfect — let's dig in. What's your question?"); setTimeout(() => document.getElementById('ti-coach-input').focus(), 100); } function tiShowPaywall() { document.getElementById('ti-coach-input-row').style.display = 'none'; document.getElementById('ti-coach-paywall').style.display = 'block'; } function tiDismissPaywall() { document.getElementById('ti-coach-paywall').style.display = 'none'; document.getElementById('ti-coach-input-row').style.display = 'flex'; tiAddMsg('ai', 'No problem! Run a free deal analysis anytime at /tools/.'); } function tiChip(btn) { if (!tiGated) { document.getElementById('ti-coach-gate').style.display = 'block'; return; } document.getElementById('ti-coach-input').value = btn.textContent; tiCoachSend(); } function tiAddMsg(role, text) { const msgs = document.getElementById('ti-coach-msgs'); const div = document.createElement('div'); div.className = `ti-msg ti-msg-${role}`; const bubble = document.createElement('div'); bubble.className = 'ti-msg-bubble'; bubble.innerHTML = text.replace(/\n/g, '
'); div.appendChild(bubble); msgs.appendChild(div); msgs.scrollTop = msgs.scrollHeight; } function tiShowTyping() { const msgs = document.getElementById('ti-coach-msgs'); const div = document.createElement('div'); div.id = 'ti-typing'; div.innerHTML = '
'; msgs.appendChild(div); msgs.scrollTop = msgs.scrollHeight; } function tiHideTyping() { const el = document.getElementById('ti-typing'); if (el) el.remove(); } async function tiCoachSend() { if (!tiGated) { document.getElementById('ti-coach-gate').style.display = 'block'; return; } if (tiMsgCount >= TI_FREE_LIMIT) { tiShowPaywall(); return; } const input = document.getElementById('ti-coach-input'); const send = document.getElementById('ti-coach-send'); const text = input.value.trim(); if (!text) return; input.value = ''; send.disabled = true; tiAddMsg('user', text); tiHistory.push({ role: 'user', content: text }); tiMsgCount++; localStorage.setItem(STORAGE_COUNT, tiMsgCount); tiShowTyping(); try { const res = await fetch('https://api.anthropic.com/v1/messages', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': TI_API_KEY, 'anthropic-version': '2023-06-01', 'anthropic-dangerous-direct-browser-access': 'true' }, body: JSON.stringify({ model: TI_MODEL, max_tokens: 400, system: COACH_SYSTEM, messages: tiHistory }) }); const data = await res.json(); const reply = data.content?.[0]?.text || 'I had trouble with that — please try again.'; tiHistory.push({ role: 'assistant', content: reply }); if (tiHistory.length > 20) tiHistory = tiHistory.slice(-20); tiHideTyping(); tiAddMsg('ai', reply); if (tiMsgCount >= TI_FREE_LIMIT) setTimeout(tiShowPaywall, 2500); } catch(e) { tiHideTyping(); tiAddMsg('ai', 'Connection issue — please try again in a moment.'); } send.disabled = false; input.focus(); } document.addEventListener('DOMContentLoaded', () => { document.getElementById('ti-coach-input') .addEventListener('keydown', e => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); tiCoachSend(); } }); document.getElementById('ti-gate-email') .addEventListener('keydown', e => { if (e.key === 'Enter') tiGateSubmit(); }); });