Helpdesk onboarding (AI file)
Download new-customer-helpdesk-onboarding.llm.md
# OB_WORKFLOW: new_customer.helpdesk_onboarding
version: 0.3-draft (2026-10-11). product: OrangeBoard (OB) PSA, https://ob.standardcomputer.com
goal: company not yet a customer contacts helpdesk -> Client (Onboarding -> Managed Client).
actor: helpdesk/IT staff. CRM pages need CRM access. Direct "+ Client" is ADMIN only, with or without the CRM module.
## MODEL
- One organizations table. CRM side = Stage {Prospect, MQL (Marketing Qualified Lead), Lead, Lost}; also Vendor, Former Client (not convertible). Clients side = Relationship {Onboarding, Managed Client}. "Client" = any customer organization. Customer vs pre-customer is computed isCustomer. There is no /customers noun and no /api/v1/customers route.
- Crossing pre-customer -> customer is the audited UI action "Convert to client" only (sales-all or admin). Server action convertToClientAction -> convertOrgToClient. Optional QBO, contract-from-deal, and onboarding-ticket steps run inside that action. Not undone by a stage edit; people/notes/deals stay on record. No REST endpoint. PATCH /api/v1/clients/{id} that would cross pre-customer -> customer returns 422: "This stage change would make a pre-customer org a client. Use Convert to client (CRM)…".
- Convert dialog "Convert \"{org}\" to client": checkboxes "Create/link QBO customer" and "Open onboarding ticket" (both on by default). Admin defaults: /settings/crm "Conversion defaults" (QBO create/link, contract from deal MRR/term/renewal, onboarding ticket + template default "Plain onboarding ticket", Landing stage: Auto (onboarding → customer) / Managed Client / Onboarding, notify on conversion).
- Non-convertible: Vendor ("Not a sales stage"), Archived, Former Client. "Needs cleanup" flagged orgs require explicit human acknowledgement.
- UI label "Practice name*" = organization name (literal label; applies to any business).
- CRM module off: /crm pages and the CRM API are disabled. Redirect to /console for everyone including admins. Do not treat that as "every CRM control is gone." "+ Client" and "+ Add client" (/clients?new=1) stay available to ADMIN (no CRM-module check on the page, sidebar button, or server action). Header CRM pill stays and lands on /console. Ticket overflow "Convert to CRM lead…" is NOT module-gated: it still renders from the user's crmAccess tier and fails only at submit with "The CRM module is turned off (Admin → CRM)." That overflow item is separate from Ticket finder "Convert to lead". A module-gate fix for the overflow item is in progress; document and follow the current behavior until it is live. /crm/finder is part of /crm (redirects when the module is off) and also follows the ticketToLeadEnabled toggle on its own.
- Until the Add-client stage fix ships: the "+ Add client" Relationship list offers Lead / MQL / Prospect but those choices save a customer-side row (isCustomer true) and skip Convert to client. Create pre-customers with CRM intake ("+ New lead", CSV import, or POST /api/v1/crm/leads). On "+ Add client", use Onboarding or Managed Client only when the company is becoming a customer now.
## API (confirmed 2026-10-11)
- base: https://ob.standardcomputer.com/api/v1. Header: Authorization: Bearer, plus the key. Key string starts with the prefix obk_. Shown once at creation (Admin → Integrations → API keys); stored hashed. Content-Type: application/json. Never print a real key.
- Write implies read within an area. 13 areas, 23 scope strings: tickets:read, tickets:write; clients:read, clients:write (contacts ride on clients — no contacts scope); sites:read, sites:write; devices:read, devices:write; users:read (no users:write); mentions:read, mentions:write; webhooks:read, webhooks:write; reports:read; projects:read, projects:write; crm_leads:read, crm_leads:write (label "CRM: Leads (intake)"); crm_prospects:read, crm_prospects:write; kb:read, kb:write; kb_secrets:read. No quotes scope.
- Error body is {"error":"..."}: 400 malformed JSON or schema ("Invalid request: field: message"); 401 missing/invalid/revoked/expired key; 403 missing scope (names it); 422 business rule; 429 + Retry-After on rate-limited CRM keys; 503 API kill switch off, or CRM module/intake/researcher API off on CRM routes.
- Phone: omit or "" = no number; JSON null = 400. Sites and contacts shape-check a non-empty phone (10 digits, or 11 starting with 1; trailing extension allowed; leading + for 8–15 digits; a single repeated digit is refused).
- POST /api/v1/clients (clients:write): customer-side only. Required name. Optional phone, website, relationship, industry, notes, address_line_1, address_line_2, city, county, postcode, country, main_site_name. Address field is county, NOT state (sites use state). Unknown keys are dropped silently, so a state key on this route vanishes. relationship "lead" (or other pre-customer stage) is 422. 201 returns the client (legacy PSA field names) + main_site_id. qbo_provisioning is always present (ok/created/qbo_customer_id, or ok:false + warning). QBO failure still leaves the client created. GET /clients, /contacts, and /sites return customer-side rows unless ?include_pre_customer=true is sent with crm_prospects:read (without that scope the parameter is 403).
- POST /api/v1/crm/leads (crm_leads:write): pre-customers. Required practice_name (alias name). Optional contact_name, contact_email, contact_phone, website, address_line_1, address_line_2, city, state, postcode, org_npi, notes, source, source_detail, research_notes, confidence 0–1, external_id, idempotency_key. No country. contact_email is not email-validated here; contact_phone is not shape-checked here (validation at promote). 201, or 200 with created:false on idempotency replay. Response may omit address and notes. dedupe_state: clean | customer_match | precustomer_match | fuzzy. status: pending | promoting | approved | merged | rejected. Trusted key that clears the confidence threshold AND dedupe_state clean can auto-approve (auto_approved:true, client_id). 503 when CRM module, intake queue, or researcher API is off.
- POST /api/v1/sites (sites:write): required client_id, name. Optional phone, address_line_1, address_line_2, city, state, postcode, country. 201 does not echo address fields (GET to read back). Unknown client_id → 422 {"error":"Unknown client."} (not 404). Pre-customer parent without crm_prospects:write → 422 (not 403).
- POST /api/v1/contacts (clients:write): required client_id, name. Optional site_id, email (RFC-validated), phone, mobile (shape-checked), job_title, role, is_primary. 201 uses legacy names (emailaddress, phonenumber). site_id is accepted and not echoed. 422 Unknown client; 422 site not under that client; 422 pre-customer parent without crm_prospects:write.
- Quote accept does not convert. Public /quote/{token} and staff Record outcome share one handler: quote status SENT→ACCEPTED, acceptedAt, frozen acceptedSnapshot, journal events. Never touches relationship, isCustomer, linked deal, or pipeline stage. Ticket/project handoff is a separate staff-confirmed UI action. No quotes API.
- CSV import (/crm/intake/import) is a 3-step mapping wizard, not a downloadable template. camelCase headers. This API uses snake_case. See the CRM conversion file for the header line and rules.
## RULES
- Search /crm/orgs and /clients for duplicates before creating or converting. On possible match: stop, ask human.
- Never convert a Needs cleanup org without explicit human approval.
- Show the human every create/convert/send action before executing; conversions are not reversible by you.
- In UI dialogs, nothing happens until the submit button; if only observing, press Cancel.
- Never output client names, contacts, PHI, or API keys. Use fictional examples (Example Dental, front-desk@example.com).
- Report partial results verbatim: converted / skipped / failed / "converted but QBO errored — fix from the client page".
- Create pre-customers only via CRM intake or POST /api/v1/crm/leads. Do not send Lead/MQL/Prospect through "+ Add client" or POST /api/v1/clients.
- Leave Convert to client to a human in the UI.
## UI_STEPS
1. /tickets?view=queue -> left rail "+ New ticket" (shortcut c) -> "Quick ticket": Caller phone ("Search by caller number…"), Client ("Type to search clients…"), Site (disabled until Client), Contact (disabled until Site), Summary*, Details*, Assign to (default current user), Team (default Support), Notify tech checked, Notify customer checked, "Ack To (blank = contact's email)", "Ack CC (comma-separated)". Type/category/impact default. Buttons: Cancel / Create ticket.
Unknown company: Client shows "No matching clients." (no create option). File under internal/catch-all client; record caller company + contact in Details.
2. /crm/finder "Ticket finder" (CRM sidebar, Work). Tabs "Prospect-sounding (n)", "Filed under internal client (n)". Columns: Ticket, Summary, Client, Site, Status, Opened, Contact, Why flagged. Requires CRM module on (else redirect /console) and follows ticketToLeadEnabled. With CRM off, do not use the ticket overflow "Convert to CRM lead…" — it can still be visible and fails at submit.
3. Row "Convert to lead" -> "Convert ticket #N to lead": toggle "New lead org" / "Existing pre-customer org"; Practice name* (only required), Contact name, Contact email, Contact phone, Website, City, State, Source (prefill "ticket"), Source detail (prefill "OB ticket #N"). Button "Convert to lead". Effect: ticket moves onto lead org with history; un-invoiced time -> non-billable; SLA clock clears; nothing deleted. (Re-file is automatic.)
4. /crm/orgs "Pre-customer organizations"; find via Stage chips.
5. Row "Convert to client" -> dialog (see MODEL) -> "Convert to client". Human only. -> Relationship per Landing stage (default Onboarding).
6. Onboarding = the onboarding ticket (from template; /settings/templates "Ticket templates"). No per-client checklist UI. /crm/pipeline shows Onboarding column.
7. Onboarding -> Managed Client: /clients/{id} Organization section "Edit" -> "Edit {client}" -> Standing: Relationship = "Managed Client" -> "Save changes". Or automatic via Landing stage.
ALT direct customer (ADMIN): sidebar "+ Client" (/clients?new=1) or "+ Add client" on /clients -> "New client": Business (Business name, Business phone, Website, Relationship [Managed Client, Onboarding, Prospect, Marketing Qualified Lead, Lead, Lost, Former Client, Vendor], Industry, Account status Allowed/Stopped); Sites (Main site · QBO parent, Site name, Site phone, Address 1/2, City, State, Zip, "+ Additional site"); Contacts (Main contact Name, Email, Phone; "CC this person on every ticket"; "Same person fills all three roles (main, billing, after hours)"). "Create client" also provisions QuickBooks, BookStack wiki, Benji Pays, SimpleHelp, Tactical RMM (outcomes shown after create). Requires human approval. Relationship Lead/MQL/Prospect on this form currently creates a customer-side row — do not use them for a pre-customer.
MANUAL re-file: /tickets/{id} left-column Client section "Change client" -> Caller phone, Client, Site, Contact -> "Move ticket". Notes/time/attachments/audit stay; device and project links from old client dropped.
## API_STEPS
- Ticket create: POST /api/v1/tickets (tickets:write). Required summary, client_id. Optional details, site_id (defaults to the client's main site), contact_id, agent_id, team_id, tickettype_id, category_1, impact 1–3, urgency 1–3, notify_tech, notify_customer. Confirm with a human first. Unknown company has no client yet — do not invent a client_id.
- Direct customer create: POST /api/v1/clients (clients:write) per MODEL. Confirm with a human first. Do not send a pre-customer relationship.
- Pre-customer from a helpdesk lead: POST /api/v1/crm/leads (crm_leads:write), or the Ticket finder UI. Ticket -> lead has no confirmed REST endpoint; use the UI.
- Convert to client, Log touch, Change client re-file, quote accept: UI only.