Files
resolutionflow/backend/app/schemas/survey.py
Michael Chihlas 882f67f42e feat: AI chat session conclusion + survey completion & management
AI Assistant - Conclude Session:
- 3-step modal: select outcome (resolved/escalated/paused), add notes, AI-generated summary
- AI generates structured ticket notes from conversation transcript (PSA-ready format)
- Copy to clipboard for pasting into ticketing systems
- "Resume in New Chat" for paused sessions (pre-loads context into new chat)
- Backend: POST /chats/{id}/conclude endpoint, conclusion_summary/outcome/concluded_at fields
- Migration 048: add conclusion fields to assistant_chats

Survey Completion Flow:
- Email-to-self option after submission (branded HTML email with formatted responses)
- Finish button navigates to /survey/thank-you page
- Thank you page with close-window message and feedback email callout
- Already-submitted state updated with same messaging
- Backend: POST /survey/email-copy public endpoint

Survey Admin Management:
- Read/unread indicators (cyan dot, bold name, auto-mark on expand)
- Unread count stat card
- Per-row context menu: mark read/unread, archive/unarchive, delete
- Bulk actions bar: select all, mark read/unread, archive, delete
- Show Archived toggle to filter archived responses
- Backend: 7 new admin endpoints (read, unread, archive, unarchive, delete, bulk)
- Migration 049: add is_read, archived_at to survey_responses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 20:00:28 -05:00

73 lines
2.0 KiB
Python

"""Schemas for FlowPilot survey submission."""
from datetime import datetime
from typing import Any, Optional
from pydantic import BaseModel, Field
class SurveySubmission(BaseModel):
"""Incoming survey response from the public form."""
respondent_name: Optional[str] = Field(None, max_length=255)
responses: dict[str, Any] = Field(
...,
description="Question ID -> answer mapping. Values can be strings, lists, or numbers.",
)
token: Optional[str] = Field(None, description="Invite token for tracking")
class SurveySubmissionResponse(BaseModel):
"""Response after successful submission."""
message: str = "Thank you for your response!"
id: str
class SurveyInviteCreate(BaseModel):
"""Create a new survey invite."""
recipient_name: str = Field(..., min_length=1, max_length=255)
recipient_email: Optional[str] = Field(None, max_length=255)
send_email: bool = False
class SurveyInviteResponse(BaseModel):
"""Invite details returned to admin."""
id: str
token: str
recipient_name: str
recipient_email: Optional[str]
status: str
email_sent: bool
created_at: datetime
completed_at: Optional[datetime]
survey_url: str
class SurveyInviteStatus(BaseModel):
"""Public invite status check — minimal info."""
name: str
status: str
class SurveyEmailCopyRequest(BaseModel):
"""Request to email a copy of responses to the respondent."""
email: str = Field(..., max_length=255)
response_id: str
class SurveyResponseDetail(BaseModel):
"""Full survey response returned to admin."""
id: str
respondent_name: Optional[str]
responses: dict[str, Any]
source: str
invite_name: Optional[str]
is_read: bool = False
archived_at: Optional[datetime] = None
created_at: datetime
class SurveyResponseListResponse(BaseModel):
"""List of survey responses with summary stats."""
responses: list[SurveyResponseDetail]
total: int
this_week: int
unread: int