Alexa lambda_handler not creating event session
<p>I am having a problem getting my python lambda function to work.  I get an invalid key for the event array that should be created when the skill is invoked.  The error I get is:</p>

<pre><code>{
    "stackTrace": [
        [
            "/var/task/lambda_function.py",
            163,
            "lambda_handler",
            "app_id = event['session']['application']['applicationId']"
            ]
    ],
    "errorType": "KeyError",
    "errorMessage": "'session'"
}
</code></pre>

<p>and here is my code</p>

<pre><code>def lambda_handler(event, context):


"""Lambda function entrypoint."""
# print("event.session.application.applicationId={}".format(
#       event['session']['application']['applicationId']))

# Prevent unwanted access to this Lambda function.
app_id = event['session']['application']['applicationId']
if app_id != "amzn1.ask.skill.yyyyyyyy-xxx":
    raise ValueError("Invalid Application ID: {}".format(app_id))

request = event['request']

if event['session']['new']:
    on_session_started(
        {'requestId': request['requestId']}, event['session'])

func_map = {
    "LaunchRequest": on_launch,
    "IntentRequest": on_intent,
    "SessionEndedRequest": on_session_ended,
}

return func_map[request['type']](event['request'], event['session'])
</code></pre>

<p>The problem was I had configured the wrong test in the Lambda Function dashboard.  When I changed it to an Alexa Start Session, the event object got created.  :)</p>

python aws-lambda alexa alexa-skills-kit