Hi I am trying to get a respond from Alexa requesting on a backend using requests. I am using Python with these example: https://github.com/alexa/skill-sample-python-fact. However my backend is NodeJS.
From my Lambda:
URL = 'https://alexa-app-nikko.herokuapp.com/alexa'
def get_post_response():
r = requests.get(URL)
speech_output = str(r.text)
return response(speech_response(speech_output, True))
On my backend, it is routed to /alexa:
router.get('/', function(request, response) {
//console.log('Logged from Alexa.');
response.send('Hello World, Alexa!');
});
I tested it on the Lambda and works fine with these results:
{
"version": "1.0",
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "Hello World, Alexa!"
},
"shouldEndSession": true
}
}
However I get a null
on the Skill Output or this response from Alexa:
"There was a problem with the requested skill's response"
How do I debug from the Developer Console, because it seems the Lambda is fine.
Based on your own answer :
The problem is, when you invoke the LaunchIntent
or other intents like AMAZON.StopIntent
it doesn't have the key "slots"
in them. And you were trying to access the value of slots
which should throw a KeyError.
What you can do is, when you're sure of invocation of any particular intent which uses some slots, then you try to access them.
This is what I do :
def getSlotValue(intent, slot):
if 'slots' in intent:
if slot in intent['slots']:
if 'value' in intent['slots'][slot] and len(intent['slots'][slot]['value']) > 0:
return intent['slots'][slot]['value']
return -1
And try to access the slot values in your intent's function (in your get_post_response
or get_power_response
).