RAIA™ Specification

Documentation

Just like our system has pages you can click around on in your browser, it also has "doors" in the background where other computers talk to us. These are called API Endpoints. When a tenant calls Twil

← Back to Developer Hub TEXTBOOK SPECIFICATION
RAIA™ (Real estate Artificial Intelligence Agent) Specification

Just like our system has pages you can click around on in your browser, it also has "doors" in the background where other computers talk to us. These are called API Endpoints. When a tenant calls Twil

🧩 Section A: In Plain English

API Endpoints Reference — Unified Gateway & Endpoint Catalog

Just as our system has visual pages for users, it also has machine-readable 'doors' called API Endpoints — the secure channels through which Twilio calls, Gmail emails, and nightly cron jobs all communicate with our database.

🧩 In Plain English

Just like our system has pages you can click around on in your browser, it also has "doors" in the background where other computers talk to us. These are called API Endpoints. When a tenant calls Twilio, when a landlord emails our Gmail inbox, or when our server runs a nightly check on rents—the computers use these specific endpoints to share and save data inside our secure database.

3.15 Unified API Gateway & Endpoint Reference

Interface Specification (API-REF)

The EstateAigents Next.js Portal serves as both our administrative interface and our **Sovereign API Gateway**. Every event in the Single Journey Tenancy (SJT) lifecycle—from initial telephony triage and webhook signals to scheduled database synchronization crons—is routed securely through optimized backend API endpoints.

This specification catalogs our active endpoints, detailing their authentication requirements, expected payloads, and internal transactional pipelines to support scalable third-party integrations and developer auditing.

1. Telephony & Communication Webhooks

These endpoints handle asynchronous communication inputs from external networks, converting them into structured database logs inside tbl_conversations.

POST /api/webhooks/voice/incoming

1.1 Twilio Inbound Voice Gateway

Point of entry for all incoming telephony. Initiates caller ID database lookup and dynamically answers with a customized TwiML speech-gathering prompt.

Expected Payload (Twilio Form Parameters):
{
  "From": "+447400473888",     // Caller CLI Number
  "CallSid": "CAxxxxxxxxxxxx", // Unique Twilio Call ID
  "To": "+447123456789"        // Target Bridge Number
}
Response (XML / TwiML):

Generates Polly neural audio. Prompts matched contacts by name; falls back to generic greeting, launching <Gather input="speech"> to capture spoken intent.

POST /api/webhooks/voice/triage

1.2 Telephony AI Intent Classifier & Sandbox Router

Triggered asynchronously once the caller finishes speaking. Submits spoken text to DeepSeek-V4-Flash for intent classification, processes spam rejection, and writes valid logs to Supabase.

Expected Payload (TwiML Callback):
{
  "SpeechResult": "The kitchen ceiling is leaking water under the pipe.",
  "Confidence": "0.98",
  "CallSid": "CAxxxxxxxxxxxx"
}
Internal Transaction Path:
  1. Extracts SpeechResult and feeds it into the DeepSeek structured classification prompt.
  2. If classified as spam or sales_call, returns a polite dismissal TwiML and hangs up.
  3. If valid, creates a ticket row inside tbl_conversations mapped under the matching caller's person ID.
  4. Dispatches a real-time event notification to the Sandbox staff panel.
POST /api/webhooks/telegram

1.3 Telegram Bot Ingress & Chat Gateway

Repository Code

The live codebase implementation for this specification sits within the following repository folder:

00 leading-relaxed"> Ingests chat messages, media, and voice memos sent by our field agents and support staff to the central Telegram bot (@raia_robot).

Security Gate:

Enforces cryptographic token validation via query param (?token=TELEGRAM_BOT_SECRET) to guarantee payload origin.

2. Background Synchronization & Chronology Crons

These endpoints are triggered by automated cron schedulers to process background syncs, pull data from legacy databases, and update system state.

GET /api/cron/gmail-sync

2.1 Daily GMail Ingestion & Triage Sync

Nightly cron executing at 04:00 UTC. Connects to our Google Workspace service accounts, scans new inbound customer and supplier correspondence, filters out transactional noise, and logs business-critical items.

Authentication:

Requires a secure bearer token in the headers: Authorization: Bearer CRON_SECRET_KEY.

3. Property Records, Snapshots & Billing API

These routes are utilized by the administrative portal frontend to power real-time dashboards, search for assets, and query billing data.

GET /api/properties/[id]/snapshot

3.1 Property Dynamic Asset Snapshot Endpoint

Generates and serves the dynamic state snapshot for a specific managed asset. Pulls current rent status, occupancy data, and upcoming safety compliance dates.

GET /api/billing/usage

3.2 B2B Property Portfolio Usage & SaaS Billing Ledger

Calculates the active property portfolio size for the billing period and generates the dynamic billing total under our flat £1.00 per property per month module pricing.

Repository Code

The live codebase implementation for this textbook logic sits within the following repository folder: