如何为自定义alexa技能创建和测试对话框?

时间:2017-05-18 06:49:21

标签: ruby-on-rails alexa-skills-kit alexa-skill

我正在使用ROR API上的帐户链接开发Alexa技能。我有LaunchRequest工作,但是当我尝试创建一个IntentRequest(有3个插槽)时,我没有得到一个dialogState,而Alexa只是告诉我我的响应有问题。我使用亚马逊的技能构建测试版构建了技能模型。由于对话框在控制台或模拟器中无法测试,因此几乎无法确定是什么。这是模型:

{
"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"
}

我可以填充插槽,但不会产生dialogState。有任何想法吗?有没有人想出一个更好的方法来测试这个,而不用尖叫你的点?

1 个答案:

答案 0 :(得分:0)

问题在于我的回答。我刚刚根据我在亚马逊的文档中阅读的内容返回了响应的<Directive/>部分。哪个是问题所在。我对任何想要使用Alexa的程序员的建议是here。了解请求/响应JSON,因为这里的错误很难测试。亚马逊的文档似乎迫使你在编程之前学习语音设计,我认为这样可以把车推到马前。