Assuming your lambda is returning the variable called dinner as part of its JSON response, as my code is doing on line 18 in my code graphic, it probably means that the dinner variable does not contain a valid value. Open your AWS console and look at your lambda code. First, make sure you don’t have any syntax errors and that you aren’t missing any lines of code. If it looks OK, you can also look at the logs to help troubleshoot. Here’s how:
- Choose the Monitoring tab.

2. Next choose View logs in CloudWatch.

3. Find the most recent error (I simulated what I think is your error by throwing an invalid variable in the response called s):

When I added the invalid variable, my error in the utterance testing matched yours, so it’s likely a problem here…
import random # <-- HERE fourthdinnerOptions = [ # <-- HERE third
"Chicken",
"Beef",
"Pork",
"Fish",
"Vegetarian"
]def lambda_handler(event, context):
dinner = random.choice(dinnerOptions) # <-- HERE second
response = {
'version': '1.0',
'response': {
'outputSpeech': {
'type': 'PlainText',
'text': dinner, # <-- Check HERE first
}
}
}
return response
Make sure your variable name dinner and your list name, dinnerOptions, are spelled the same, including case, in all places. You can also put some print statements in your code which will also show you output in the CloudWatch logs. Hope this helps.
