How do I get a user's date/time or timezone information for an Alexa Skill?
Asked Answered
C

1

4

I'm using Lambda (Python) to develop a skill and I'm interested in giving the user some time-related information. On the request object there is a timestamp but that is UTC without offset. Is there a way to find the user's date/time or timezone without having to ask for location information (and if that's the only way, do you know of a database of US zip codes to timezone or another workaround?).

Concent answered 19/5, 2017 at 14:28 Comment(7)
This will help with the zip-to-timezone question: #2456824Ironsmith
Zip code is really not a great way to set time zone. Especially if you want to handle customers outside the US.Glavin
@MattJohnson agreed, and I see how it will become a burden if I ever deploy to other regions (like the UK, but luckily, they have only one time zone there) but I don't see any other option for the time being.Concent
Don't know a whole lot about Alexa Skills, but if there's a way to get a zip code, is there also a way to get just a lat/lon or other location info? If so, there are APIs to translate lat/lon to time zone here: https://mcmap.net/q/21176/-how-to-get-a-time-zone-from-a-location-using-latitude-and-longitude-coordinatesGlavin
@MattJohnson Thanks, currently there are only two options: Country+Zip OR Full street address.Concent
Perhaps try a geocoding API like Google's? You can then go after the time zone from there. developers.google.com/maps/documentation/geocoding/startGlavin
If anyone is interested in this, there is a feature request in the Amazon forums here: forums.developer.amazon.com/questions/8857/…Concent
B
0

It is now possible to get the user's timezone using the Alexa Settings API. See the related blogpost for official information about this feature's release.

The endpoint you'll be interested in is the following:

GET /v2/devices/{deviceId}/settings/System.timeZone

You simply need to provide the user's device ID, which is part of the received intent. The response will contain a timezone name, for instance "Europe/London".

Back answered 21/8, 2018 at 20:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.