# Contact the agent

Source: https://help.ruuster.com/idx/recipe-contact-agent

> The listing page's contact screen, from ContactAgentModal, which sends the visitor's question to your own route with their consent, then offers a tour time.

"Contact Jordan Lee" on a listing page opens the contact screen: a short form with the visitor's
name, email, phone and a message about the home, your consent wording beside an unchecked box, and a
"Send message" button. After your route accepts the message, the screen thanks the visitor and offers
a tour time in the same window. Every message goes to your own server route, which sends it to your
CRM. `ListingDetail` mounts the contact screen for you when you pass `leadAction` and `consentText`.

## What the visitor sees

<figure class="idx-shot"><img src="/idx-docs/screens/ours/contact-modal-1440.png" alt="The contact dialog, closed, on its first step (the message form), with the tour step and the summary hidden, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>Step 1: the message.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/contact-modal-375.png" alt="The contact dialog, closed, on its first step (the message form), with the tour step and the summary hidden, on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>Step 1: the message.</figcaption></figure>

The markup is `static/html/contact-modal.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

<figure class="idx-shot"><img src="/idx-docs/screens/ours/contact-modal-tour-1440.png" alt="The contact dialog after the message was sent: the form is hidden and the tour step shows, on a desktop (1440 px wide)" width="1440" height="900" loading="lazy" decoding="async"><figcaption>Step 2: the thank-you and the tour days and times.</figcaption></figure>

<figure class="idx-shot"><img src="/idx-docs/screens/ours/contact-modal-tour-375.png" alt="The contact dialog after the message was sent: the form is hidden and the tour step shows, on a phone (375 px wide)" width="375" height="812" loading="lazy" decoding="async"><figcaption>Step 2: the thank-you and the tour days and times.</figcaption></figure>

The markup is `static/html/contact-modal-tour.html` in `@ruuster/idx-recipes`. The [HTML and CSS recipe](https://help.ruuster.com/idx/recipe-html-css) shows how to fill it and which stylesheet and script to load.

## How it opens

Every button that opens it carries `data-rw-open="contact"`:

- the dark "Contact Jordan Lee" button in the sidebar's agent card, from 992 pixels;
- the same button in the action bar fixed to the bottom of the screen, under 992 pixels;
- the same button in the full gallery's sidebar and mobile bar.

The title and the button read "Contact" and your agent's name. With no name or brokerage in `agent`,
they read "Contact an agent".

## The steps

1. **The form.** "How can we reach you?" over these fields:

   | Field | Required | Notes |
   |---|---|---|
   | First name and last name | Yes | Side by side |
   | Email | Yes | The browser checks the format |
   | Phone | No | As the visitor types it. Your route can normalise it |
   | Message | No | Starts as "I would like more information about 123 Peachtree St NE, Atlanta, GA 30308." For a hidden address it names no street |
   | Contact consent | Yes | Your `consentText` beside an unchecked box |
   | Listing alerts | No | Your `alertsConsentText` beside its own unchecked box, when you pass it |

   "Send message" stays off until the visitor checks the consent box, and the line under it says so.
   A hidden `website` field catches form robots.
2. **Sent.** After your route answers with a 2xx status, the screen reads "Thank you. We will be in
   touch shortly." and "We can also set up a tour of this home. Which day and time work for you?",
   with the same day and time picker as the [tour screen](https://help.ruuster.com/idx/recipe-tour-booking).
   "Request a tour" sends a second request, a tour, with the same person and the consent they gave on
   step 1.
3. **Tour received.** The tour summary with the date, the time, the phone and the email, and "Done".

When your route answers anything else, the form shows "We could not send your request. Please check
your connection and try again." and keeps everything the visitor typed. Closing the window part way
keeps the fields too. "Done", or closing after a sent message, starts the next visitor at step 1.

## What your route receives

Each step posts one `LeadSubmission` as JSON to `leadAction`. Step 1 sends `kind: "contact"`:

```json
{
  "kind": "contact",
  "firstName": "Sam",
  "lastName": "Rivera",
  "email": "sam.rivera@example.com",
  "phone": "404-555-0187",
  "message": "I would like more information about 123 Peachtree St NE, Atlanta, GA 30308.",
  "tour": null,
  "listing": { "id": "aaaaaaaa-0000-4000-8000-000000000001", "mlsNumber": "FXSTD100", "url": "https://www.peachrealty.example/homes/123-peachtree-st-ne-atlanta-ga-30308-aaaaaaaa-0000-4000-8000-000000000001" },
  "consent": { "contact": true, "alerts": false, "text": "I agree that Peach Realty may contact me by phone, text or email about this request." },
  "page": { "url": "https://www.peachrealty.example/homes/123-peachtree-st-ne-atlanta-ga-30308-aaaaaaaa-0000-4000-8000-000000000001", "referrer": null },
  "attribution": { "utmSource": null, "utmMedium": null, "utmCampaign": null, "utmTerm": null, "utmContent": null, "gclid": null, "fbclid": null }
}
```

The tour on step 2 sends `kind: "tour"` with `tour: { "date": "2026-11-12", "time": "afternoon" }`.
`consent.text` is the exact wording the visitor saw. After a 2xx answer the page sends the GA4
`generate_lead` event. The routes for Follow Up Boss, Sierra Interactive and Sure Send are on
[Send leads and activity to your CRM](https://help.ruuster.com/idx/crm-overview), and the example's
route is `app/api/leads/fub/route.ts`.

## Use it on your own layout

Mount `ContactAgentModal` once inside the element that carries `data-rw-detail`, and put
`data-rw-open="contact"` on your own button in that element. The
[gallery page](https://help.ruuster.com/idx/recipe-gallery) shows a full layout.

| Prop | Type | Required | What it does |
|---|---|---|---|
| `listing` | `ListingDetail` or `ListingCard` | Yes | The listing the visitor asks about |
| `action` | `string` | Yes | Your route, for example `/api/leads/fub` |
| `consentText` | `ReactNode` | Yes | Your consent wording beside the unchecked contact box |
| `agent` | `DetailAgent \| null` | No | Your agent or office: `name`, `photoUrl`, `phone`, `email`, `brokerage`, `license` |
| `alertsConsentText` | `ReactNode` | No | Your wording for the separate listing-alerts box |
| `now` | `Date` | No | The time the tour days are counted from. Leave it out on a live site |

## Rules this screen follows

**MUST**

- Use your own agent or office in `agent`, the person who answers the visitor.
- Keep both consent boxes unchecked until the visitor checks them, and send the exact wording.
- Post to your own server route, which sends the lead to your CRM.

**NEVER**

- Put the listing agent from the MLS in `agent` unless that agent works with you.
- Send the lead to a CRM from the browser, or put a CRM key in browser code.
