Repository navigation
Replies: 1 comment
|
Thanks for the detailed proposal, @mvanhorn. I checked it against today's
I opened #4023 with this, split into a small step (emit — Assistente de IA do DeskcommCRM. Para falar com uma pessoa do time, mencione @melgarafael. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Proposal
feat(atendimento): WhatsApp CSAT after conversation close
Motivation
Operators running a self-hosted AI sales inbox need a quality signal after a conversation ends. Intercom, Chatwoot, and Kommo all ship post-conversation CSAT. DeskcommCRM’s own PRD lists NPS pós-atendimento as a success metric, and Spec 07 sketches a
csat-triggeron resolve/fulfill — but production code never sends a survey.Today
POST /api/v1/conversations/[id]/closeflips status viafn_service_statusand writes auditconversation.closed. There is noevent_logrow for automations, no survey table, and no side-effect on the WhatsApp channel. Closing a chat is a silent dead-end for product quality.This feature was proposed from code analysis without hands-on usage (bulk dogfooding skipped).
Research Summary
General Project Dogfooding
Feature-Specific Validation
csat|nps_underlib//app/(excluding docs) returns no implementation; PRD/spec text is aspirational.Project Context
Related Issues & Community Signals
Competitive Analysis
Proposed Solution
Opt-in per organization. When enabled, closing a conversation schedules a one-shot WhatsApp CSAT (1–5) to the contact on the same channel session, after a short delay, only if the 24h session window (or WAHA equivalent) still allows free-form text. Store the rating; never block or fail the close API if the survey path errors.
Behaviour:
organizations.settings.csat(zod):{ enabled: boolean, pergunta: string, atraso_ms: number, validade_ms: number }with safe defaults (enabled false; Portuguese default question; ~60s delay; ~48h reply window).fn_service_status+ audit, insertevent_logconversation.closed(so automations can also react) and/or enqueue jobcsat_surveyidempotent on(organization_id, conversation_id).sendMessageHandler/ ledger path (same blocked-contact and pacing guards). Body like: "De 1 a 5, como foi o atendimento?" — usetraduzir/ org locale. Mark surveysent.answered, do not run the AI turn for that message. Non-matching inbound clears nothing (survey stays open until validity expires).csat_surveys: org, conversation, contact, channel_session, status (pending|sent|answered|expired|skipped), rating nullable, sent_at, answered_at; unique(organization_id, conversation_id); RLS tenant isolation + isolation test list update.Out of scope: Meta HSM templates for outside-session, NPS 0–10 variant, public web form, forcing
conversations.status='resolved'writers, AI auto-close.Success: close a conversation with CSAT enabled → contact receives the question on WhatsApp → reply
5stores rating and does not trigger an AI sales reply.Approach
Complexity M. Estimated ~250–400 LOC + migration triple.
1. Schema triple
Migration + baseline appendix + MANIFEST. Include RLS policy
tenant_isolation_csat_surveys_alland add table to isolation test allowlist.2. Pure helpers
lib/csat/pesquisa.ts: decide whether to enqueue; render question; parse rating from inbound text. Fully unit-tested (no network).3. Close wiring
close/route.ts: keep current success path; add best-effort event_log insert + enqueue. Failures log and still returnok(conv).4. Handler
Register in
ensureHandlersRegistered. Skip when disabled, already surveyed, contact blocked, or channel cannot send.5. Ingest short-circuit
Before
ai_agent.dispatch_requested/ inbound-turn, consume rating replies.6. Settings API + form
Admin-only PATCH; merge jsonb settings (do not clobber unrelated keys — follow
ai/providersmerge pattern).7. i18n + changelog fragment
.changes/csat-pos-fechamento.mdfor release screen; strings viatraduzir/useT.8. Tests
PR strategy
feat(atendimento): pesquisa CSAT no WhatsApp ao fechar a conversaHappy to open a PR if this direction works for you.
AI was used for assistance.
All reactions