Khurram Badar / Archive / Courses / VillasInUAE.com — Autonomous Platform Setup Guide

VillasInUAE.com — Autonomous Platform Setup Guide

guide · 2026-03-11 · 1055 words · Khurram Badar · for professionals · practitioner

VillasInUAE.com — Autonomous Platform Setup Guide From zero to fully self-running in one afternoon --- STEP 1 — Supabase Database (15 minutes) 1. Create a new Supabase project at https://supabase.com 2.

ai · commerce · esg · infrastructure · khda

VillasInUAE.com — Autonomous Platform Setup Guide

---

STEP 1 — Supabase Database (15 minutes)

1. Create a new Supabase project at https://supabase.com
2. Go to SQL Editor → New Query
3. Run `database/schema.sql` (the main schema — 17 sections)
4. Run `database/schema-autonomous.sql` (monitoring + health tables)
5. Copy your credentials:
- Project URL → `SUPABASE_URL`
- `anon` key → `NEXT_PUBLIC_SUPABASE_ANON_KEY`
- `service_role` key → `SUPABASE_SERVICE_KEY` *(keep secret)*

---

STEP 2 — Anthropic API (5 minutes)

1. Get API key at https://console.anthropic.com
2. Set `ANTHROPIC_API_KEY`

> SIRAJ™ uses `claude-haiku-4-5-20251001` — fast + cost-effective
> Estimated cost: ~$8–15/month for full platform usage

---

STEP 3 — WhatsApp Business API (30 minutes)

1. Go to https://developers.facebook.com → Create App → Business
2. Add "WhatsApp" product
3. Set up a WhatsApp Business Account (WABA)
4. Get a phone number (or use the free test number first)
5. Create a System User with full permissions → generate permanent token
6. Set credentials:
- `WHATSAPP_PHONE_NUMBER_ID` — from App Dashboard
- `WHATSAPP_ACCESS_TOKEN` — permanent system user token
- `WHATSAPP_WEBHOOK_TOKEN` — any random string you choose

7. Configure Webhook in Meta App Dashboard:
- URL: `https://villasinuae.com/api/whatsapp/webhook`
- Verify Token: same as `WHATSAPP_WEBHOOK_TOKEN`
- Subscribe to: `messages`, `message_deliveries`, `message_reads`

8. Submit these message templates for Meta approval (1–3 days):
- `new_listing_alert_v3`
- `price_drop_alert_v2`
- `broker_listing_claim_v1`
- `weekly_market_report_v1`
- `off_plan_launch_v1`
*(See template bodies in whatsapp/whatsapp-engine.js)*

> **OWNER REPORTS**: Set `OWNER_WHATSAPP` to your personal number
> Format: +971XXXXXXXXX (E.164 format)
> You'll receive the daily report at 9am UAE time every day

---

STEP 4 — Meta Graph API for Social (20 minutes)

1. In the same Facebook App, add "Facebook Login" + "Instagram Graph API"
2. Add permissions: `pages_manage_posts`, `pages_read_engagement`,
`instagram_basic`, `instagram_content_publish`
3. Go through App Review to get these permissions approved
4. Set:
- `META_APP_ID`
- `META_APP_SECRET`
- `META_WEBHOOK_VERIFY_TOKEN` — random string for webhook verification

5. Configure Lead Ads webhook (for buyer lead capture):
- URL: `https://villasinuae.com/api/meta/lead-webhook`
- Subscribe to: `leadgen`
- `META_PAGE_ACCESS_TOKEN` — your platform's page token

---

STEP 5 — Email via Resend (10 minutes)

1. Create account at https://resend.com
2. Add and verify your domain (villasinuae.com)
3. Add DNS records: SPF, DKIM, DMARC *(Resend guides you through this)*
4. Set:
- `RESEND_API_KEY`
- `RESEND_FROM_EMAIL=alerts@villasinuae.com`
- `RESEND_FROM_NAME=VillasInUAE`

5. Set `OWNER_EMAIL` to your personal email for daily reports

---

STEP 6 — Apify Scrapers (15 minutes)

1. Create account at https://apify.com
2. Subscribe to these actors (all have free tiers):
- `dhrumil/bayut-scraper`
- `dhrumil/propertyfinder-scraper`
- `parseforge/uae-dubai-property-leads-scraper`
3. Set `APIFY_TOKEN` from your Apify account settings

---

STEP 7 — Telegram Bot (20 minutes)

1. Message @BotFather on Telegram → `/newbot`
2. Get your Bot Token
3. Go to https://my.telegram.org → API Development Tools
4. Create an app → get `API_ID` and `API_HASH`
5. Set environment variables:
- `TELEGRAM_API_ID`
- `TELEGRAM_API_HASH`
- `TELEGRAM_PHONE` — your phone number (for initial auth)
6. Deploy the Python bot:
```bash
pip install telethon supabase anthropic python-dotenv aiohttp
python scraper/telegram-monitor.py
```
*(Run on a VPS — Railway, Render, or DigitalOcean $4/month droplet)*

---

STEP 8 — Deploy to Vercel (10 minutes)

1. Push code to GitHub
2. Connect repo at https://vercel.com
3. Add ALL environment variables in Vercel Project Settings → Environment Variables
4. Set `CRON_SECRET` — a long random string (guards all cron endpoints)
5. Vercel automatically reads `vercel.json` and schedules all 14 cron jobs

**Verify deployment:**
- Visit `https://villasinuae.com/admin` → should show dashboard
- Trigger a manual health check from the dashboard
- Check that `OWNER_WHATSAPP` receives a test message

---

ENVIRONMENT VARIABLES — Complete List

```env
# ── Supabase ──────────────────────────────────────────────────
SUPABASE_URL=https://xxxxxxxx.supabase.co
SUPABASE_SERVICE_KEY=<redacted>
NEXT_PUBLIC_SUPABASE_ANON_KEY=<redacted>

── AI (SIRAJ) ────────────────────────────────────────────────

── WhatsApp Business API ─────────────────────────────────────

── Meta (Facebook/Instagram) ─────────────────────────────────

── Email ─────────────────────────────────────────────────────

── Scrapers ──────────────────────────────────────────────────

── Telegram ─────────────────────────────────────────────────

── Platform ──────────────────────────────────────────────────

── Owner Reporting (YOU) ────────────────────────────────────

---

WHAT RUNS AUTOMATICALLY (zero action from you)

| Time (UAE) | What Happens |
|---------------|------------------------------------------------------------|
| Every 2 min | Smart alerts dispatched (email + WhatsApp) |
| Every 5 min | Email sequences processed |
| Every 10 min | All systems health-checked; failures auto-healed |
| Every 4 hrs | Price drops detected → saved-listing owners notified |
| 6am + 6pm | Bayut, PropertyFinder, Dubizzle scraped (2000 listings ea) |
| 7am | Broker listings auto-posted to Facebook + Instagram |
| 8am (Mon) | Weekly business report → your WhatsApp + email |
| 9am | **Daily owner report → your WhatsApp + email** |
| 9am (Sun) | Weekly market report to all subscribers |
| 10am | Telegram broker outreach (unclaimed listings) |
| 11am | 30-day inactive users enrolled in re-engagement |
| 12pm + 6pm | More broker social posts |
| 2am | Meta access tokens refreshed before expiry |
| 3am | Expired listings removed, stats computed, cleanup |
| 1st of month | Monthly business report → your WhatsApp + email |
| Continuous | Telegram monitor (200+ channels, live feed, 24/7) |

---

YOUR DAILY REPORT (delivered 9am to your WhatsApp)

```
📊 VillasInUAE Daily Report
Thursday, 12 June

🏡 LISTINGS
New today: 847 (Total: 34,219)
Telegram: 312 | Bayut/PF: 535
Top: Dubai Hills (124), Palm Jumeirah (89), Arabian Ranches (67)

👥 USERS & LEADS
New users: 43 (Total: 12,847)
New leads: 18 | Hot leads (7+): 5
Email subscribers: +29
WhatsApp subscribers: +11

🤝 BROKERS
New registrations: 3 (Total: 287)
Monthly revenue: AED 127,500

📱 MARKETING
Social posts: 12
Smart alerts sent: 94

🟢 SYSTEMS
All systems operational ✅

🔗 Full dashboard: villasinuae.com/admin
```

---

TROUBLESHOOTING

**Cron jobs not running?**
- Verify `CRON_SECRET` is set in Vercel env vars
- Check Vercel → Functions → Logs for each cron

**WhatsApp not sending?**
- Templates must be approved by Meta before templated messages work
- During testing, use free-form messages to numbers on your test list

**Telegram bot not finding listings?**
- Make sure the bot is running on your VPS
- Check that phone number completed the initial authentication

**No scraper results?**
- Test Apify actors manually in the Apify console first
- Check the webhook URL is publicly accessible

**Admin dashboard blank?**
- Run both SQL files in Supabase in order
- Verify `ADMIN_SECRET` matches what the dashboard sends

---

ESTIMATED MONTHLY COSTS

| Service | Plan | Cost (AED) |
|---------------|---------------|------------|
| Vercel | Pro | AED 75 |
| Supabase | Pro | AED 90 |
| Resend | Pro (50K/mo) | AED 75 |
| Apify | Starter | AED 185 |
| WhatsApp API | Per-message | ~AED 110 |
| Anthropic | Pay-as-you-go | ~AED 55 |
| VPS (Telegram)| DigitalOcean | AED 15 |
| **Total** | | **~AED 605/month** |

**Break-even: 1 paid broker subscription** (Starter = AED 500/month)
**At 10 paid brokers: AED 5,000 MRR → 8x ROI on infrastructure**

← 2050Planet: Sustainability Platform ArchitectureO-Level English Language: Complete Resource Guide →
Two years of working thought, indexed.
Ask me to present it in your conference room — WhatsApp +971 55 623 9111
Book Session →