# WhatsApp Group Tickets — Design

**Date:** 2026-08-05  
**Status:** Approved  
**Goal:** Staff can open a New ticket as a WhatsApp **group** (client + staff phones), then use the ticket UI like a normal chat while messages sync with that group.

## Decisions

| Topic | Choice |
|-------|--------|
| Participants | Client phone + selected staff phones; channel WA account creates/owns the group |
| Group name | Editable; default `Silicon Support — {client label}` |
| New ticket UX | Toggle **Direct** vs **Group** |
| Staff picker | Only staff (`admin`/`user`) with `users.phone` set; max 3 |
| Ticket model | One ticket per group; store `wa_group_jid` + subject |

## Data

- `tickets.wa_group_jid` (nullable text, unique when set) — e.g. `120363…@g.us`
- `tickets.wa_group_subject` (nullable text)
- Optional `tickets.wa_group_participant_user_ids` UUID[] for staff members selected at create

Contact on the ticket remains the **client** contact (primary customer).

## Create flow

1. Modal: Group mode → channel, client (contact/phone), 1–3 staff with phones, subject, first message.
2. API validates connected WhatsApp channel + phones.
3. Worker `groupCreate(subject, [clientJid, …staffJids])`.
4. Insert ticket with `wa_group_jid`, assign creator, append outbound first message to group JID.
5. Navigate to ticket.

## Inbound / outbound

- Inbound from `@g.us` matching a ticket’s `wa_group_jid` → append to that ticket (not a new 1:1 by participant phone).
- Store sender phone on message metadata or prefix content for display (v1: include sender in message row if column exists; else content prefix / metadata JSON).
- Outbound staff replies: `sendMessage(group_jid, text)` when ticket has `wa_group_jid`.

## Out of scope v1

- Add/remove members after create  
- Link existing WhatsApp groups  
- Portal/email groups  
- Changing group subject after create  
