我是Alexa自定义技能的新手,如果我的用户触发了需要身份验证的意图,我希望他们链接他们的帐户以继续使用我的技能。当然,我的技能需要返回一个说明,让他们知道如何链接他们的帐户。
我在Officical docs中找到了,但不幸的是没有python的示例代码。在网上搜索了几个小时后,我在ask_sdk_model.ui上找到了LinkAccountClass。所以我开始将这个类添加到我的代码中,如下所示:
from ask_sdk_model.ui import LinkAccountCard if not handler_input.request_envelope.context.system.user.access_token: speech = "You must open alexa app on your phone and link you account to continue" handler_input.response_builder.speak(speech).set_card(LinkAccountCard(speech)) return handler_input.response_builder.set_should_end_session(False).response
但是Alexa一直对我说“对不起,我帮不了你”。如果我使用.set_card(SimpleCard(speech))而不是.set_card(LinkAccountCard(speech)),Alexa会显示消息“你必须在你的手机上打开alexa应用程序并链接你的账户才能继续”,没有任何错误。那么我如何将linkAccountCard返回给用户,以帮助他们转到设置中的链接帐户?
非常感谢!
发布于 2020-05-08 20:29:40
LinkAccountCard不接受任何参数;将其更改为.set_card(LinkAccountCard())就可以了。Alexa提供了该卡的副本。
或者,您可以使用…
from ask_sdk_model.ui import Card
…
handler_input.response_builder.set_card(Card('LinkAccount'))发布于 2021-03-16 23:27:31
您不需要向LinkAccountCard传递任何参数
下面是一个示例代码:
from ask_sdk_model.ui import LinkAccountCard
...
return handler_input.response_builder.speak("Hello").set_card(LinkAccountCard()).responsehttps://stackoverflow.com/questions/61632789
复制相似问题