在某些情况下,我试图向用户加价订阅(该技能中唯一的高级产品)。但是,发送请求后,Alexa不会跟进,也不会启动加售过程。无法读取加售消息,也没有其他输出(只是静音)。
Lambda函数的处理程序中的Upsell指令
upsell_msg = ("Sorry, noobie! You just reached the daily limit for the Free Subscription! To get access to 10 prices per day, you can upgrade to the amazing Premium Subscription. {} Want to learn more?").format(subscription_pack[0].summary)
handler_input.attributes_manager.session_attributes["lastSpeech"] = upsell_msg
return handler_input.response_builder.add_directive(
SendRequestDirective(
name = "Upsell",
payload = {
"InSkillProduct": {
"productId": subscription_pack[0].product_id,
},
"upsellMessage": upsell_msg,
},
token = "correlationToken")).response
JSON输出
{
"body": {
"version": "1.0",
"response": {
"directives": [
{
"type": "Connections.SendRequest",
"name": "Upsell",
"payload": {
"InSkillProduct": {
"productId": "amzn1.adg.product.7a43a869-2b1e-4acb-b832-ec59ec253259"
},
"upsellMessage": "Sorry, noobie! You just reached the daily limit for the Free Subscription! To get access to 10 prices per day, you can upgrade to the amazing Premium Subscription. The Premium subscription allows you to get the real-time price of Bitcoin, Ethereum, Litecoin, XRP, or Bitcoin Cash, in US dollars, or Euros, 10 times a day! Want to learn more?"
},
"token": "correlationToken"
}
],
"type": "_DEFAULT_RESPONSE"
},
"sessionAttributes": {
"counter_prices": 3,
"lastSpeech": "Sorry, noobie! You just reached the daily limit for the Free Subscription! To get access to 10 prices per day, you can upgrade to the amazing Premium Subscription. The Premium subscription allows you to get the real-time price of Bitcoin, Ethereum, Litecoin, XRP, or Bitcoin Cash, in US dollars, or Euros, 10 times a day! Want to learn more?",
"counter_prices_time": "06/21/19 15:07:07"
},
"userAgent": "ask-python/1.10.1 Python/3.7.3"
}
}
Cloudwatch日志中未显示错误。
更新:
进一步研究之后,问题似乎出在Upsell指令位于意图处理程序中,该处理程序具有由Alexa处理的对话模型(对话委托策略-自动委派)。
我进行了以下测试:将Upsell指令移至Lambda函数中的另一个Intent处理程序(仅用于测试),并且在触发该Intent时,它可以完美运行。但是,在原始的Intent处理程序(将对话框委托设置为auto的处理程序)中,Upsell请求没有得到Alexa的响应。
该意图的JSON
{
"name": "PriceIntent",
"slots": [
{
"name": "crypto",
"type": "cryptoCoin",
"samples": [
"Give me the {crypto} price"
]
},
{
"name": "fiat",
"type": "fiatCoin",
"samples": [
"the {fiat} price please"
]
},
{
"name": "exchange",
"type": "theExchange"
}
],
"samples": [
"what is the price of {crypto} in {fiat} on {exchange}"
]
}
...
"dialog": {
"intents": [
{
"name": "PriceIntent",
"delegationStrategy": "ALWAYS",
"confirmationRequired": false,
"prompts": {},
"slots": [
{
"name": "crypto",
"type": "cryptoCoin",
"confirmationRequired": false,
"elicitationRequired": true,
"prompts": {
"elicitation": "Elicit.Slot.69186907495.1229392271052"
}
},
{
"name": "fiat",
"type": "fiatCoin",
"confirmationRequired": false,
"elicitationRequired": true,
"prompts": {
"elicitation": "Elicit.Slot.69186907495.1330830443661"
}
},
{
"name": "exchange",
"type": "theExchange",
"confirmationRequired": false,
"elicitationRequired": false,
"prompts": {}
}
]
}
],
"delegationStrategy": "ALWAYS"
},
"prompts": [
{
"id": "Elicit.Slot.69186907495.1419981262022",
"variations": [
{
"type": "PlainText",
"value": "I can tell you the price of {crypto} from Kraken, Coinbase, or Bitstamp. Pick one"
}
]
},
{
"id": "Elicit.Slot.69186907495.1330830443661",
"variations": [
{
"type": "PlainText",
"value": "Please tell me what currency would you like me to use for the price of {crypto} . US dollars, or Euros?"
}
]
},
{
"id": "Elicit.Slot.69186907495.1229392271052",
"variations": [
{
"type": "PlainText",
"value": "I can tell you the current price of Bitcoin, Ethereum, Litecoin, XRP, or Bitcoin Cash. Pick one"
}
]
}
]
任何帮助将不胜感激!