Automated Lead Routing Between a Property Listing App and CRM for a Riyadh Real Estate Agency to Reduce Response Time by 48%

Property app screens: listings, listing detail and the agent lead view

Project Overview

Our client, a real estate agency in Riyadh, had a property listing app and an integrated CRM system, but they were not connected. When a buyer tapped "Request a viewing" in the app, the enquiry landed in a shared email inbox.

The goal was to route all the queries to the appropriate agent within a few seconds without manual typing. The service itself needed to identify the agent by area and workload, store the complete enquiry in the CRM, and alert the manager when the agent didn't respond in time.

Our app development team automated the lead routing between the app and CRM to decrease the response time.

Business Challenges

  • Hand-typed leads

    A coordinator was able to copy approximately 130 enquiries into the CRM from email per day. There were frequent errors in telephone numbers.

  • Late Response

    Inquiry left in the Inbox to be read later. The buyers had, of course, by now, been making contact with another agency.

  • Duplicate records

    Three buyers that tapped three listings became three leads, and three agents called the same person.

  • No Context

    A name and a number were found on the CRM record, but were missing from the context. It revealed neither what listing it was, nor any price nor what the buyer had asked for.

  • No response data

    Managers were unable to view the slowest-responding agent, branch or hour of the day.

Our Solution

The listing app sends an enquiry to a lead intake endpoint behind an API gateway. The endpoint checks the payload and returns a confirmation in under a second.

  • The app's enquiry ID acts as the idempotency key, protected by a unique constraint in PostgreSQL
  • A retry after a dropped connection returns the stored lead and creates no second record
  • Each lead carries the listing ID, price, district, property type, sale or rent flag and the buyer's message
  • Phone numbers are normalized to E.164 format before anything else happens

Rules run in a fixed order and stop at the first agent who qualifies.

  • District match, then language match, then sale or rent specialty
  • Agents with more than 10 open leads are skipped
  • Agent shift calendars decide who is available, including prayer breaks computed for Riyadh
  • If nobody qualifies, the lead goes to the branch manager queue
  • Rule changes are stored as versioned configuration, so a manager can see what the rules were on any date

The CRM stays the system of record for contacts and deals. A mapping table links each lead field to a CRM field.

  • Matching on normalized phone number: a new buyer creates a contact and lead, a known buyer gets a new activity on the existing contact
  • Writes go through a queue that respects the CRM's API rate limit
  • The listing link, price and buyer message are written into the lead notes
  • A CRM webhook reports when the agent logs the first call or message, and that event stops the response timer

Each assigned lead starts a delayed job in Redis through BullMQ.

  • 3 minutes without contact: reminder push to the agent
  • 5 minutes: the lead is reassigned to the next qualifying agent
  • 10 minutes: alert to the branch manager
  • Every step is written to the lead's history with a timestamp

Push notifications are sent via Firebase Cloud Messaging and APNs, and SMS as a last resort if push is not sent within 30 seconds. The lead opens in the mobile view of the CRM with each message containing a deep link.

Leads still come to agents even if the CRM is down or slow, as the notification does not wait for the CRM to write. If the CRM fails to write, it will fail again in a random amount of time and with an increasing number of back-off periods. Then it will be sent to a dead letter queue with an alert. A replay command re-sends dead letter jobs once the CRM recovers, in the original order.

A correlation ID follows each lead from the app to the CRM write. Logs are structured JSON with OpenTelemetry traces and masked phone numbers. The manager dashboard displays the median and p95 response time for each agent, branch, and hour, queue depth, reassignment count, and dead letter volume. Records within the audit are append-only.

Agent app with a new lead and its response timer, beside a new lead notification
CRM dashboard on a laptop cycling through the results: lead routing, response time, pipeline and lead delivery

Technology Stack

  • Routing service

    Node.js, REST

    Many short requests and webhook calls

  • Database

    PostgreSQL

    Unique constraints for idempotency and a full lead history

  • Timers and queues

    Redis with BullMQ

    Delayed jobs for reminders and reassignment, with retries

  • Gateway

    AWS API Gateway

    Authentication, throttling and schema validation at one point

  • CRM link

    CRM REST API and webhooks

    Writes out and first contact events back in

  • Push

    Firebase Cloud Messaging, APNs

    Instant agent alerts on both platforms

  • Fallback

    SMS gateway

    Delivers when push fails

  • Dashboard

    React

    Filterable response time charts for managers

  • Cloud

    AWS EC2, RDS, CloudWatch

    Managed database, backups and alarms

  • Observability

    OpenTelemetry, structured logs

    Trace one lead across every hop

Saudi Specific Integrations

  • Phone formats

    Saudi numbers entered as 05XXXXXXXX, 5XXXXXXXX or +966 are normalized to one format, which removes most duplicate matches

  • Arabic and RTL

    Arabic buyer messages stored and displayed correctly in the CRM notes and the dashboard

  • Working calendar

    Sunday to Thursday shifts, public holidays, Ramadan hours and prayer breaks applied during routing

  • REGA advertising license

    the license number on each listing travels with the lead into the CRM

  • PDPL

    buyer consent recorded at enquiry time, with data retention rules for lead records

  • SMS

    Saudi licensed gateway with Arabic sender names

Development Process

  1. Discovery

    Tracked 60 queries from app to Agent call and note of each agent's waiting place.

  2. Rule design

    Designed the routing rules with branch managers and validated with previous month's leads.

  3. Intake and storage

    Built the intake endpoint, idempotency constraint and lead history before connecting any outside system.

  4. CRM integration

    Integrated all the CRM API and webhooks, configured fields and dealt with rate limits.

  5. Timers and notifications

    Escalation timers, push messages and SMS fallback were added.

  6. Failure testing

    Deactivated the CRM and sent the same enquiry five times, ensuring that no lead was lost or duplicated.

  7. Parallel run and cutover

    Ran the service beside the shared inbox for two weeks, compared both paths, then retired the inbox.

Measurable Results

  • Median first response time cut by 48%, from about 47 minutes to about 19 minutes

  • Leads answered within 5 minutes up from 12% to 58%

  • Lead delivery to the agent at p95 under 6 seconds

  • Manual CRM entry removed, from about 130 leads a day to none

  • Duplicate CRM records down 84%

  • Viewing requests turned into booked viewings up from 21% to 29%

  • No lead lost during the CRM outage test

Ready To Modernize Your Property Listing App

Connect with Code Brew Labs now to modernize or automate your real estate listings!

Get a Free Quote
Contact Us

Ready To Fuel Your Vision With AI-Powered Innovation?

Our Presence

Level- 18, Dubai World Trade Centre Tower, Sheikh Rashid Tower, Sheikh Zayed Rd, Dubai, UAE

business@code-brew.com +971-55-645-7972

Plot no I - 36, Sector 83 Alpha, Mohali SAS Nagar 140308

business@code-brew.com +91-771-976-8427

Al Akaria 2, 6926 Olaya Street, RHOA2566, Riyadh, Saudi Arabia.

business@code-brew.com

Av. Miguel Hidalgo y Costilla 1995, Arcos Vallarta, 44600 Guadalajara, Mexico

business@code-brew.com +1(213)2614953

4231 Balboa Ave #512 San Diego, CA 92117 United States

business@code-brew.com +1(213)2614953

2nd floor, College House, 17 King Edwards Rd, London HA4 7AE, UK

business@code-brew.com +44 (20) 82644493

Partner With Experts Who Leverage AI & Tech To Transform Ideas Into Market-Leading Solutions.

Wait! Looking for Right Technology Partner For Your Business Growth?

It's Time To Convert Your Business Idea Into Success!

Get Free Consultation From Top Industry Experts:
gif
I would like to keep it to myself