Installing the ASK CLI

The ASK CLI is a Swiss Army knife for Alexa developers, providing dozens of handy utilities. Among other things, we’re going to use the ASK CLI throughout this book to create new skill projects, deploy skills, and test skills.

Before you install the ASK CLI, you’ll need to install a few prerequisite command line tools:

  • Node.js and npm[4]—We’ll be developing Alexa skills in JavaScript using Node.js and using npm to install library dependencies and the ASK CLI itself.

  • Git CLI[5]—When initializing a new Alexa skill project, the ASK CLI acts as a Git client to clone a template project.

There’s a good chance that you already have all of these prerequisites installed. If not, then follow the instructions at the respective download pages before attempting to install the ASK CLI.

To install the ASK CLI, use the npm install command:

 $ ​​npm​​ ​​install​​ ​​--global​​ ​​ask-cli

Depending on your operating system and user permissions, you may need to perform this as sudo:

 $ ​​sudo​​ ​​npm​​ ​​install​​ ​​--global​​ ​​ask-cli

Be patient. It may take several moments for npm to install everything needed for the ASK CLI and install it. When it finishes, you can verify that it installed by using it to tell you which version is installed:

 $ ​​ask​​ ​​--version
 2.26.0

Ultimately, the skills you create will be deployed to and will run in AWS Lambda. The ASK CLI can help you deploy them, but to do so, it will need to be authorized to access you AWS developer account. The ask configure command initializes the ASK CLI to obtain that authorization. Start by typing ask configure at the command line:

 $ ​​ask​​ ​​configure

Your web browser should open and prompt you to sign in with your Amazon developer credentials. From the sign-in page, provide your Amazon developer credentials and sign in. If you’ve not yet created an Amazon developer account, you’ll need to do so by clicking the “Create your Amazon Developer account” button on the sign-in screen. If you already have an Amazon account (for shopping) then you won’t need to create a new account. Instead, you can add developer capabilities your existing Amazon account. This will enable you to interact with the skills you develop using any Alexa devices associated with that account.

After signing into your Amazon developer account, you’ll be presented with a page that requests several permissions for the ASK CLI to have access to your account. The page will look a little something like the screenshot.

images/hello/alexapermissions.png

 

While the list of permissions being requested may seem daunting, they are all directly relevant to developing and deploying Alexa skills and it’s important to accept them before moving on.

Once you’ve granted the ASK CLI authority to access your Amazon developer account, you will be shown a very basic text message in the browser instructing you to close the browser and return to the command line to continue setup.

If your web browser doesn’t open to the sign-in page, it may be because you’re running ask init in an environment without a web browser, such as from a Docker container. In that case, you can initialize the ASK CLI specifying --no-browser to the ask init command:

 $ ​​ask​​ ​​configure​​ ​​--no-browser

In “no-browser” mode, the ASK CLI will provide you with a URL to copy and paste into a browser’s address bar on some other machine. From there you will go through the same sign-in and authorization steps, but in the end you’ll be given an authorization code to provide to the ASK CLI when prompted with “Please enter the Authorization Code”.

Next, you’ll be asked if you want to link your AWS account in order to host skills. There are several options for hosting skills, including hosting them in AWS Lambda. But for now, we’re going to use a different hosting option called “Alexa-hosted skills”, which we’ll discuss more in the next section. Respond with “No” to skip linking your AWS account at this time.

 

 

After answering all of the configuration questions, the ASK CLI will be ready for you to start developing skills. Let’s give it a spin by using it to create a new project that will be the foundation for a travel planning skill.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset