Skip to content

[BE-43] NPS satisfaction survey automation: backend #1230

Description

@yusuftomilola

Overview

There is no systematic way to measure member satisfaction. NPS (Net Promoter Score) surveys sent automatically after a completed booking provide quantifiable feedback and identify members to retain or win back.

Context

  • CompleteBookingProvider: backend/src/bookings/providers/complete-booking.provider.ts — trigger survey here
  • EmailModule: backend/src/email/ — deliver the NPS survey email
  • @nestjs/schedule: schedule the delayed email send (2 hours after completion)

Tasks

  • Create NpsSurveyResponse entity: id, userId (FK), bookingId (FK, unique — one response per booking), score (int, 0–10), comment (text, nullable), submittedAt (timestamptz), createdAt
  • In CompleteBookingProvider: after booking status → COMPLETED, schedule a delayed job (via Bull, 2-hour delay) to send NPS survey email
  • Email contains a link to /nps/[bookingId] with the booking ID; pre-fill context (workspace name, booking date)
  • POST /nps/respond — authenticated member submits { bookingId, score, comment }; reject if already responded
  • Rate limit NPS sends: do not send more than one survey to the same member within 30 days (check before queuing)
  • GET /nps/summary — admin endpoint: { averageScore, promoters, passives, detractors, npsScore, totalResponses, recentComments }
    • Promoters: score 9–10; Passives: 7–8; Detractors: 0–6; NPS = (Promoters% - Detractors%)
  • GET /nps/responses — paginated raw responses (admin only)

Files to Modify / Create

  • New: backend/src/nps/ (module, entity, controller, service, bull processor)
  • backend/src/bookings/providers/complete-booking.provider.ts
  • backend/src/app.module.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions