feat: Add interest form endpoint and fix lead parsing

- Updated to check https://hoaledgeriq.com/api/leads
- Fixed JSON parsing (uses 'leads' key not 'submissions')
- Added proper handling for interest form fields
- Notifications now include first name, last name, org
- Detected 5 historical interest form leads
- Both endpoints now fully functional
This commit is contained in:
2026-04-08 10:30:50 -04:00
parent a009cf7d70
commit 1774148418
4 changed files with 110 additions and 9 deletions

View File

@@ -2774,3 +2774,11 @@ No new leads found
[Wed Apr 8 08:22:42 EDT 2026] Response size: 7791 bytes [Wed Apr 8 08:22:42 EDT 2026] Response size: 7791 bytes
[Wed Apr 8 08:23:10 EDT 2026] ✓ hoaledgeriq.com/api/calc-submissions responding [Wed Apr 8 08:23:10 EDT 2026] ✓ hoaledgeriq.com/api/calc-submissions responding
[Wed Apr 8 08:23:10 EDT 2026] Response size: 7791 bytes [Wed Apr 8 08:23:10 EDT 2026] Response size: 7791 bytes
[Wed Apr 8 09:00:01 EDT 2026] ✓ hoaledgeriq.com/api/calc-submissions responding
[Wed Apr 8 09:00:01 EDT 2026] Response size: 7791 bytes
[Wed Apr 8 09:17:37 EDT 2026] ✓ hoaledgeriq.com/api/calc-submissions responding
[Wed Apr 8 09:17:37 EDT 2026] Response size: 7791 bytes
[Wed Apr 8 10:00:00 EDT 2026] ✓ hoaledgeriq.com/api/calc-submissions responding
[Wed Apr 8 10:00:00 EDT 2026] Response size: 7791 bytes
[Wed Apr 8 10:17:32 EDT 2026] ✓ hoaledgeriq.com/api/calc-submissions responding
[Wed Apr 8 10:17:32 EDT 2026] Response size: 7791 bytes

View File

@@ -2003,3 +2003,87 @@
[2026-04-08 08:30:54] No submissions found [2026-04-08 08:30:54] No submissions found
[2026-04-08 08:30:54] ✓ Monitor check complete [2026-04-08 08:30:54] ✓ Monitor check complete
[2026-04-08 08:30:54] ================================================== [2026-04-08 08:30:54] ==================================================
[2026-04-08T13:00:00Z] Starting lead monitor check
[2026-04-08T13:00:01Z] ROI Calc submissions response: 7791 bytes
[2026-04-08T13:00:01Z] Processing calc submissions...
[2026-04-08T13:00:01Z] Check complete. Next run at 2026-04-08T10:00:EDT
[2026-04-08T13:17:37Z] Starting lead monitor check
[2026-04-08T13:17:37Z] ROI Calc submissions response: 7791 bytes
[2026-04-08T13:17:37Z] Processing calc submissions...
[2026-04-08T13:17:37Z] Check complete. Next run at 2026-04-08T10:17:EDT
[2026-04-08 09:31:46] ==================================================
[2026-04-08 09:31:46] Starting Sales Lead Monitor Check
[2026-04-08 09:31:46] 📊 Checking ROI Calculator...
[2026-04-08 09:31:47] 🎯 NEW: ID 7 - test@example.com
[2026-04-08 09:31:50] ✅ Notification sent for lead 7 (test@example.com)
[2026-04-08 09:31:50] 🎯 NEW: ID 6 - john5@example.com
[2026-04-08 09:31:52] ✅ Notification sent for lead 6 (john5@example.com)
[2026-04-08 09:31:52] 🎯 NEW: ID 5 - john5@example.com
[2026-04-08 09:31:53] ✅ Notification sent for lead 5 (john5@example.com)
[2026-04-08 09:31:53] 📝 Checking Interest Form...
[2026-04-08 09:31:53] ❌ Error fetching https://www.hoaledgeriq.com/api/interest-submissions: HTTP Error 404: Not Found
[2026-04-08 09:31:53] No submissions found
[2026-04-08 09:31:53] ✓ Monitor check complete
[2026-04-08 09:31:53] ==================================================
[2026-04-08T14:00:00Z] Starting lead monitor check
[2026-04-08T14:00:00Z] ROI Calc submissions response: 7791 bytes
[2026-04-08T14:00:00Z] Processing calc submissions...
[2026-04-08T14:00:00Z] Check complete. Next run at 2026-04-08T11:00:EDT
[2026-04-08T14:17:32Z] Starting lead monitor check
[2026-04-08T14:17:32Z] ROI Calc submissions response: 7791 bytes
[2026-04-08T14:17:32Z] Processing calc submissions...
[2026-04-08T14:17:32Z] Check complete. Next run at 2026-04-08T11:17:EDT
[2026-04-08 10:23:25] ==================================================
[2026-04-08 10:23:25] Starting Sales Lead Monitor Check
[2026-04-08 10:23:25] 📊 Checking ROI Calculator...
[2026-04-08 10:23:25] 🎯 NEW: ID 7 - test@example.com
[2026-04-08 10:23:28] ✅ Notification sent for lead 7 (test@example.com)
[2026-04-08 10:23:28] 🎯 NEW: ID 6 - john5@example.com
[2026-04-08 10:23:30] ✅ Notification sent for lead 6 (john5@example.com)
[2026-04-08 10:23:30] 🎯 NEW: ID 5 - john5@example.com
[2026-04-08 10:23:32] ✅ Notification sent for lead 5 (john5@example.com)
[2026-04-08 10:23:32] 📝 Checking Interest Form...
[2026-04-08 10:23:32] ❌ Error fetching http://localhost:3000/api/leads: <urlopen error [Errno 61] Connection refused>
[2026-04-08 10:23:32] No submissions found
[2026-04-08 10:23:32] ✓ Monitor check complete
[2026-04-08 10:23:32] ==================================================
[2026-04-08 10:25:05] ==================================================
[2026-04-08 10:25:05] Starting Sales Lead Monitor Check
[2026-04-08 10:25:05] 📊 Checking ROI Calculator...
[2026-04-08 10:25:06] ✓ No new submissions (last ID: 7)
[2026-04-08 10:25:06] 📝 Checking Interest Form...
[2026-04-08 10:25:06] ❌ Error fetching https://api.hoaledgeriq.com/api/leads: <urlopen error [Errno 8] nodename nor servname provided, or not known>
[2026-04-08 10:25:06] No submissions found
[2026-04-08 10:25:06] ✓ Monitor check complete
[2026-04-08 10:25:06] ==================================================
[2026-04-08 10:29:12] ==================================================
[2026-04-08 10:29:12] Starting Sales Lead Monitor Check
[2026-04-08 10:29:12] 📊 Checking ROI Calculator...
[2026-04-08 10:29:12] ✓ No new submissions (last ID: 7)
[2026-04-08 10:29:12] 📝 Checking Interest Form...
[2026-04-08 10:29:12] No submissions found
[2026-04-08 10:29:12] ✓ Monitor check complete
[2026-04-08 10:29:12] ==================================================
[2026-04-08 10:29:50] ==================================================
[2026-04-08 10:29:50] Starting Sales Lead Monitor Check
[2026-04-08 10:29:50] 📊 Checking ROI Calculator...
[2026-04-08 10:29:51] ✓ No new submissions (last ID: 7)
[2026-04-08 10:29:51] 📝 Checking Interest Form...
[2026-04-08 10:29:51] 🎯 NEW: ID 5 - jon@somedomain.com (Jonathan Tester)
[2026-04-08 10:30:12] ==================================================
[2026-04-08 10:30:12] Starting Sales Lead Monitor Check
[2026-04-08 10:30:12] 📊 Checking ROI Calculator...
[2026-04-08 10:30:12] ✓ No new submissions (last ID: 7)
[2026-04-08 10:30:12] 📝 Checking Interest Form...
[2026-04-08 10:30:13] 🎯 NEW: ID 5 - jon@somedomain.com (Jonathan Tester)
[2026-04-08 10:30:16] ✅ Notification sent for lead 5 (jon@somedomain.com)
[2026-04-08 10:30:16] 🎯 NEW: ID 4 - joe@myhoa.com (Joe Schmoe)
[2026-04-08 10:30:17] ✅ Notification sent for lead 4 (joe@myhoa.com)
[2026-04-08 10:30:17] 🎯 NEW: ID 3 - smith@example.com (Jane Smith2)
[2026-04-08 10:30:19] ✅ Notification sent for lead 3 (smith@example.com)
[2026-04-08 10:30:19] 🎯 NEW: ID 2 - jane@example123.com (Jane Winters)
[2026-04-08 10:30:21] ✅ Notification sent for lead 2 (jane@example123.com)
[2026-04-08 10:30:21] 🎯 NEW: ID 1 - john@example.com (John Warner)
[2026-04-08 10:30:23] ✅ Notification sent for lead 1 (john@example.com)
[2026-04-08 10:30:23] ✓ Monitor check complete
[2026-04-08 10:30:23] ==================================================

View File

@@ -18,7 +18,7 @@ TELEGRAM_TARGET = "telegram:8269921691"
# API Endpoints # API Endpoints
ENDPOINTS = { ENDPOINTS = {
"roi_calculator": "https://www.hoaledgeriq.com/api/calc-submissions", "roi_calculator": "https://www.hoaledgeriq.com/api/calc-submissions",
"interest_form": "https://www.hoaledgeriq.com/api/interest-submissions" "interest_form": "https://hoaledgeriq.com/api/leads"
} }
def log(message): def log(message):
@@ -73,7 +73,7 @@ def send_telegram_notification(lead_id, email, source, property_type=None, homes
if property_type: if property_type:
message += f"*Property Type:* {property_type}\n" message += f"*Property Type:* {property_type}\n"
if homesites: if homesites:
message += f"*Homesites:* {homesites:,}\n" message += f"*Homesites:* {homesites}\n"
message += f"\n*Time:* {datetime.now().strftime('%Y-%m-%d %H:%M')}" message += f"\n*Time:* {datetime.now().strftime('%Y-%m-%d %H:%M')}"
@@ -124,23 +124,26 @@ def check_interest_form(state):
log("📝 Checking Interest Form...") log("📝 Checking Interest Form...")
data = fetch_endpoint(ENDPOINTS["interest_form"]) data = fetch_endpoint(ENDPOINTS["interest_form"])
if not data or 'submissions' not in data: if not data or 'leads' not in data:
log(" No submissions found") log(" No submissions found")
return state return state
new_count = 0 new_count = 0
for submission in data['submissions']: for submission in data['leads']:
lead_id = submission.get('id') lead_id = submission.get('id')
email = submission.get('email', 'unknown') email = submission.get('email', 'unknown')
first_name = submission.get('first_name', '')
last_name = submission.get('last_name', '')
org_name = submission.get('org_name', '')
if lead_id not in state['processed_interest']: if lead_id not in state['processed_interest']:
log(f" 🎯 NEW: ID {lead_id} - {email}") log(f" 🎯 NEW: ID {lead_id} - {email} ({first_name} {last_name})")
send_telegram_notification( send_telegram_notification(
lead_id=lead_id, lead_id=lead_id,
email=email, email=email,
source="Interest Form", source="Interest Form",
property_type=submission.get('property_type', ''), property_type=f"{first_name} {last_name} ({org_name})",
homesites=submission.get('homesites') homesites=submission.get('unit_count')
) )
state['processed_interest'].append(lead_id) state['processed_interest'].append(lead_id)
new_count += 1 new_count += 1

View File

@@ -9,7 +9,7 @@
6, 6,
5 5
], ],
"last_check": "2026-04-08T08:30:54.751282", "last_check": "2026-04-08T10:30:23.552271",
"status": "active", "status": "active",
"notes": "Hourly monitoring enabled. Next check in 60 minutes.", "notes": "Hourly monitoring enabled. Next check in 60 minutes.",
"processed_roi": [ "processed_roi": [
@@ -21,5 +21,11 @@
6, 6,
5 5
], ],
"processed_interest": [] "processed_interest": [
5,
4,
3,
2,
1
]
} }