在Amazon Alexa中生成JSON请求时,在自定义插槽中获取无值

时间:2017-11-06 12:07:52

标签: alexa-skill

我的意图架构:

{
  "intents": [
    {
      "slots": [
        {
          "name": "FruitSlot",
          "type": "Fruit"
        }
      ],
      "intent": "ConverseGenieIntent"
    },
    {
      "intent": "AMAZON.HelpIntent"
    },
    {
      "intent": "AMAZON.StopIntent"
    },
    {
      "intent": "AMAZON.CancelIntent"
    }
  ]
}

自定义广告位类型: Fruit

值:

apple
orange
grapes
mango

示例话语:

ConverseGenieIntent apple
ConverseGenieIntent orange 
ConverseGenieIntent mango
ConverseGenieIntent grapes
ConverseGenieIntent pine apple

当我在服务模拟器中测试输入为“Mango”或“Apple”时,我收到的JSON输入请求生成为:

{
  "session": {
    "new": true,
    "sessionId": "SessionId.f11dd59a-d245-400e-b4a0-1398898921df",
    "application": {
      "applicationId": "amzn1.ask.skill.514ba391-33e5-4196-8a61-d140770a13d5"
    },
    "attributes": {},
    "user": {
      "userId": "amzn1.ask.account.AEMNWKN5GSRFKMORWJGDBMZ24RZFMNOWM5KWZU4UE2L5S4QUEP7DCXCRD4I6DXMDKVR5P2B3EWO5NAQR7P23R6XRC5IYHM34GFY7S4G3NLSADUQMEN4OJRGE4POSYYAZN53RVP3V7E2DZJJWFREPMLSM7G5Q22LRJGXHWBRTTPDYUIZTMGVNJVG6SHK3WDTNX2BP2JS5GKVCA7Y"
    }
  },
  "request": {
    "type": "IntentRequest",
    "requestId": "EdwRequestId.93fdc778-d0f9-4a3f-8298-295408a7bba3",
    "intent": {
      "name": "ConverseGenieIntent",
      "slots": {
        "FruitSlot": {
          "name": "FruitSlot"
        }
      }
    },
    "locale": "en-US",
    "timestamp": "2017-11-06T11:58:38Z"
  },
  "context": {
    "AudioPlayer": {
      "playerActivity": "IDLE"
    },
    "System": {
      "application": {
        "applicationId": "amzn1.ask.skill.514ba391-33e5-4196-8a61-d140770a13d5"
      },
      "user": {
        "userId": "amzn1.ask.account.AEMNWKN5GSRFKMORWJGDBMZ24RZFMNOWM5KWZU4UE2L5S4QUEP7DCXCRD4I6DXMDKVR5P2B3EWO5NAQR7P23R6XRC5IYHM34GFY7S4G3NLSADUQMEN4OJRGE4POSYYAZN53RVP3V7E2DZJJWFREPMLSM7G5Q22LRJGXHWBRTTPDYUIZTMGVNJVG6SHK3WDTNX2BP2JS5GKVCA7Y"
      },
      "device": {
        "supportedInterfaces": {}
      }
    }
  },
  "version": "1.0"
}

为什么我在“FruitSlot”中没有获得任何值?我错过了什么?

1 个答案:

答案 0 :(得分:1)

正如@Priyam Gupta所说,但现在在答案中提出了

示例话语应为ConverseGenieIntent {FruitSlot}

{FruitSlot}表示用户在此处所说的内容需要发送到名为FruitSlot的插槽,以便进一步检查并最终将其发送到您的后端以执行您的代码。

例如: 我说:" apple" Alexa会理解这个单词并将其与您的自定义类型进行核对#34; Fruit"在这里它会找到苹果(或不是),并将这个词发送到你的后端,同时应该在你的后端代码中调用它。