The official example template of creating a blog with Bootstrap.
If you’re into building skills, you’re probably familiar with Alexa Skills Kit’s Command Line Interface, which lets you create and manage your skill using the CLI, like updating the interaction model, and the backend code. You can of course manage these directly through the Alexa Developer Console, and AWS respectively, but CLI is a much faster workflow.
There are two ways to create a new Alexa skill using the ASK-CLI. You can use AWS Lambda as your backend, or if you are new and would like to keep things simple initially, you can use Alexa Hosted.
With an Alexa-hosted skill, your code is available inside a code editor in the Alexa developer console itself, so you can edit and deploy changes to your code quickly, without needing to set up an AWS account.
Let’s look at how you can use the ASK-CLI to create a new skill using each of these two backend options.
You can find more information about the prerequisites on the Amazon Developer Documentation here.
$ ask new
This will provide the following prompts -
Node.js V8
or Python3
hello world
as the template to get started with
ice-cream-soda
(or a name you prefer)This will create the skill locally on your machine.
Type the following into the command line -
$ cd ice-cream-soda
$ ask deploy
This may take a few minutes, and if everything goes well, you will get a confirmation that Your skill is now deployed and enabled in the development stage. Try simulate your Alexa skill skill using "ask dialog" command.
You can verify by logging into the Alexa developer console at developer.amazon.com/alexa/console/ask. Your backend code has been deployed as an AWS Lambda function using the AWS IAM user you set up in #2 of the prerequisites, which you can verify by logging into your AWS Console at console.aws.amazon.com/lambda.
ice-cream-soda
. If curl is your thing, you can also type this on the command line - $ curl -u 'YOUR_GITHUB_USER_NAME' https://api.github.com/user/repos -d '{"name":"YOUR_NEW_REPO_NAME"}'
When you use ask new
to create a new skill using one of the templates (say hello world), the git remote for the skill directory that's created for you points to https://github.com/alexa/skill-sample-nodejs-hello-world.git
. If you’d like to push your skill code on GitHub, you need to remove the .git
directory, which removes the remote. Let’s do that now.
.git
directory (hidden by default) to reset the remote origin, which is by default set to https://github.com/alexa/skill-sample-nodejs-hello-world.git(https://github.com/alexa/skill-sample-nodejs-hello-world.git). $ rm -r .git
You may get a warning asking if you’d like to override removal of .pack
and .idx
files. Typeyes
to confirm.
You can now deploy your skill code to a GitHub repo with no problems, without breaking the ask deploy
process to deploy the skill to AWS Lambda/Developer Console.
$ git init
$ git remote add origin git@github.com:YOUR_GITHUB_USERNAME/YOUR_GITHUB_REPO_NAME.git
// example:
// git remote add origin git@github.com:ajot/ice-cream-soda.git
$ git add .
$ git commit -m "first commit"
$ git push -u origin master
You can also use the Alexa Skills Kit CLI to create a skill using Alexa Hosted as the backend, instead of AWS Lambda using the create-hosted-skill(https://developer.amazon.com/docs/smapi/ask-cli-command-reference.html#create-hosted-skill-command) command. Support is available for Node.js only for Alexa Hosted through the CLI.
$ ask create-hosted-skill
kiwi-cream-soda
Node.js V8
or Python3
yes
Your skill has now been automatically deployed on the Alexa Developer Console using Alexa Hosted. For future deployments, just use ask deploy
from within the skill directory.
When you use ask create-hosted-skill
to create a new skill, the git remote is set to an AWS Code Commit service https://git-codecommit.us-east-1.amazonaws.com
. We need to add another remote, so we can push to both GitHub without breaking the AWS Code Commit service. We will do this in step by adding a new remote (Step 2 below), and then updating the Push URLs for the remotes (Step 3 below)
kiwi-cream-soda
. If curl is your thing, you can also type on the command line - $ curl -u 'YOUR_GITHUB_USER_NAME' https://api.github.com/user/repos -d '{"name":"YOUR_NEW_REPO_NAME"}'
$ cd kiwi-cream-soda
$ nano .git/config
Make a note of the Push URL. We will need this in the next step. This will be something like -https://git-codecommit.us-east-1.amazonaws.com/.....
CTRL + X to exit the nano editor.
$ git remote add github git@github.com:YOUR_GITHUB_USERNAME/YOUR_GITHUB_REPO_NAME.git
// example:
// git remote add github git@github.com:ajot/kiwi-cream-soda.git
Set remote URL for GitHub
$ git remote set-url --add --push origin git@github.com:YOUR_GITHUB_USERNAME/YOUR_GITHUB_REPO_NAME
//example:
// git remote set-url --add --push origin git@github.com:ajot/kiwi-cream-soda.git
Set remote URL for AWS Commit Service to enable the ask deploy
workflow.
$ git remote set-url --add --push origin YOUR_PUSH_URL_FROM_GIT_CONFIG_FILE_FROM_STEP_2
//example:
// git remote set-url --add --push origin https://git-codecommit.us-east-1.amazonaws.com/v1/repos/xxxxx-xxxxx-xxxxx
[remote "origin"]
url = https://git-codecommit.us-east-1.amazonaws.com/v1/repos/xxxxx-xxxxx-xxxxx
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = git@github.com:<YOUR_USER_NAME>/kiwi-cream-soda.git
pushurl = https://git-codecommit.us-east-1.amazonaws.com/v1/repos/xxxxx-xxxxx-xxxxx
CTRL + X to exit the nano editor.
$ git add .
$ git commit -m "first commit"
$ ask deploy
This will deploy the skill to Alexa Hosted, and also push to GitHub.
$ npm install -g ask-cli
$ ask -v