diff --git a/src/config/config.ts b/src/config/config.ts index dfb9d87bd..4964d21ef 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -48,6 +48,8 @@ export type WarelayConfig = { allowFrom?: string[]; // E.164 numbers allowed to trigger auto-reply (without whatsapp:) samePhoneMarker?: string; // Prefix for same-phone mode messages (default: "[same-phone]") samePhoneResponsePrefix?: string; // Prefix auto-added to replies in same-phone mode (e.g., "🦞") + timestampPrefix?: boolean; // Prepend compact timestamp to messages (default: false) + timestampTimezone?: string; // IANA timezone for timestamp (default: UTC), e.g., "Europe/Vienna" transcribeAudio?: { // Optional CLI to turn inbound audio into text; templated args, must output transcript to stdout. command: string[]; @@ -143,6 +145,8 @@ const WarelaySchema = z.object({ allowFrom: z.array(z.string()).optional(), samePhoneMarker: z.string().optional(), samePhoneResponsePrefix: z.string().optional(), + timestampPrefix: z.boolean().optional(), + timestampTimezone: z.string().optional(), transcribeAudio: z .object({ command: z.array(z.string()), diff --git a/src/web/auto-reply.ts b/src/web/auto-reply.ts index 96428a9f3..8ea4bda43 100644 --- a/src/web/auto-reply.ts +++ b/src/web/auto-reply.ts @@ -562,12 +562,26 @@ export async function monitorWebProvider( lastInboundMsg = msg; + // Build timestamp prefix if enabled + let timestampStr = ""; + if (cfg.inbound?.timestampPrefix) { + const tz = cfg.inbound?.timestampTimezone ?? "UTC"; + const now = new Date(); + try { + // Format: "Nov 29 06:30" - compact but informative + timestampStr = `[${now.toLocaleDateString("en-US", { month: "short", day: "numeric", timeZone: tz })} ${now.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", hour12: false, timeZone: tz })}] `; + } catch { + // Fallback to UTC if timezone invalid + timestampStr = `[${now.toISOString().slice(5, 16).replace("T", " ")}] `; + } + } + // Prefix body with marker in same-phone mode so the assistant knows to prefix replies // The marker can be customized via config (default: "[same-phone]") const samePhoneMarker = cfg.inbound?.samePhoneMarker ?? "[same-phone]"; const bodyForCommand = isSamePhoneMode - ? `${samePhoneMarker} ${msg.body}` - : msg.body; + ? `${timestampStr}${samePhoneMarker} ${msg.body}` + : `${timestampStr}${msg.body}`; const replyResult = await (replyResolver ?? getReplyFromConfig)( {