human handoffs
This commit is contained in:
parent
79188e0f59
commit
36a55930f9
35 changed files with 4039 additions and 139 deletions
71
frontend/src/utils/handoffUtils.js
Normal file
71
frontend/src/utils/handoffUtils.js
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
export const HANDOFF_LABELS = ["Important", "Finance", "Clients", "Projects", "Personal", "Support"];
|
||||
|
||||
export const EMAIL_TYPE_OPTIONS = [
|
||||
{
|
||||
id: "utility",
|
||||
title: "Utility",
|
||||
description: "Account updates, alerts and service information",
|
||||
},
|
||||
{
|
||||
id: "transactional",
|
||||
title: "Transactional",
|
||||
description: "Orders, payments, invoices, receipts and account activity",
|
||||
},
|
||||
{
|
||||
id: "promotional",
|
||||
title: "Promotional",
|
||||
description: "Offers, deals and promotional messages",
|
||||
},
|
||||
{
|
||||
id: "marketing",
|
||||
title: "Marketing",
|
||||
description: "Campaigns, newsletters and marketing outreach",
|
||||
},
|
||||
];
|
||||
|
||||
export const INSTRUCTION_EXAMPLES = [
|
||||
"Refund requests",
|
||||
"Human requested",
|
||||
"Approval needed",
|
||||
];
|
||||
|
||||
function joinOrNone(items, fallback = "any email") {
|
||||
if (!items?.length) return fallback;
|
||||
if (items.length === 1) return items[0];
|
||||
if (items.length === 2) return `${items[0]} or ${items[1]}`;
|
||||
return `${items.slice(0, -1).join(", ")} or ${items.at(-1)}`;
|
||||
}
|
||||
|
||||
function typeTitles(types) {
|
||||
return types.map((id) => EMAIL_TYPE_OPTIONS.find((item) => item.id === id)?.title || id);
|
||||
}
|
||||
|
||||
export function buildHandoffSummary({
|
||||
ownerEmail,
|
||||
labels,
|
||||
emailTypes,
|
||||
instructions,
|
||||
}) {
|
||||
const labelText = labels?.length
|
||||
? `${joinOrNone(labels)} emails`
|
||||
: "eligible emails";
|
||||
const typeText = emailTypes?.length
|
||||
? typeTitles(emailTypes).join(" or ").toLowerCase()
|
||||
: "any type";
|
||||
const instructionText = instructions?.trim()
|
||||
? "when they require your personal decision or attention"
|
||||
: "when your handoff instructions apply";
|
||||
|
||||
return `Your agent will handle email normally. ${labelText} that are ${typeText} will be handed to ${ownerEmail || "the human owner"} ${instructionText}.`;
|
||||
}
|
||||
|
||||
export function buildRuleCardSummary(rule) {
|
||||
const parts = [];
|
||||
if (rule.labels?.length) parts.push(rule.labels.join(", "));
|
||||
if (rule.email_types?.length) {
|
||||
parts.push(typeTitles(rule.email_types).join(", "));
|
||||
}
|
||||
const meta = parts.length ? parts.join(" • ") : "All eligible emails";
|
||||
const replies = rule.allow_replies ? "Replies enabled" : "View only";
|
||||
return `${meta} • ${replies}`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue