我用于自定义 intent 的广告位始终被识别为None
。
我有一个这样的 intent 架构:
{
"interactionModel": {
"languageModel": {
"invocationName": "name_of_app",
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "EventsIntent",
"slots": [
{
"name": "eventCity",
"type": "AMAZON.GB_CITY"
}
],
"samples": [
"whats on in {eventCity}",
"whats going on in {eventCity} ",
"tell me what events are in {eventCity}"
]
}
],
"types": []
}
}
}
我的代码是使用flask-ask框架在python中编写的。我的主要入口点看起来像这样:
@ask.launch
def start_skill():
welcome_message = 'Welcome to name_of_app, what do you want?'
return question(welcome_message)
@ask.intent('EventsIntent', mapping={'city': 'eventCity'})
def weather(city):
return statement('you have selected {}'.format(city))
但是,即使这个简单的示例在输入为:
"whats on in London?"
我曾尝试在亚马逊开发者控制台的测试面板中使用小写字母和/或不使用标点符号,但是返回总是:
"you have selected None"
表示无作为“eventCity”传递。我是否在 intent 模式或代码中错误地传递了此插槽?
谢谢
最佳答案
嘿哥们,以下是您的问题的解决方案:
@ask.launch
def start_skill():
welcome_message = 'Welcome to name_of_app, what do you want?'
return question(welcome_message)
@ask.intent('EventsIntent', convert={'eventCity': str})
def weather(eventCity):
return statement('you have selected {}'.format(eventCity))
我也面临类似的问题,这件事解决了我的问题。
关于python - flask-ask插槽始终被映射为None,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49989604/