如何获取用户的 Alexa 技能的日期/时间或时区信息? [英] How do I get a user's date/time or timezone information for an Alexa Skill?

查看:43
本文介绍了如何获取用户的 Alexa 技能的日期/时间或时区信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Lambda (Python) 来开发一项技能,并且我有兴趣为用户提供一些与时间相关的信息.在 request 对象上有一个 timestamp 但它是没有偏移的 UTC.有没有一种方法可以在无需询问位置信息的情况下找到用户的日期/时间或时区(如果这是唯一的方法,您是否知道美国邮政编码的数据库到时区或其他解决方法?).

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?).

推荐答案

现在可以使用 Alexa 设置 API.见相关博客文章 了解有关此功能发布的官方信息.

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

您只需提供用户的设备 ID,这是接收到的意图的一部分.响应将包含一个时区名称,例如欧洲/伦敦".

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".

这篇关于如何获取用户的 Alexa 技能的日期/时间或时区信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆