How to fix "There was a problem with the requested skill's response" error?

159 views Asked by At

I'm trying to follow this very basic tutorial on how to get Alexa to turn on an LED attached to a Raspberry Pi, but I never get a successful launch of the skill. I always get a "There was a problem with the requested skill's response." I checked the Device Log and InvocationResponse is always null.

I followed all the steps in the tutorial, except for the part where I have to copy-paste the code on the Intent Schema box. I assume that part is already taken care of automatically in the latest Developer Console, correct? I checked the JSON Editor tab and most of the Intent Schema code given by the tutorial was already written. I tried editing the JSON Editor but that did not work -- the response error still shows up.

I looked at other forums and they said the python script that I'm running locally on the Pi may be the problem. The script is an exact copy of this code as suggested by the tutorial. Ngrok seems to be working as it gives a 200 OK on the terminal.

I really have no idea how I can start debugging this issue. Hopefully someone could help me! Thanks!


This is the python script that I'm running on the Pi:

from flask import Flask
from flask_ask import Ask, statement, convert_errors
import RPi.GPIO as GPIO
import logging

GPIO.setmode(GPIO.BCM)

app = Flask(__name__)
ask = Ask(app, '/')

logging.getLogger("flask_ask").setLevel(logging.DEBUG)

@ask.intent('GPIOControlIntent', mapping={'status': 'status'})
def gpio_status(status):

if status in ['on','high' ]:
  GPIO.setup(21, GPIO.IN)
  state = GPIO.input(21)
  if (state == True):
    GPIO.setup(21, GPIO.OUT)
    GPIO.output(21,GPIO.HIGH)
    return statement('Lights are already on')
  else:
    GPIO.setup(21, GPIO.OUT)
    GPIO.output(21,GPIO.HIGH)
    return statement('Turning lights {}'.format(status))

if status in ['off','low' ]:
  GPIO.setup(21, GPIO.IN)
  state = GPIO.input(21)
  print('status of light',state)
  if (state == False):
    GPIO.setup(21, GPIO.OUT)
    GPIO.output(21,GPIO.LOW)
    return statement('Lights are already off')
  else:
    GPIO.setup(21, GPIO.OUT)
    GPIO.output(21,GPIO.LOW)
    return statement('Turning lights {}'.format(status))

if __name__ == '__main__':
port = 5000 #the custom port you want
    app.run(host='0.0.0.0', port=port)

This is what is on the JSON Editor in the AWS Developer Console

{
"interactionModel": {
    "languageModel": {
        "invocationName": "raspberry pi",
        "intents": [
            {
                "name": "AMAZON.FallbackIntent",
                "samples": []
            },
            {
                "name": "AMAZON.CancelIntent",
                "samples": []
            },
            {
                "name": "AMAZON.HelpIntent",
                "samples": []
            },
            {
                "name": "AMAZON.StopIntent",
                "samples": []
            },
            {
                "name": "AMAZON.NavigateHomeIntent",
                "samples": []
            },
            {
                "name": "GPIOControlIntent",
                "slots": [
                    {
                        "name": "status",
                        "type": "GPIO_Control"
                    }
                ],
                "samples": [
                    "turn the light {status}",
                    "turn {status} the light"
                ]
            }
        ],
        "types": [
            {
                "name": "GPIO_Control",
                "values": [
                    {
                        "name": {
                            "value": "off"
                        }
                    },
                    {
                        "name": {
                            "value": "on"
                        }
                    }
                ]
            }
        ]
    }
}
}
0

There are 0 answers