Skip to content

Instantly share code, notes, and snippets.

@panzerama
Forked from rogerwschmidt/alexa-hello-world.md
Created October 27, 2017 01:14
Show Gist options
  • Save panzerama/66cba3b8f91b877938035defa1d89161 to your computer and use it in GitHub Desktop.
Save panzerama/66cba3b8f91b877938035defa1d89161 to your computer and use it in GitHub Desktop.

Sign in to the Amazon Developer Console

https://developer.amazon.com/

Click on the Sign In button on the top right

Enter your credentials

Note: If this is your first time logging in to an Amazon Developer Account, you might need to enter a few more details

Click on the Alexa button on the top middle of the screen

Click on 'Get Started' button on the Alexa Skill Kit Frame

Click on the 'Add a New Skill` Button on the top right

Note: This page will list all Alexa Skills that you have already created.

Create a name and invocation for your skill, then hit save

  1. Skill type is used to target devices with different capabilities, keep on Custom Interaction Model.
  2. The name is what is displayed to the customers of your skill. In this case, name it Greeter.
  3. The invocation are the words that you use to activate this skill. In this case, we'll use the name of the Skill, greeter.
  4. These are settings that allow for more complex Alexa Skills, leave them as No.
  5. Click Save on the bottom left of the screen.

Click Next on the bottom right of the screen.

Note: If there where problems with the form in the previous step, this button will not show.

Click on the Launch Skills Builder Button

The Skills Builder will look as follows

Note: This is where you will add Intents to your skill. Intents are how you communicate with the Skill, for example 'What is the weather like today' can be made into an intent.

Click on the ADD + button on the panel on the left of the screen.

Note: This will let us add a brand new Intent. Notice the three intents (Cancel, Help, and Stop) that Amazon has provided as defaults.

When you click ADD + your screen will look as follows.

Type in SayHello (this will be the name of the new intent) and Click Create Intent

Once the SayHello Intent is created, Your screen will look like this.

Create a new utterance Say Hello (notice the space) and click the + button

Once the utterance has been created, your screen should look like this

Build and Save the Model, you'll need to do this everytime you add or remove any utterances

Click on Configuration. This will move you on to the next step.

After Clicking on configuration, your screen should look like this.

Sign into the Amazon AWS Console

https://aws.amazon.com/console/

Click on the Sign in to the Console button on the top right.

After signing in, your screen should look like this.

In the search bar, type in lamda, and click on the Lambda entry

Once you clicked on Lambda your screen should look as follows. Next, click on the button Create a function on the right side of the scree.

Type fact into the input box and press enter


This creates a filter that leaves the option that we are looking for. Click on the alexa-skill-kit-sdk-factskill card

Once you selectd the alexa-skill-kit-sdk-factskill, your screen should look as follows. Here is where we finish creating the Lambda function


Make sure that you are creating a lambda in N. Virginia. The Alexa Skills is not available in any other areas.


When creating a new function, your screen should look as follows:

Add a name for your function, call it greeter


Select Create custom role from the Role dropdown. This will open a new screen


In this new screen, you don't have to change anything, just click on the Allow button in the bottom right.


Make sure that the lambda_basic_execution option is selected.

Note: this migth look different for you, but the words lambda_basic_execution should be there.


Click the Create Function button in the bottom right


After Creating the Lambda function, you should see the following screen.


Scroll down to the window that contains the code for your function, select it all and delete it. After you are done, your screen should look as follows.


Copy the code bellow and paste it into the empty text box

/* eslint-disable  func-names */
/* eslint quote-props: ["error", "consistent"]*/


'use strict';

const Alexa = require('alexa-sdk');

const APP_ID = undefined;  // TODO replace with your app ID (OPTIONAL).

const languageStrings = {
    'en': {
        translation: {
            SKILL_NAME: 'Greeter',
            HELP_MESSAGE: 'You can say exit to quit skill',
            HELP_REPROMPT: 'What can I help you with?',
            STOP_MESSAGE: 'Goodbye!',
        },
    },
};

const handlers = {
    'LaunchRequest': function () {
        this.emit('SayHello');
    },
    'SayHello': function () {
        this.emit(':tell', 'Hello');
    },
    'AMAZON.HelpIntent': function () {
        const speechOutput = this.t('HELP_MESSAGE');
        const reprompt = this.t('HELP_MESSAGE');
        this.emit(':ask', speechOutput, reprompt);
    },
    'AMAZON.CancelIntent': function () {
        this.emit(':tell', this.t('STOP_MESSAGE'));
    },
    'AMAZON.StopIntent': function () {
        this.emit(':tell', this.t('STOP_MESSAGE'));
    },
};

exports.handler = function (event, context) {
    const alexa = Alexa.handler(event, context);
    alexa.APP_ID = APP_ID;
    // To enable string internationalization (i18n) features, set a resources object.
    alexa.resources = languageStrings;
    alexa.registerHandlers(handlers);
    alexa.execute();
};

After you pasted the code, your screen should look like this.

Note: The blue arrow points to the code that we are going to be working on. SayHello here matches the name of the intent created earlier


Save your changes


Click on Triggers


Click on + Add Triggers


Click on the Box outline


Select the Alexa Skills Kit. This option will not appear if you do not have your region set up as N. Virginia, and click Submit.


Back in the Amazon Developer Console

Select the ARN radio button, and paste the string you copied, and click save

Click Next

This will take you to a screen that you can use to test your new skill

Type Say Hello, this is the utterance that was created for the SayHello intent. You'll know your successful when the `Service Response comes back with some information

You can test your new skill using echo sim

Be sure to give your browser access to your microphone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment