Skip to content

lead-sla-escalation

Source of truth: packages/notifications/src/translations.ts

DomainChannelsRecipients
leadsin-app + email + pushTeam ADMINs (tier 2) → team LEAD (tier 3)
SourceContext
apps/worker/src/leads.ts:398processEscalations
apps/worker/src/leads.ts:458processEscalations
interface LeadSlaEscalationData {
customerName: string;
propertyAddress: string;
thresholdMinutes: number;
escalationTier: number;
assigneeName: string;
leadsUrl: string;
}

The caller invokes triggerWorkflow('lead-sla-escalation', recipientIds, data) where data is the LeadSlaEscalationData shape above. The server pre-translates the payload via getTranslatedPayload('lead-sla-escalation', recipientLocale, data) from @repo/notifications before sending, producing { inAppBody, emailSubject, emailBody } for the dashboard templates to render.

Knock dashboard template body: {{ inAppBody }}.

LocalePreview source
esp.escalationTier === 2 ? `🔺 Escalación SLA: el lead de ${p.customerName} (${p.propertyAddress}) lleva más de ${p.thresholdMinutes * 2} min sin atención. Asignado a ${p.assigneeName}.` : `🚨 Escalación crítica: el lead de ${p.customerName} (${p.propertyAddress}) lleva más de ${p.thresholdMinutes * 3} min sin atención. Requiere acción inmediata.`
enp.escalationTier === 2 ? `🔺 SLA escalation: lead from ${p.customerName} (${p.propertyAddress}) untouched for over ${p.thresholdMinutes * 2} min. Assigned to ${p.assigneeName}.` : `🚨 Critical escalation: lead from ${p.customerName} (${p.propertyAddress}) untouched for over ${p.thresholdMinutes * 3} min. Requires immediate attention.`

Subject: {{ emailSubject }}. Body: {{ emailBody }} (HTML mode, dashboard escaping OFF — every user-supplied string is escaped server-side via escapeHtml from @repo/notifications).

LocaleSubject preview
esp.escalationTier === 2 ? `Escalación SLA — lead de ${p.customerName}` : `Escalación crítica SLA — lead de ${p.customerName}`
enp.escalationTier === 2 ? `SLA escalation — lead from ${p.customerName}` : `Critical SLA escalation — lead from ${p.customerName}`

Email body is composed by emailBody.es in packages/notifications/src/translations.ts via the layout components in packages/notifications/src/email-layout.ts (wrapEmailLayout, ctaButton, calloutBox, quoteBlock, propertyCard, detailTable / detailRow). Body source is not inlined here because it spans tens of lines per locale — open the source file for the full template.

Push delivery is configured at the Knock dashboard level for this workflow (FCM channel step with {{ inAppBody }} as the notification body). iOS APNs is deferred until the dashboard p8 key is wired — see Configuration → mobile push.