Alexa服务模拟器解析错误

时间:2017-07-11 12:32:04

标签: c# aws-lambda alexa alexa-skills-kit alexa-voice-service

我正在尝试使用VS2015和Alexa.Net nuget包向Alexa Echo Dot添加自定义技能。 我可以将lambda函数上传到Amazon Webservice。我能够看到技能。 但是当我尝试使用Service Simulator测试lambda函数时,我收到的错误是

  

“无法调用远程端点,或者它返回的响应无效。”
  “第1行的解析错误:   远程端点^期待'STRING',NUMBER',NULL ...“

我不确定这里到底缺少什么。这是详细信息

Lambda请求

{
  "session": {
    "sessionId": "SessionId.23409e06-265b-4704-a288-8d5329a68a68",
    "application": {
      "applicationId": "amzn1.ask.skill.55a9cca9-02dc-4780-a55c-c1d0dee6b8c6"
    },
    "attributes": {},
    "user": {
      "userId": "amzn1.ask.account.AHPIWHCHA22Z3WAJGS2ABA3MQ3PTKB4HOMJIBBDILIBPWTSAAOELN45D4PIV3U75IOBDHNGJQ36OSUYK43VQKYSQFIM2OHHOORSDWM2HMLWKINLCLKU7R3SNONWM7YPWSMR5XGN6XKVZGBG4NFHDQXACZLVK57MXUOIYYV6RLLVACBMMSFPVDINMO3QKQUZVZMVR73KTCEYTCRY"
    },
    "new": true
  },
  "request": {
    "type": "IntentRequest",
    "requestId": "EdwRequestId.082b6e56-29d4-4eed-a353-e24890cfbefa",
    "locale": "en-US",
    "timestamp": "2017-07-11T12:19:27Z",
    "intent": {
      "name": "CountryInfoIntent",
      "slots": {
        "Country": {
          "name": "Country",
          "value": "France"
        }
      }
    }
  },
  "version": "1.0"
}

功能处理程序

public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context)
{
    var requestType = input.GetRequestType();

    if (requestType == typeof(IntentRequest))
    {
        return MakeSkillResponse(
            $"Hello Infotec! This is the first response from your Alexa skill using c sharp.",
            true);
    }
    else
    {
        return MakeSkillResponse(
            $"I don't know how to handle this intent. Please say something like Alexa, ask {INVOCATION_NAME} about Canada.",
            true);
    }
}

private SkillResponse MakeSkillResponse(string outputSpeech, bool shouldEndSession, string repromptText = "Just say, tell me about Canada to learn more. To exit, say, exit.")
{
    var response = new ResponseBody
    {
        ShouldEndSession = shouldEndSession,
        OutputSpeech = new PlainTextOutputSpeech { Text = outputSpeech }
    };

    if (repromptText != null)
    {
        response.Reprompt = new Reprompt() { OutputSpeech = new PlainTextOutputSpeech() { Text = repromptText } };
    }

    var skillResponse = new SkillResponse
    {
        Response = response,
        Version = "1.0"
    };
    return skillResponse;
}

1 个答案:

答案 0 :(得分:1)

这是Alexa.Net nuget包中的一个错误。这已在最新的软件包中得到修复。

https://github.com/timheuer/alexa-skills-dotnet/commit/5c6dc0d2c0e3e16ca055d8938b1d0f24ad9670ed