article

Monday, January 13, 2020

Hello World - How to Make an Alexa Skill with Python part 1

Hello World - How to Make an Alexa Skill with Python part 1
import json

# --------------- entry point -----------------

def lambda_handler(event, context):
    """ App entry point  """
    return response("", response_plain_text("hello word", True))


# --------------- speech response handlers -----------------
# build the json responses

def response_plain_text(output, endsession):
    """ create a simple json plain text response  """
    return {
        'outputSpeech': {
            'type': 'PlainText',
            'text': output
        },     
        'shouldEndSession': endsession
    }

def response(attributes, speech_response):
    """ create a simple json response """
    return {
        'version': '1.0',
        'sessionAttributes': attributes,
        'response': speech_response
    }
//demoquiz.json
{
    "interactionModel": {
        "languageModel": {
            "invocationName": "demo quiz",
            "intents": [
                {
                    "name": "AMAZON.CancelIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.HelpIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.StopIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.NavigateHomeIntent",
                    "samples": []
                },
                {
                    "name": "demo quiz",
                    "slots": [],
                    "samples": [
                        "start"
                    ]
                },
                {
                    "name": "AMAZON.RepeatIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.StartOverIntent",
                    "samples": [
                        "start new game"
                    ]
                }
            ],
            "types": []
        }
    }
}

Related Post