One of the most common questions I get from new Alexa developers is this: "I'm getting an error that says, 'The remote endpoint could not be called, or the response it returned was invalid.' How do I fix it?"
The good news is you have all of the tools you need between developer.amazon.com and aws.amazon.com.
Each time you use the Service Simulator, your typed utterance generates a service request. This service request is the JSON file that is passed to your AWS Lambda function. It indicates which intent was identified by Alexa, what the slot values were, and any other pertinent data about your request including a user ID, locale, and even device capabilities. Here's what the Service Simulator provides for my baseball skill, Games Back:
{
"session": {
"new": true,
"sessionId": "SessionId.22451bc9-7b92-4b79-8354-04cfbf99b6a6",
"application": {
"applicationId": "amzn1.ask.skill.88479642-7cbe-4dc6-baee-4afffa03b297"
},
"attributes": {},
"user": {
"userId": "amzn1.ask.account.AG5RXTR6YQBDMREHT7KO2BIT6J2SY3UO5L7RUJ2XSYU3REOAX2ENNL5EZGX53YT3OEFLFQ6VUSYHVEYXH3XBI23TN7SEUEAM6UIW2NCJIQ64VHEH2VKGUI45X6AFHWX7BRTXHFUIHGT5RDCCQOW6WJW4QTMETIIZ5SBAC7FDHPUBL3RP2P64666WDISVRTEKPRMYMGGVNYIW2JI"
}
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.d712248a-c374-4928-b8d1-da638bfc9946",
"intent": {
"name": "GetGamesBack",
"slots": {
"Team": {
"name": "Team",
"value": "mariners"
}
}
},
"locale": "en-US",
"timestamp": "2017-08-23T12:46:44Z"
},
"context": {
"AudioPlayer": {
"playerActivity": "IDLE"
},
"System": {
"application": {
"applicationId": "amzn1.ask.skill.88479642-7cbe-4dc6-baee-4afffa03b297"
},
"user": {
"userId": "amzn1.ask.account.AG5RXTR6YQBDMREHT7KO2BIT6J2SY3UO5L7RUJ2XSYU3REOAX2ENNL5EZGX53YT3OEFLFQ6VUSYHVEYXH3XBI23TN7SEUEAM6UIW2NCJIQ64VHEH2VKGUI45X6AFHWX7BRTXHFUIHGT5RDCCQOW6WJW4QTMETIIZ5SBAC7FDHPUBL3RP2P64666WDISVRTEKPRMYMGGVNYIW2JI"
},
"device": {
"supportedInterfaces": {}
}
}
},
"version": "1.0"
} "application": { "applicationId": "amzn1.ask.skill.88479642-7cbe-4dc6-baee-4afffa03b297" }, "attributes": {}, "user": { "userId": "amzn1.ask.account.AG5RXTR6YQBDMREHT7KO2BIT6J2SY3UO5L7RUJ2XSYU3REOAX2ENNL5EZGX53YT3OEFLFQ6VUSYHVEYXH3XBI23TN7SEUEAM6UIW2NCJIQ64VHEH2VKGUI45X6AFHWX7BRTXHFUIHGT5RDCCQOW6WJW4QTMETIIZ5SBAC7FDHPUBL3RP2P64666WDISVRTEKPRMYMGGVNYIW2JI" } }, "request": { "type": "IntentRequest", "requestId": "EdwRequestId.d712248a-c374-4928-b8d1-da638bfc9946", "intent": { "name": "GetGamesBack", "slots": { "Team": { "name": "Team", "value": "mariners" } } }, "locale": "en-US", "timestamp": "2017-08-23T12:46:44Z" }, "context": { "AudioPlayer": { "playerActivity": "IDLE" }, "System": { "application": { "applicationId": "amzn1.ask.skill.88479642-7cbe-4dc6-baee-4afffa03b297" }, "user": { "userId": "amzn1.ask.account.AG5RXTR6YQBDMREHT7KO2BIT6J2SY3UO5L7RUJ2XSYU3REOAX2ENNL5EZGX53YT3OEFLFQ6VUSYHVEYXH3XBI23TN7SEUEAM6UIW2NCJIQ64VHEH2VKGUI45X6AFHWX7BRTXHFUIHGT5RDCCQOW6WJW4QTMETIIZ5SBAC7FDHPUBL3RP2P64666WDISVRTEKPRMYMGGVNYIW2JI" }, "device": { "supportedInterfaces": {} } } }, "version": "1.0"}
Copy your version of the Service Request JSON from your skill at developer.amazon.com to move on to the next step.
You may have tried this before, but you can actually test your Lambda function for a specific utterance. To do this, open your Lambda function at aws.amazon.com/lambda and look for the "Actions" button in the top right corner of the screen. From the menu that appears, select "Configure Test Event."
The default test event that will be selected is "Hello World." You can certainly choose a different template from the dropdown, but since we will be deleting the contents of this template, Hello World is perfectly fine to use. Replace the few lines of code that are provided with the JSON you copied from the Service Simulator.
Once your JSON is in the test event box, you can click "Save and Test" to run that specific JSON file against your Lambda code.
At the top of your screen, assuming your skill was giving you an error, you should now see a red box with the title: "Execution Result: failed." If you expand the Details, you should now see a detailed error message about what exactly is failing in your skill.
At this point, you should be able to determine what your error is and where in your code it is occurring. Then you'll able to continue to retest that specific scenario over and over until it is working properly.
Hopefully this will help you figure out why a specific utterance is causing you headaches, or why specific phrases aren't getting the kinds of responses you expect! Good luck with your skill!
Got skills? Bring your big idea to life with the Alexa Skills Kit and earn perks through our new tiered rewards system. Publish a skill in September, and earn a pair of limited-edition Alexa dev socks. If 100 unique users use your skill in its first 30 days in the Alexa Skills Store, you can also apply to receive a free Echo Dot featuring a limited-edition developer skin design. Learn more about our promotion and start building today.