As a developer, I spend a large amount of my time writing code everyday. The rest, of course is spent debugging that code and “Googling” the internet for answers. But, I digress. All to say, that I am always looking for ways to speed up the development workflows when it comes to “getting started” with something, and then making it easy to “run”, and “deploy” the code.
One area I spend a significant amount of time every week is creating new Alexa Skills from scratch from a learning and education point of view. This is where I’ve found the ASK CLI to be super helpful in speeding up the workflow to create and update Alexa Skills, using the Alexa Skill Kit CLI tool.
The Alexa Skills Kit Command Line Interface(ASK CLI) provides a quick way to perform a lot of Alexa skills tasks from the command line interface, like creating new skills, and deploying the code to Alexa Hosted or AWS. You can even simulate your skill from the command line.
One feature that I like the most about ASK CLI is that it allows you to create a new skill by using your own custom skill templates. So, if you’re like me, you can create a starter template for all your Alexa Skill projects. For example, if there are certain helper functions you use in every skill, it would make sense to include those in the template, so they’re available in the new skill right off the bat.
To create a new skill using a custom template, you provide the Git URL of the template with the flag
The command to create a new skill using a custom template varies a bit based on the version of the ASK CLI. To check the version of ASK CLI, simply type
ask -v or
ask -V in the terminal.
If you’re using ASK CLI v2
If you’re using ASK CLI v2, you can create a new skill using a custom template using the command below -
$ ask new --template-url https://example.com/example/example-skill.git --template-branch master
Here’s a CLI v2 compatible I use to jump start my Python based Alexa Skills -
https://github.com/ajot/python-alexa-skill-starter-template-cli-v2.git. If you like, you can use this to create a new skill by using the command below.
$ ask new --template-url https://github.com/ajot/python-alexa-skill-starter-template-cli-v2.git --template-branch master
You may get a warning, like the one below. Type "y" to continue.
"[Warn]: CLI is about to download the skill template from unofficial template. Please make sure you understand the source code to best protect yourself from malicious usage."
This will create the skill locally on your machine. You’re now ready to deploy the skill. See “Deploy” section below.
If you’re using ASK CLI v1
If you’re using ASK CLI v1, you can create a new skill using a custom template using the command below -
$ ask new --template-url https://example.com/example/example-skill.git
Here’s a CLI v1 compatible template I use to jump start my Python based Alexa Skills -
https://github.com/ajot/python-skill-basic-template.git. If you like, you can use this to create a new skill by using the command below, and optionally, providing a skill name.
$ ask new --template-url https://github.com/ajot/python-skill-basic-template.git -n <optional-name-for-your-skill> -n <optional-skill-name>
You may get a warning, like the one below. Type "yes"
“Downloading skill template from unofficial resource. Please make sure you understand what each script is doing to best protect yourself from malicious usage".
This will create the skill locally on your machine.
At this point, we need to locally install any other modules your skill may need. In the case of the Python template I mentioned above, it needs
ask-sdk-core package to be installed.
As is generally a good practice, we first need to create/activate a virtual environment. There are several options available for managing virtual environments for Python. I personally use virtualenv, but you can tailor the steps below to match your virtual environment of choice (like Conda).
$ virtualenv skill_env -p python3
Our virtual environment is created. Now before we start using it, we need to activate:
Activating a virtual environment
$ source skill_env/bin/activate
You will know it worked if you see (skill_env) in front of the command line, like this:
[Image: Screen Shot 2020-05-07 at 8.01.34 PM.png]Install any modules your skill may need
This specific template, for example needs the
ask-sdk-core module. So let’s install that inside the virtual environment we created using the Python's pip command -
$ pip install ask-sdk-core
We are now ready to deploy our skill to the developer console, and AWS lambda -
$ ask deploy
1. Verify the skill deployment on the Alexa Developer Console
2. Verify the code deployment on AWS Lambda Console
3. Test the skill in the Alexa Developer Console
You can now test your skill using the "Test" tab inside the Alexa Developer Console at https://developer.amazon.com/alexa/console/ask/test