Alexa не отвечает на запрос Upsell, исходящий от обработчика намерения с включенным автоматическим делегированием - PullRequest
0 голосов
/ 24 июня 2019

Я пытаюсь перепродать подписку (единственный премиальный продукт в навыке) пользователю в определенном сценарии.Однако Alexa не отслеживает и не запускает процесс перепродажи при отправке запроса.Сообщение upsell не читается, и нет другого выхода (только тишина).

Директива Upsell внутри обработчика в функции Lambda

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 (Dialog Delegation Strategy - auto Delegation).

Я сделал следующееtest: переместил директиву Upsell в другой обработчик намерений в моей функции Lambda (только для тестирования), и она прекрасно работает, когда это намерение запускается.Однако в исходном обработчике намерений (в котором делегирование диалога установлено как авто), запрос 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"
            }
        ]
    }
]

Любая помощь будет принята с благодарностью!

...