From 965561eb2206d3f49153e9090feb0364e89bce5f Mon Sep 17 00:00:00 2001 From: local Date: Sat, 9 May 2026 23:11:53 -0700 Subject: [PATCH] fix(api): type Activity.timestamp/localTimestamp as string, not Date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Bot Framework Activity protocol sends these as ISO-8601 strings over JSON (as the existing doc comments already say). Inbound activities are parsed by express.json() with no reviver and Activity.from() is just Object.assign — so at runtime these fields are strings, not Date objects. The Date type was a lie; calling activity.timestamp.toISOString() in a handler would crash. The withTimestamp/withLocalTimestamp builders still accept Date for ergonomics and normalize via toISOString(), so existing call sites keep working. --- packages/api/src/activities/activity.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/api/src/activities/activity.ts b/packages/api/src/activities/activity.ts index d23162ed1..70b9dd4da 100644 --- a/packages/api/src/activities/activity.ts +++ b/packages/api/src/activities/activity.ts @@ -34,7 +34,7 @@ export interface IActivity { /** * Contains the date and time that the message was sent, in UTC, expressed in ISO-8601 format. */ - timestamp?: Date; + timestamp?: string; /** * A locale name for the contents of the text field. @@ -50,7 +50,7 @@ export interface IActivity { * * For example, 2016-09-23T13:07:49.4714686-07:00. */ - localTimestamp?: Date; + localTimestamp?: string; /** * Contains an ID that uniquely identifies the channel. Set by the channel. @@ -138,7 +138,7 @@ export class Activity implements IActivity { /** * Contains the date and time that the message was sent, in UTC, expressed in ISO-8601 format. */ - timestamp?: Date; + timestamp?: string; /** * A locale name for the contents of the text field. @@ -154,7 +154,7 @@ export class Activity implements IActivity { * * For example, 2016-09-23T13:07:49.4714686-07:00. */ - localTimestamp?: Date; + localTimestamp?: string; /** * Contains an ID that uniquely identifies the channel. Set by the channel. @@ -302,8 +302,8 @@ export class Activity implements IActivity { return this; } - withTimestamp(value: Date) { - this.timestamp = value; + withTimestamp(value: Date | string) { + this.timestamp = value instanceof Date ? value.toISOString() : value; return this; } @@ -312,8 +312,8 @@ export class Activity implements IActivity { return this; } - withLocalTimestamp(value: Date) { - this.localTimestamp = value; + withLocalTimestamp(value: Date | string) { + this.localTimestamp = value instanceof Date ? value.toISOString() : value; return this; }