fix(automation): allow explicit scheduledAt / scheduleOffsetMinutes
P3-58: Automation rule's schedule_meeting action hardcoded +1hr from now, producing meetings that could land in the past or outside working hours. Accept scheduledAt (ISO-8601) first, fall back to scheduleOffsetMinutes, and only default to +60min when the rule specifies no time at all.
This commit is contained in:
1 parent
7eba08cfb9
commit
32e676aec9
2 files changed
+14
-5
No files matched your search
@@ -65,6 +65,10 @@ export const scheduleMeetingConfigSchema = z.object({
|
||||
title: z.string().optional(),
|
||||
participantAgentIds: z.string().optional(),
|
||||
durationMinutes: z.number().int().positive().optional(),
|
||||
// Absolute ISO-8601 scheduling is preferred; otherwise callers can specify
|
||||
// an offset in minutes from now (replaces the previous hard-coded 60min).
|
||||
scheduledAt: z.string().optional(),
|
||||
scheduleOffsetMinutes: z.number().int().positive().optional(),
|
||||
});
|
||||
|
||||
export const createDocumentConfigSchema = z.object({
|
||||
|
||||
@@ -287,16 +287,21 @@ export function executeAutomationAction(
|
||||
break;
|
||||
}
|
||||
case "schedule_meeting": {
|
||||
const meetingType = (config.meetingType as string) ?? "department_sync";
|
||||
const title = (config.title as string) ?? "Auto-scheduled meeting";
|
||||
const cfg = config as AutomationActionConfigMap["schedule_meeting"];
|
||||
const meetingType = cfg.meetingType ?? "department_sync";
|
||||
const title = cfg.title ?? "Auto-scheduled meeting";
|
||||
// Prefer an absolute scheduledAt; otherwise honor scheduleOffsetMinutes.
|
||||
// Default to +60min only when the rule specifies no time at all.
|
||||
const offsetMinutes = cfg.scheduleOffsetMinutes ?? 60;
|
||||
const scheduledAt = cfg.scheduledAt ?? new Date(Date.now() + offsetMinutes * 60_000).toISOString();
|
||||
db.saveMeeting({
|
||||
companyId: ctx.companyId,
|
||||
type: meetingType,
|
||||
title,
|
||||
organizerAgentId: ctx.agentId ?? null,
|
||||
participantAgentIds: (config.participantAgentIds as string) ?? "[]",
|
||||
scheduledAt: new Date(Date.now() + 3600_000).toISOString(),
|
||||
durationMinutes: (config.durationMinutes as number) ?? 30,
|
||||
participantAgentIds: cfg.participantAgentIds ?? "[]",
|
||||
scheduledAt,
|
||||
durationMinutes: cfg.durationMinutes ?? 30,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user