Proposal to change protocol for message.timestamp
I propose that the timestamp field for received messages utilize the unknown local offset convention of RFC 3339 and that - when the channel permits obtaining the local timezone information - the timestamp reflect the local offset.
What this means in practice is, e.g., for the Bot Framework Emulator, instead of transmitting this message in JSON:
{
"type": "message",
"text": "some message content",
"from": {
"id": "default-user",
"name": "User"
},
"timestamp": "2016-11-28T03:14:04.054Z",
"channelData": {
"clientActivityId": "1480302834461.7015973076449713.0"
},
"serviceUrl": "http://localhost:9005",
"id": "7177bd518g925bnac",
"channelId": "emulator",
"recipient": {
"id": "default-bot"
},
"conversation": {
"id": "64ndeg1ak251l1m4gc"
}
}
It would instead transmit this for the timestamp field, per RFC 3339:
"timestamp": "2016-11-28T03:14:04.054-00:00",
Or, as the bot emulator runs on a channel that permits access to a local clock, messages would be sent using my local time and offset:
"timestamp": "2016-11-27T21:14:04.054-06",
Certain channels such as Slack permit obtaining the user's local time, which could be used to provide this to the bot framework, and for other channels I would suggest amending the Bot State REST API to include a well known key for persisting the user's preferred offset. This would allow bots to request and/or modify the user's time zone or preferred offset. If the offset is set,
In summary, the changes I request are, to use RFC language:
-
The channel adapter or client should set the
timestampfield using the local offset when available -
If the local offset remains undetermined and a preferred offset is persisted and available in the Bot State REST API, then the channel adapter or client should set the
timestampaccording to that preference -
If the local offset remains undetermined, the channel adapter or client must set the timestamp using unknown local offset convention
I believe this handles the use case and issue raised in #1240 and #813, that of handling channels such as SMS. I believe that to avoid confusion, the Bot Framework should not set the local offset of a user automatically, because it could make debugging behavior when communicating over multiple channels very confusing.
Hi @AaronFriel, the latest revision of the Bot Framework protocol includes a new localTimestamp field that contains time specific to the user. We also allow channels to set this timestamp freely, so it can reflect e.g. the timestamp when a user took an action on a client instead of the timestamp when the message was processed on a server.
The addition of RFC3339 is an interesting one. Given that localTimestamp is known to be a user-specific timestamp (and therefore we would only use Zulu time when appropriate), does the unknown-local-fallback convention confer any new data?
If a localTimestamp is provided if and only if we know for sure the local offset of the user, then no, I don't think it would confer any additional data. I would then assume that timestamp is UTC and non-local.
Closing as it looks like we've got enough in the protocol to handle this. Please open a new issue or at-mention to discuss further. Thanks!
@dandriscoll i am using webchat and c# and the activity.localtimestamp value is null for my messages. Can you please help understand if this needs to be set somewhere in the request?
@kalykodu Did you get the localtimestamp in C# bot service?