Alan B
Alan B

Reputation: 2299

Alexa Service Simulator Parse Error

I am trying to add custom skill to Alexa Echo Dot using VS2015 and Alexa.Net nuget packages. I am able to upload the lambda function to Amazon Webservice. And I am able to see the skills. However when I try to test the lambda function using Service Simulator, I am getting the error below

"The remote endpoint could not be called, or the response it returned was invalid."
"Parse error on line 1: The remote endpoint ^ Expecting 'STRING', NUMBER', NULL ... "

I am not sure what really missing here. Here is the details

Lambda Request

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

Function Handler

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;
}

Upvotes: 1

Views: 282

Answers (1)

Alan B
Alan B

Reputation: 2299

It was a bug in the Alexa.Net nuget package. And that has been fixed in the latest package.

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

Upvotes: 1

Related Questions