How to install ASK CLI to manage Alexa Skills, AWS Setup

VijayAlexaLeave a Comment

Install Ask CLI for Alexa

If you are a new Alexa Skills developer seeking for information, the Alexa developer website is pretty much the first place all of you go to create Alexa skills. The Alexa Skills interface in the developer portal has undergone a lot of change since its inception and is today amongst the most user friendly developer sites in terms of its design and UX.

However, most of the seasoned developers prefer to use the command line interface to manage their apps and projects. ‘ASK CLI’ is the command line interface(CLI) provided by Amazon to developers to manage their Alexa Skills and related AWS Lambda functions. The ASK CLI allows access to the Alexa Skill Management API. Using the ASK CLI developers can programmatically manage their Alexa Skills.

Pre-Requisites for Setting up ASK CLI for Alexa Skill Development :

Installing the ASK CLI requires you to have account and proper access at the following websites :

If you do not have any of the above, the hyperlinks in each of the pre-requisites will direct you to the right place to go about getting a new account created and get access.

How to Configure AWS credentials to access AWS services for ASK CLI ?

Once you have your accounts in place, you will need to configure your AWS credentials to access your AWS services as described at Setup Credentials – developer.amazon.com . If you have already accessed AWS services via the command line for other things than Alexa, you can skip this step. But if you are starting from scratch then this is an important step that needs to be in place. For the benefit of new users, here are the steps.

Steps to  to configure the AWS credentials to access AWS Services:

  • Go to Identity and Access Management (IAM) in your AWS account.
  • Create a new user and select both Programmatic access and AWS Management Console access for AWS access type.
  • Go to Permissions and attach a new policy. Copy paste the contents below in the policy section.
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "iam:CreateRole",
        "iam:GetRole",
        "iam:AttachRolePolicy",
        "iam:PassRole"
      ],
      "Resource": "arn:aws:iam::*:role/ask-*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "lambda:AddPermission",
        "lambda:CreateFunction",
        "lambda:GetFunction",
        "lambda:UpdateFunctionCode",
        "lambda:ListFunctions"
      ],
      "Resource": "arn:aws:lambda:*:*:function:ask-*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "logs:FilterLogEvents",
        "logs:getLogEvents",
        "logs:describeLogStreams"
      ],
      "Resource": "arn:aws:logs:*:*:log-group:/aws/lambda/ask-*"
    }
  ]
}
  • Go through the next steps by clicking ‘Next’.
  • Upon the user being created, you will have the aws_access_key_id and aws_secret_access_key of the user.
  • Copy Paste the same in ~/.aws/credentials if you have a Mac and %USERPROFILE%\.aws\credentials if you have a Windows machine.

Please ensure that you store these credentials under a different profile name if you already have aws access configured. In such cases the credentials file will already have a [default] profile already in there like the one below.

[default]

aws_access_key_id = XXXXXXXXXXXXXXXXXXXXXX

aws_secret_access_key = XXXXXXXXXXXXXXXXXX

The access key id and secret access key are marked ‘XXXXXX’ to ensure privacy but in reality, they will have different values. You can store the new user details in a different profile name of your choice like [alexa-cli] for example.

[default] aws_access_key_id = XXXXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXX
[alexa-cli]

aws_access_key_id = enter the access key id from AWS console for the user created
aws_secret_access_key = enter the secret access key from AWS console for the user created

For users who are doing this from scratch, they will do the following in the credentials file:

[default] aws_access_key_id = enter the access key id from AWS console for the user created
aws_secret_access_key = enter the secret access key from AWS console for the user created

Install and use ASK CLI for building Alexa Skills 
The users can now install the CLI using

npm install -g ask-cli (or) sudo npm install -g ask-cli (if using Mac)

Now the ASK CLI is installed. To initialize their Alexa skills project, users can now use

ask init -p ‘profile name’

The profile name can be default or any other profile name like alexa-cli created by the user.

ask init

This is also another option that can be used. In this case the user will have to choose the profile that they want to use if a profile other than default is also available in the credentials file. Whichever the profile name, the user will have to login to the AWS Console using the console credentials for the user mentioned in the profile name.Upon successful login to the Console, users can now create and deploy Alexa skills using the ASK CLI.

Did I miss anything ? Any questions ? Please add your thoughts.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.