wit icon indicating copy to clipboard operation
wit copied to clipboard

Reference #1348 - Wit-ai returns different date and time, if timezone specified

Open umasudheesh opened this issue 7 years ago • 8 comments

Reference #1348

Hi @patapizza, Thank you for your reply. I have already applied your suggestion before raising the issue in wit of passing timezone in request. As per your suggestion, if the case is that -

If the client mention some other timezone apart from his own timezone - "call me at 2 pm pdt est"

The result are as follows -

{
  "_text": "call me at 2 pm pdt est",
  "entities": {
    "positive_reply": [
      {
        "confidence": 1,
        "value": "Yes you can call",
        "type": "value"
      }
    ],
    "datetime": [
      {
        "confidence": 0.96036125,
        "values": [
          {
            "value": "2019-03-15T21:00:00.000+00:00",
            "grain": "minute",
            "type": "value"
          },
          {
            "value": "2019-03-16T21:00:00.000+00:00",
            "grain": "minute",
            "type": "value"
          },
          {
            "value": "2019-03-17T21:00:00.000+00:00",
            "grain": "minute",
            "type": "value"
          }
        ],
        "value": "2019-03-15T21:00:00.000+00:00",
        "grain": "minute",
        "type": "value"
      }
    ]
  },
  "msg_id": "1lvoFnqtHpDZbMrFh"
}

still faced the same issue. Date time entity is one part of our project, apart from we use more entities to communicate with the clients. For every request I can't pass the timezone kind. Our sales teams are from other timezone, so we have to schedule date and time according to their time zone too. I hope you understood my issue

Thanks.

umasudheesh avatar Mar 15 '19 04:03 umasudheesh

I see. Will bring this up with the team to see if we can prioritize some sort of timezone parsing.

jtliao avatar Mar 18 '19 02:03 jtliao

Hi @umasudheesh,

Re call me at 2 pm pdt est, we can fix to prevent parsing multiple timezone mentions, to only parse call me at 2pm pdt and call me at 2pm est but not call me at 2 pm pdt est. In the example above, it seems like you're still sending the UTC timezone in the request and convert afterwards. Can you clarify your current flow, why you can't pass the client timezone and how the sales teams come into play? Thanks.

patapizza avatar Mar 18 '19 16:03 patapizza

HI @patapizza , @jtliao

I guess you didn't understood my issue.

I am using wit.ai for different proposes too, to communicate with the clients. In every request i cant pass the timezone kind, right. If he say where is your company located I have to reply my address with location, right. In this scenario i cant pass timezone. I have some sort of algorithm in my backend to reply it so. that flow will completely go wrong.

In any kind of project if client or customers are there then there will be one sales team to handle them not the developer to coordinate or for further communication with them.

My project work with basic communication with the clients. To know there interest in our product or not. if yes then schedule with the sales team for further discussion.

Here the clients can be from any timezone and sales team too.

I can pass client timezone in request but if the client profusely send some other timezone then how will I identify it?

We used to get raw data of clients detail to feed in our database. In that data we get his location and timezone. In some cases like he might be in some other timezone apart from his own. then he will say that location's timezone.

E.g: In my database Client A is belongs PST time zone. and he traveled to EST timezone. if he says call me at 2pm est and i pass my request to wit as you suggested like pass the client timezone. In my database it feeded as PST.

Then my request will be as -

call me at 2pm pst.

I will append that pst in that statement. And in the response i get converted pst time not the user requested time with timezone. which is wrong.

My question was very simple - how will I identify whether the user inputs along with timezone? cause I am getting the response in UTC.

For your understanding below is the examples - Client belongs to EST (in database) And Sales team belongs to PDT working hours (7 am to 7 pm)

if he says - call me at 2 pm --- wit.ai response in UTC => 3/19/2019, 2:00:00 PM I will set the requested time in EST (client timezone in database) for call scheduling. i.e 2 pm EST and 11 am in PDT (EST to PDT). The call will schedule for 11 am PDT cause it fits in sales team working hours

In some situation Client request some other timezone like PDT.

call me at 2 pm PDT --- wit.ai response in UTC => 3/19/2019, 9:00:00 PM I will set the requested time in EST (client timezone in database) for call scheduling. i.e 9 pm EST and 6 pm in PDT (EST to PDT). The call will schedule for 6 pm PDT cause it fits in sales team working hours. Which is wrong. Because here client request for 2 pm PDT .

If I get to know there is a conversion in time, simply I will set the call accordingly.

I hope that I make it clear with all my points.

Thanks.

umasudheesh avatar Mar 19 '19 05:03 umasudheesh

Thanks for the thorough context @umasudheesh, this really helps!

What I meant by "passing the client timezone in the request", is to set timezone or reference_time as part of the context parameter when making API calls, using the client timezone from your database. The reason why you're getting UTC is because you don't set this parameter, and your timezone is set to UTC in your Wit app settings.

// User request: "call me at 2pm"
// User timezone in database: "pst" (or rather: "America/Los_Angeles")
// Sales team timezone: "est" (or rather: "America/New_York")

// Currently
{"q": "call me at 2pm pst"}
-> "2019-03-20T22:00:00.000+00:00"
// UTC -> PST conversion for client
// UTC -> EST conversion for sales team

// Suggested
{"q": "call me at 2pm", "context": {"timezone": "America/Los_Angeles"}}
-> "2019-03-20T14:00:00.000-07:00"
// Use directly for the client
// America/Los_Angeles -> America/New_York conversion for the sales team
// Or make a second call with the "America/New_York" timezone to get directly the sales team datetime
// User request: "call me at 2pm PDT"
// User timezone in database: "est" (or rather: "America/New_York")
// Sales team timezone: "est" (or rather: "America/New_York")

// Currently
{"q": "call me at 2pm PDT est"}
-> "2019-03-20T21:00:00.000+00:00" // "est" is ignored as there's already a timezone mention
// UTC -> EST conversion for client and sales team

// Suggested
{"q": "call me at 2pm PDT", "context": {"timezone": "America/New_York"}}
-> "2019-03-20T17:00:00.000-04:00"
// Use directly for the client and the sales team

Now if you know the user location, then use that instead of the database timezone (or update it) when making API calls. I strongly recommend to use e.g. "America/Los_Angeles" and "America/New_York" instead of "PST" and "EST" to store timezones, as these handle daylight savings offsets.

Hope this helps.

patapizza avatar Mar 20 '19 17:03 patapizza

Hi @patapizza , @jtliao

What ever you suggested above I have done with that. I am working with wit ai for almost a year.

I dont know about my clients live locations and all. as there is no live location detection or gps for tracking there location in my project. Understand this first.

I process sending messages based on details in database. And about saving timezone in Database, I used to save as "America/Los_Angeles" this format.

Coming to the point of UTC in Wit ai. I have already told you about this. I want some centralized timezone for project to work with as my users are from different timezone so I set with UTC.

Try to understand the issue as you are an end user. If a user doesn't mentions timezone for scheduling call then wit.ai replies with exact time what user has mentioned like "call me at 2 pm - wit.ai responses in UTC => 3/22/2019, 2:00:00 PM"

But if a user says call me at 2PM PDT on 22nd March 2019 then wit.ai doesn't replies with exact time like "call me at 2 pm PDT - wit.ai responses in UTC => 3/22/2019, 9:00:00 PM"

So please understand the issue, that by seeing the wit response how will I identify which time wit.ai has converted and which one is not converted. As an end user how will get to know the difference.

Thanks in Advance!

umasudheesh avatar Mar 22 '19 12:03 umasudheesh

Hi @umasudheesh,

Got it, no live location. So you use the user's timezone from the database, correct? What I'm trying to get, I guess, is why you're not passing the user's timezone from the database in the context of the request, and use the user's timezone as a base to convert to other timezones (e.g. sales team). You shouldn't have to deal with UTC time.

patapizza avatar Mar 25 '19 17:03 patapizza

@patapizza , @jtliao

I would recommend some one else to look into this. Please assign some one else. I am not getting it why @patapizza didn't getting the point. or he just want to extend this unnecessarily. I have explained him each and every cases in detailed. Still he come up with same thing.

If u guys don't want to enhance this then do say straight forward rather than wasting my time as well yours.

I don't know how many times I have to repeat the same thing to you @patapizza ?

At least answer this question who hired you in Facebook / Wit ai ? @patapizza .

I have explained you in detail with simple way, even though you are repeating the same question like WHY YOU ARE NOT PASSING THE CLIENT / SALES TEAM LOCATION IN REQUEST

Read my queries once again from start.

umasudheesh avatar Mar 26 '19 04:03 umasudheesh

Hi @umasudheesh,

I'm sorry we aren't understanding each other correctly. There's no need to be rude, I was trying to help. :)

Closing this now, let's not waste each other's time any further. Maybe you'll get my point by reading again my answers.

patapizza avatar Mar 28 '19 20:03 patapizza