首页 > 解决方案 > 如何在 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
                )
        )

标签: pythonalexaalexa-skills-kitalexa-presentation-language

解决方案


如果您不想每次都加载文档,那么您可以在 apl 文档中使用 pager。制作一个寻呼机容器并将所有屏幕保存在项目中。并且在用户操作时不要再次发送文档,而是发送 apl 命令在页面之间切换。有关寻呼机和 apl 命令的信息,请参阅此内容


推荐阅读