Ruby on rails 如何为自定义alexa技能创建和测试对话框?
我正在开发一个Alexa技能,在ROR API上进行帐户链接。我的LaunchRequest正常工作,但当我尝试进行IntentRequest(有3个插槽)时,我没有得到dialogState,Alexa只是告诉我我的响应有问题。我用亚马逊的skill builder测试版建立了技能模型。由于对话框不可在控制台或模拟器中测试,因此几乎不可能知道发生了什么。模型如下:Ruby on rails 如何为自定义alexa技能创建和测试对话框?,ruby-on-rails,alexa-skills-kit,alexa-skill,Ruby On Rails,Alexa Skills Kit,Alexa Skill,我正在开发一个Alexa技能,在ROR API上进行帐户链接。我的LaunchRequest正常工作,但当我尝试进行IntentRequest(有3个插槽)时,我没有得到dialogState,Alexa只是告诉我我的响应有问题。我用亚马逊的skill builder测试版建立了技能模型。由于对话框不可在控制台或模拟器中测试,因此几乎不可能知道发生了什么。模型如下: { "intents": [ { "name": "AMAZON.CancelIntent", "samples": []
{
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "RateWineIntent",
"samples": [...]
,
"slots": [
{
"name": "wine",
"type": "AMAZON.NUMBER",
"samples": [
"{wine}",
"wine {wine}",
"wine number {wine}"
]
},
{
"name": "rating",
"type": "AMAZON.NUMBER",
"samples": [
"{rating}",
"a rating of {rating}",
"rate it a {rating}",
"give it a rating of {rating}"
]
},
{
"name": "taster",
"type": "AMAZON.NUMBER",
"samples": [
"{taster}",
"taster number {taster}",
"taster {taster}",
"for taster {taster}",
"for taster number {taster}"
]
}
]
}],
"prompts": [
{
"id": "Confirm.Intent-RateWineIntent",
"promptVersion": "1.0",
"definitionVersion": "1.0",
"variations": [
{
"type": "PlainText",
"value": "I have a rating of {rating} on wine {wine} for taster {taster}. Is that correct."
}
]
},
{
"id": "Elicit.Intent-RateWineIntent.IntentSlot-wine",
"promptVersion": "1.0",
"definitionVersion": "1.0",
"variations": [
{
"type": "PlainText",
"value": "OK, which wine number?"
}
]
},
{
"id": "Elicit.Intent-RateWineIntent.IntentSlot-rating",
"promptVersion": "1.0",
"definitionVersion": "1.0",
"variations": [
{
"type": "PlainText",
"value": "And what rating for this wine?"
}
]
},
{
"id": "Elicit.Intent-RateWineIntent.IntentSlot-taster",
"promptVersion": "1.0",
"definitionVersion": "1.0",
"variations": [
{
"type": "PlainText",
"value": "Great. And for which taster number?"
}
]
}
],
"dialog": {
"version": "1.0",
"intents": [
{
"name": "RateWineIntent",
"confirmationRequired": true,
"prompts": {
"confirm": "Confirm.Intent-RateWineIntent"
},
"slots": [
{
"name": "wine",
"type": "AMAZON.NUMBER",
"elicitationRequired": true,
"confirmationRequired": false,
"prompts": {
"elicit": "Elicit.Intent-RateWineIntent.IntentSlot-wine"
}
},
{
"name": "rating",
"type": "AMAZON.NUMBER",
"elicitationRequired": true,
"confirmationRequired": false,
"prompts": {
"elicit": "Elicit.Intent-RateWineIntent.IntentSlot-rating"
}
},
{
"name": "taster",
"type": "AMAZON.NUMBER",
"elicitationRequired": true,
"confirmationRequired": false,
"prompts": {
"elicit": "Elicit.Intent-RateWineIntent.IntentSlot-taster"
}
}
]
}
]
}
}
以下是回应:
{
"session": {
"sessionId": "MY-SESSION-ID",
"application": {
"applicationId": "MY-APPLICATION-ID"
},
"attributes": {},
"user": {
"userId": "MY-USER-ID"
},
"new": true
},
"request": {
"type": "IntentRequest",
"requestId": "REQUEST-ID",
"locale": "en-US",
"timestamp": "2017-05-18T06:41:56Z",
"intent": {
"name": "RateWineIntent",
"slots": {
"taster": {
"name": "taster"
},
"rating": {
"name": "rating"
},
"wine": {
"name": "wine"
}
}
}
},
"version": "1.0"
}
我可以填充插槽,但不会生成对话框状态。有什么想法吗?有没有人能想出一个更好的方法来测试这个问题,而不用对着你的小点大喊大叫?问题在于我的回答。我只是根据我在亚马逊的文档中读到的内容返回了回复的
部分。这就是问题所在。我给任何想和Alexa合作的程序员的建议是开始。学习请求/响应JSON,因为这里的错误很难测试。亚马逊的文档似乎迫使你在编程之前先学习语音设计,我认为这是本末倒置。对着echosim.io尖叫?只是开玩笑而已。当主持人介绍对话和可选插槽时,我很兴奋。我自己为这类东西开发了自己的有限状态机,我发现我仍然更喜欢自己的实现,因为除其他外,我可以使用unittest正确地测试它。如果您感兴趣:谢谢@Josep,但我使用ROR作为后端。我终于明白了。我没有返回完整的响应。根据文档,我认为对话框中的响应是缩写的。实际上,它现在工作得非常好,节省了大量手动填充插槽的时间。