---
title: "Surveys"
description: "The post-stay survey, when it is sent, what it stores and how a guest answers."
url: https://pr-404-docs.preview-ritorno.findmalek.engineer/docs/surveys
markdown: https://pr-404-docs.preview-ritorno.findmalek.engineer/docs/surveys.md
---

# Surveys

One short survey per guest after the stay: six questions at most, one minute on a phone.

## Questions

- NPS, 0 to 10: "How likely are you to recommend the hotel to a friend?"
- Three optional ratings from 1 to 5: your room, cleanliness, staff and food
- One optional free comment (1000 characters)

## When it is sent

The `survey-invites` job runs every hour (pg-boss, jobs module). A guest is due 24 hours after check-out (counted from noon hotel time). With no check-out date it is 8 days after the guest was captured, longer than a week's stay (a stay over a week with no date can still be asked early). A guest from a restaurant table code or a csv import is only surveyed once they have a check-out date. Only guests due in the last 14 days are picked up, so a new deploy never surveys old guests.

Where the check-out date comes from:

- The guest, on the capture page: an optional "when do you leave?" (tomorrow, in 2, 3 or 7 nights, or a date up to 90 days away). It is only kept when the guest also switches on the toggle shown under it, which grants the whole `profile` consent; otherwise neither is stored. Scanning again does not change a check-out that is today or later, staff do that.
- Staff, on the guest's edit page, once the guest has the `profile` consent.

- Sent through `sendToGuest` on the channels the guest agreed to: the `survey` email and the `guest_survey` WhatsApp template (see `whatsapp-templates`).
- Never in quiet hours, 21:00 to 08:00 hotel time. The next hourly run sends it.
- Once per guest: `survey_invites` has one row per guest and `automation_sends` one claim per channel. A crash between the invite and the send is picked up by the next run.

## Data

- `survey_invites`: `hotel_id`, `guest_id`, `sent_at`, `expires_at` (14 days). Deleted with the guest.
- `survey_responses`: `hotel_id`, `guest_id` (set to null when the guest is deleted, so the answer stays as anonymous feedback), `invite_id` (unique, one response per invite), `nps`, three ratings, `comment`, `language`, `submitted_at`, `review_link_clicked_at`.

Every query is scoped by hotel id.

## The page

`/s/<token>` in `apps/web`, branded with the hotel's logo and colors like the capture page, in the guest's language (en, fr, ar RTL). The token is signed (HMAC), so it cannot be guessed. It is a server component with a plain form and no client JavaScript. The NPS row wraps in two rows on a 390px phone. After sending, and on a second visit, the page shows the thank you state. After 14 days it says the survey has closed. The page is `noindex` and sends no referrer.

Seed data: about one guest in five of the four demo hotels has an invite, 70% of them answered, with scores from 3 to 10 and comments in fr, ar and en.

## Low score alert

A response with `nps` at or below the hotel's `hotel_settings.low_score_threshold` (default 6, `hotel.update` takes `lowScoreThreshold` 0 to 10) does two things:

- opens a `feedback_cases` row for the response with status `new` (then `contacted`, `resolved`), `notes` and `handled_by`, so it shows in the [feedback inbox](#feedback-inbox)
- calls `notifyManager(hotelId, text)`, which emails the manager. The text has the guest's first name, the score, a comment excerpt (140 characters) and a link to `/feedback/<case id>` in the dashboard. Never a phone number or email.

A failed alert never fails the guest's answer. One case per response.

## Feedback inbox

Unhappy guests are the second half of the dashboard Inbox: `/feedback`, also in the sidebar as "Unhappy guests". The alert email and the home page link straight to `/feedback/<case id>`.

- The list shows the guest, score, comment, status and date, newest first, filtered by status (`new`, `contacted`, `resolved`) with a count on each.
- A case shows the survey answer, call, email and guest profile buttons, the status and one shared staff note (2000 characters), with who saved it last.
- A save sends the `updatedAt` it read. If a colleague saved in between, `feedbackCases.update` answers `CONFLICT`, and the page says so and reloads the case.
- The alert link opens the case in the active hotel only. For another hotel the page says to switch hotel and open the link again.
- The list loads more as you scroll (`feedbackCases.list` takes `cursor`).
- Every hotel role (owner, manager, staff) can read and update cases: it needs `guest: read` and `guest: update`.
- API: `feedbackCases.list`, `feedbackCases.get`, `feedbackCases.update`, all scoped by the active hotel. Each update writes a `feedback-case.update` audit entry with the status, never the note text.
- A deleted guest's case leaves the inbox and its note is erased. The survey answer stays, anonymous.

## Share on Google

After the survey, whatever the score (never gated by score), the thank you state shows a secondary button "Share on Google" with a short line, in en, fr and ar. It only shows when the hotel has a `hotel_settings.google_review_url`.

The button points to `/r/<token>` in `apps/web`, a signed redirect (a `review` token, which cannot open the survey and the other way round). It stamps `survey_responses.review_link_clicked_at` on the first click and redirects to the hotel's page. A hotel without a link, or a bad token, gets a 404. Nothing else is sent after the survey, so the thank you page is the thank you message.
