python - 如何在 Alexa 中切换 APL 文档而不返回新文档?
问题描述
在开发我的 Alexa 技能时,每次我想在我的技能中更改用户的屏幕(使用 APL)时,我都会返回一个新的 APL 文档。但是,这很慢,因为它必须每次都加载文档。
有没有更好的方法来做到这一点,而不是每次都返回一个新文档?
我已经找到了一些关于此的信息,但很难在 Python 中找到答案。下面是我用来返回新文档的代码。
datasources = _load_apl_document("recipe_output_data.json")
if get_supported_interfaces(handler_input).alexa_presentation_apl is not None:
handler_input.response_builder.add_directive(
RenderDocumentDirective(
token="recipe_output",
document=_load_apl_document("recipe_output_APL.json"),
datasources=datasources
)
)
解决方案
如果您不想每次都加载文档,那么您可以在 apl 文档中使用 pager。制作一个寻呼机容器并将所有屏幕保存在项目中。并且在用户操作时不要再次发送文档,而是发送 apl 命令在页面之间切换。有关寻呼机和 apl 命令的信息,请参阅此内容
推荐阅读
- android - 错误:在项目“应用程序”中,已解决的 Google Play 服务库依赖项依赖于另一个确切版本的依赖项
- amazon-web-services - 使用请求路径从 AWS API Gateway 返回 302
- javascript - 如何将嵌套的对象数组转换为 Reactjs 中的字符串数组?
- reactjs - 显示字符串时如何显示换行符?
- angular - 角度服务数据未显示
- android - 如何设计一个可以在多个屏幕上工作的 UI?
- java - 如何在两个不同的活动中从 Firebase 实时数据库中检索数据
- regex - 如何使用 .htaccess 重写 mp3 文件名
- c++ - 在不构造字符串对象的情况下使用 std::string 的 std::hash 特化
- selenium - 将 WebDriver 从 GUI 更改为 Headless