Let automations fire on more CRM events and open the studio from the main nav.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-09 21:43:17 +03:30
co-authored by Cursor
parent 51684daa61
commit f1aba1b386
20 changed files with 419 additions and 49 deletions
+54 -3
View File
@@ -1722,15 +1722,35 @@ export interface RedeemLoyaltyRewardRequest {
}
/** اتوماسیون اگر/آنگاه */
export type AutomationTrigger = "deal_won" | "ticket_resolved";
export type AutomationTrigger =
| "person_created"
| "lead_submitted"
| "deal_created"
| "deal_stage_changed"
| "deal_won"
| "deal_lost"
| "ticket_created"
| "ticket_resolved"
| "invoice_issued"
| "invoice_paid"
| "activity_done";
export type AutomationAction =
| "create_activity"
| "create_notification"
| "add_loyalty_points";
export const AUTOMATION_TRIGGER_LABELS: Record<AutomationTrigger, string> = {
person_created: "مخاطب جدید ساخته شد",
lead_submitted: "فرم سرنخ ارسال شد",
deal_created: "معامله جدید ساخته شد",
deal_stage_changed: "مرحله معامله عوض شد",
deal_won: "معامله برنده شد",
deal_lost: "معامله باخت",
ticket_created: "تیکت جدید ساخته شد",
ticket_resolved: "تیکت حل شد",
invoice_issued: "فاکتور صادر شد",
invoice_paid: "پرداخت روی فاکتور ثبت شد",
activity_done: "فعالیت تمام شد",
};
export const AUTOMATION_ACTION_LABELS: Record<AutomationAction, string> = {
@@ -1748,10 +1768,33 @@ export const AUTOMATION_ACTIONS = [
] as const satisfies readonly AutomationAction[];
export const AUTOMATION_TRIGGERS = [
"person_created",
"lead_submitted",
"deal_created",
"deal_stage_changed",
"deal_won",
"deal_lost",
"ticket_created",
"ticket_resolved",
"invoice_issued",
"invoice_paid",
"activity_done",
] as const satisfies readonly AutomationTrigger[];
export const AUTOMATION_TRIGGER_GROUPS: {
label: string;
items: AutomationTrigger[];
}[] = [
{ label: "مخاطب", items: ["person_created", "lead_submitted"] },
{
label: "معامله",
items: ["deal_created", "deal_stage_changed", "deal_won", "deal_lost"],
},
{ label: "تیکت", items: ["ticket_created", "ticket_resolved"] },
{ label: "فعالیت", items: ["activity_done"] },
{ label: "مالی", items: ["invoice_issued", "invoice_paid"] },
];
export type AutomationStepKind = "action" | "condition";
export type AutomationConditionField =
@@ -1822,10 +1865,18 @@ export function firstAutomationAction(
export function conditionFieldsForTrigger(
trigger: AutomationTrigger,
): AutomationConditionField[] {
if (trigger === "deal_won") {
if (
trigger === "deal_won" ||
trigger === "deal_lost" ||
trigger === "deal_created" ||
trigger === "deal_stage_changed"
) {
return ["deal_amount", "has_person", "has_company"];
}
return ["ticket_priority", "has_person", "has_company"];
if (trigger === "ticket_resolved" || trigger === "ticket_created") {
return ["ticket_priority", "has_person", "has_company"];
}
return ["has_person", "has_company"];
}
export interface AutomationStep {