diff --git a/src/auto-reply/envelope.test.ts b/src/auto-reply/envelope.test.ts index 972dc06ff10d..2c2f059f17da 100644 --- a/src/auto-reply/envelope.test.ts +++ b/src/auto-reply/envelope.test.ts @@ -79,6 +79,16 @@ describe("formatAgentEnvelope", () => { const body = formatAgentEnvelope({ channel: "Telegram", body: "hi" }); expect(body).toBe("[Telegram] hi"); }); + + it("formats the Unix epoch timestamp", () => { + const body = formatAgentEnvelope({ + channel: "WebChat", + timestamp: 0, + envelope: { timezone: "utc" }, + body: "hello", + }); + expect(body).toBe("[WebChat Thu 1970-01-01T00:00:00Z] hello"); + }); }); describe("formatInboundEnvelope", () => { diff --git a/src/auto-reply/envelope.ts b/src/auto-reply/envelope.ts index 188fa9051b0b..43c2d0623d95 100644 --- a/src/auto-reply/envelope.ts +++ b/src/auto-reply/envelope.ts @@ -114,7 +114,7 @@ export function formatEnvelopeTimestamp( ts: number | Date | undefined, options?: EnvelopeFormatOptions, ): string | undefined { - if (!ts) { + if (ts === undefined) { return undefined; } const resolved = normalizeEnvelopeOptions(options);