Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webchat not populating localTimestamp and localTimezone properties #3788

Closed
Kaiqb opened this issue Mar 10, 2021 · 8 comments · Fixed by #3896
Closed

Webchat not populating localTimestamp and localTimezone properties #3788

Kaiqb opened this issue Mar 10, 2021 · 8 comments · Fixed by #3896
Assignees
Labels
backlog Out of scope for the current iteration but it will be evaluated in a future release. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-reported Required for internal Azure reporting. Do not delete.
Milestone

Comments

@Kaiqb
Copy link

Kaiqb commented Mar 10, 2021

Describe the bug

Customer wants to know the following which we do not have an answer for:

I would like to know the reason why localTimezone and localTimestamp in Activity (Microsoft.Bot.Schema.Activity) are always empty when running as App Service. When we run on emulator on our local Mac machine, it always has a valid timestamp and timezone

Steps to reproduce

Confirmed that localTimestamp is not populated from webchat when bot is published in Azure. I am not sure how customer is accessing localTimezone property as the IMessageActivity interface that we use does not implement that property but the generic Activity does have a localTimezone property.

Additional context

[Bug]

@Kaiqb Kaiqb added bug Indicates an unexpected problem or an unintended behavior. customer-reported Required for internal Azure reporting. Do not delete. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. labels Mar 10, 2021
@Kaiqb
Copy link
Author

Kaiqb commented Mar 10, 2021

From Eric:
I’m not sure how to redirect this. I looked into it a little, and looks like we are not setting localTimestamp or localTimezone from webchat or directlinejs:

LocalTimestamp field is empty:
microsoft/BotFramework-DirectLineJS#248

Emulator is setting localTimestamp here:
https://github.com/microsoft/BotFramework-Emulator/blob/main/packages/app/main/src/server/state/conversation.ts#L534

Should we re-open this DL-JS issue, or do you have a different recommendation for this?

@Kaiqb Kaiqb added this to the R13 milestone Mar 10, 2021
@corinagum
Copy link
Contributor

Clarification: does this mean that the timestamp is not showing in the Web Chat UI on the 'Test in Web Chat' panel on ABS? Or is this in regards to the activity data?

If it's the latter, I think reopening the DLJS issue is the right call. If it's a UI issue, I can look into it further if we can get more repro information.

@EricDahlvang
Copy link
Member

@corinagum it is the latter (when the activity arrives at the bot, these fields are not populated)

@corinagum
Copy link
Contributor

This is not just DLJS but would need to be added to any chat adapter.

@corinagum corinagum added the backlog Out of scope for the current iteration but it will be evaluated in a future release. label Mar 10, 2021
@Kaiqb Kaiqb modified the milestones: R13, Post-R13 Mar 30, 2021
@corinagum corinagum modified the milestones: Post-R13, R14 Apr 26, 2021
@compulim
Copy link
Contributor

compulim commented May 6, 2021

When working on this, please also fix #2588.

@compulim
Copy link
Contributor

compulim commented May 19, 2021

Working on this now.

Activity spec:

Property Type Description
localTimestamp string Date and time that the message was sent in the local time zone, expressed in ISO-8601 format.
localTimezone string Contains the name of the local timezone of the message, expressed in IANA Time Zone database format. For example, America/Los_Angeles.

localTimestamp

https://stackoverflow.com/questions/17415579/how-to-iso-8601-format-a-date-with-timezone-offset-in-javascript

Also work for locations with time zones that are not a full hour, such as: India (+05:30), Eucla (+08:45), Chatham Islands of New Zealand (+13:45), etc.

localTimezone

To get the local time zone IANA name

new Intl.DateTimeFormat().resolvedOptions().timeZone

image

However, this does not work in IE11:

  • InPrivate mode: window.Intl object is undefined
  • Normal: timeZone property is not supported, will return undefined

Since hour offset is not a 1:1 translation to IANA time zone names, i.e. GMT-08:00 cannot be translated to America/Los_Angeles. We will return undefined for environments where Intl or timeZone returns undefined.

image

@compulim
Copy link
Contributor

compulim commented May 20, 2021

Even though Web Chat send out an activity to ABS with localTimestamp. The bot developer will need to retrieve them using rawLocalTimestamp.

Activity received on the bot side, after Web Chat sent out an activity with time zone of Japan. See highlighted.

Original activity from Web Chat

(Capture from network trace)

  {
    "channelData": {
      "clientActivityID": "1621475335684ql44o56fi4",
      "clientTimestamp": "2021-05-20T01:48:55.684Z"
    },
    "text": "dump-activity",
    "textFormat": "plain",
    "type": "message",
    "channelId": "webchat",
    "from": {
      "id": "dl_3fc4640be134b83b9b3f71c853ffba4a",
      "name": "",
      "role": "user"
    },
    "locale": "en-US",
+   "localTimestamp": "2021-05-20T10:48:55.684+09:00",
+   "localTimezone": "Asia/Tokyo",
    "timestamp": "2021-05-20T01:48:55.684Z",
    "entities": [
      {
        "requiresBotState": true,
        "supportsListening": true,
        "supportsTts": true,
        "type": "ClientCapabilities"
      }
    ]
  }

Perceived activity on bot side

  {
    "type": "message",
    "id": "IXiRn3wwW8lI2WShb0KaXA-o|0000000",
    "timestamp": "2021-05-20T01:48:55.506Z",
+   "localTimestamp": "2021-05-20T01:48:55.684Z",
+   "localTimezone": "Asia/Tokyo",
    "serviceUrl": "https://directline.botframework.com/",
    "channelId": "directline",
    "from": {
      "id": "dl_3fc4640be134b83b9b3f71c853ffba4a",
      "name": ""
    },
    "conversation": {
      "id": "IXiRn3wwW8lI2WShb0KaXA-o"
    },
    "recipient": {
      "id": "webchat-mockbot@WYDIyKwAZCw",
      "name": "webchat-mockbot"
    },
    "textFormat": "plain",
    "locale": "en-US",
    "text": "dump-activity",
    "entities": [
      {
        "type": "ClientCapabilities",
        "requiresBotState": true,
        "supportsListening": true,
        "supportsTts": true
      }
    ],
    "channelData": {
      "clientActivityID": "1621475335684ql44o56fi4",
      "clientTimestamp": "2021-05-20T01:48:55.684Z"
    },
    "rawTimestamp": "2021-05-20T01:48:55.5067653Z",
+   "rawLocalTimestamp": "2021-05-20T10:48:55.684+09:00",
    "callerId": "urn:botframework:azure"
  }

@HiroClubLabs
Copy link

HiroClubLabs commented May 20, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Out of scope for the current iteration but it will be evaluated in a future release. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-reported Required for internal Azure reporting. Do not delete.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants