【发布时间】:2019-07-23 20:09:52
【问题描述】:
有没有什么方法可以在 Alexa 技能中显示像“阅读更多”这样的超链接? 我正在尝试在我的自定义 Alexa 技能中显示超链接,但找不到任何方法来实现它
【问题讨论】:
-
您的意思是在发送卡片作为回复的一部分时?如果是这样,没有。那是不可能的。 developer.amazon.com/docs/custom-skills/…
标签: alexa
有没有什么方法可以在 Alexa 技能中显示像“阅读更多”这样的超链接? 我正在尝试在我的自定义 Alexa 技能中显示超链接,但找不到任何方法来实现它
【问题讨论】:
标签: alexa
超链接现在作为APL 指令的一部分提供给支持它的设备。你可以阅读文档here:
OpenURL 命令
如果成功,OpenURL 命令会在 web 中打开指定的 URL 浏览器或设备上的其他应用程序。您必须提供一个 适用于当前设备的合适 URL。
他们举了一个例子:
{
"type": "OpenURL",
"source": "https://www.amazon.com/",
"onFail": {
"type": "SetValue",
"componentId": "errorText",
"property": "text",
"value": "Unable to open Amazon.com (${event.source.value})"
}
}
支持设备说明:
并非所有设备都支持打开 URL。如果设备不支持 打开 URL,该命令被忽略并且它不会运行 onFail 命令。检查数据绑定中 allowOpenURL 的值 上下文来确定设备是否支持 OpenURL。
【讨论】:
我在我的技能中尝试过这个,但我得到的只是一个空白(黑色)页面。 正常情况下,Echo Show 设备上的 Silk 浏览器可以正常显示我尝试的页面。
我使用以下APL文档进行测试:
{
"type": "APL",
"version": "1.9",
"description": "A hello world APL document.",
"theme": "dark",
"mainTemplate": {
"parameters": [
"payload"
],
"items": [
{
"type": "OpenURL",
"source": "http://192.168.254.240/",
"onFail": {
"type": "SetValue",
"componentId": "errorText",
"property": "text",
"value": "Unable to open (${event.source.value})"
}
}
]
}
}
那怎么了?
我找到了正确的用法(或解决方法):
{
"type": "APL",
"version": "1.8",
"theme": "dark",
"import": [
{
"name": "alexa-layouts",
"version": "1.5.0"
}
],
"mainTemplate": {
"parameters": [
"payload"
],
"items": [
{
"type": "Pager",
"id": "fisrtpager",
"width": "100%",
"height": "100%",
"items": [
],
"navigation": "none",
"onMount": [{
"type": "OpenURL",
"source": "http://192.168.254.240/",
"onFail": {
"type": "SetValue",
"componentId": "errorText",
"property": "text",
"value": "Unable to open Amazon.com (${event.source.value})"
}
}]
}
]
}
}
【讨论】: