Coding Your Skill: The Help Intent

get_welcome_response

Let's take a look back at the original if statement inside on_intent:

if intent_name == "GetPokemonIntent":
        return get_pokemon_name(intent, session)
    elif intent_name == "AMAZON.HelpIntent":
        return get_welcome_response()
    elif intent_name == "AMAZON.CancelIntent" or intent_name == "AMAZON.StopIntent":
        return handle_session_end_request()
    else:
        raise ValueError("Invalid intent")

we'll see in the first elif that if a HelpIntent is triggered (basically if you ask Alexa for help with your skill), we run a function get_welcome_response. It's called get_welcome_response because it's also meant to be the first thing that the user hears when they start up the skill.

Here's the existing get_welcome_response():

def get_welcome_response():
    """
    If we wanted to initialize the session to have some attributes we could
    add those here
    """
    session_attributes = {}
    card_title = "Welcome"
    speech_output = "Welcome to the Echomon skill."
    # If the user either does not reply to the welcome message or says something
    # that is not understood, they will be prompted again with this text.

    #TODO: Give a welcome response.
    reprompt_text = "Please try asking for a pokemon's name by, "
    should_end_session = False
    return build_response(session_attributes, build_speechlet_response(
        card_title, speech_output, reprompt_text, should_end_session))

We'll simply give the user a preview on how to use the skill. We'll replace the speech output with:

speech_output = "Welcome to the Echomon skill. " \
                "Try asking for a pokemon's name by asking, " \
                "What pokemon is number 25?"

That pretty much wraps up the coding part! Now, we'll have to submit it to Lambda.

← Previous
Next →