Alexa Custom Skill Life Cycle
After working on alexa custom skills a couple of times over the past three years, I thought of writing this comprehensive compilation of all the steps involved in building alexa custom skills right from signing up for various required accounts to certification. This will act as a reference for newbies as well as anyone who needs to revisit developing a custom skill at any point in time. Most of the things have now matured over these steps barring some UI changes or a few minute details that might keep changing from time to time.
Signing up for amazon developer’s account
The first step in the process is to sign up for Amazon developer’s account.
Developing Alexa Custom Skill using Alexa Skills Kit
Once you have a developer’s account, you can sign in and go to Alexa -> Alexa Skills Kit
You can now start developing your custom skill.
Steps for creating a skill
You can follow the steps of creating a new skill like giving it a name, choosing a model.
Follow along the steps of creating invocation name, intents, sample utterances, slots, slot types etc. Make use of the right slot types depending on your input e.g. AMAZON.NUMBER for numeric type etc.
You can refer to https://github.com/sameermahajan/Alexa-Custom-Skills/blob/master/lambda/twitter_bot/InteractionModel.json for a sample.
Writing backend business logic in lambda
Once you have completed the skill model, you need to write its backend business logic. It can be written in lambda and hosted on AWS or it can be written as any web service and hosted on platform of your choice including on prem server. Lambda is a preferred mechanism and we will take a look at it here.
Sign up for AWS account
Sign up for AWS account if you don’t already have one.
Once you sign up log into the AWS management console.
From the AWS Management Console, choose lambda.
Create new lambda function
Specify function name, run time, permissions etc.
You can edit code inline and take care of various settings.
You can refer https://github.com/sameermahajan/Alexa-Custom-Skills/blob/master/lambda/twitter_bot/lambda_function.py for example of an alexa skill lambda function.
Sanity testing your lambda function
Now you can perform some sanity testing of your lambda function.
Leverage various Amazon Alexa event templates like start session.
This testing is very useful in getting basic syntax and execution validation out of the way.
Once you are done editing the function, you need to publish its new version for further use.
Once published, you will see the version number as the suffix of the function.
Add ASK trigger to lambda function
Copy skill id from Alexa Skill
At this time, switch back to you alexa skill (from your developer login) and copy the skill id.
Paste skill id in lambda function trigger
Copy ARN number for the published lambda function
Paste ARN in skill’s endpoint
Now your alexa custom skill is complete and is linked to your lambda function. Build it
and it is ready for execution invocations!
Testing alexa skill
Once above steps are done, you can start testing the alexa skill.
Certification
Once you have completed testing of your skill, you can go for certification.
Take care of everything that certification reports. Here are some tips:
- Implement cancel, stop and help intents.
- Close the session (in cancel or stop intents) or keep it open (during ongoig dialogue) as appropriate. It is governed by the last argument of the response.
- Ensure appropriate content in cards.
- In case you are keeping the session open, provide reprompt text.
Now you are ready to publish your skill!
Publishing
Congratulations your skill is now live! You can search for a published skill.
You can refer to it using the published URL. You can enable it on your alexa device etc.
Monitoring published skill
Once the skill is live, you can monitor it under ‘Analytics’.
Exercising your skill without physical device
You can simulate a physical echo device using simulator.
Good luck with your alexa custom skill!