Node.js Alexa skill: alexa-sdk or alexa-app?
So, you are about to develop your first Alexa skill. Where do you start?
As you research Node.js options beyond the obvious getting stated guides from Amazon, you will be faced with two common options: alexa-sdk and alexa-app. Which one should you use?
Here are my findings after comparing these two approaches.
The Amazon Approach (alexa-sdk 1.0.7)
alexa-sdk is the Node.js package developed by Amazon and it features:
- Supports deployment of your Alexa skill on AWS Lambda.
- Includes support for internationalization (using i18next) and states (as in finite state machines — FSMs).
- Supports new session and default handlers.
- Supports userId based attribute logging (see session parameters below).
- Session parameters are handled through Amazon DynamoDB (out of the box).
- Non-Amazon deployments: if you need to deploy elsewhere (like Heroku), you are on your own to figure it out.
- FSM: the current FSM implementation lacks the support for _onEntry / _onExit events (see FSM specific packages like machina), making it necessary to repeat intent handling related code everywhere that intent is to be handled.
The Independent Approach (alexa-app 3.1.0)
- Support for deployment of your Alexa skill on AWS Lambda and elsewhere (e.g. Heroku) by using express.
- Auto-generation of intent schema and sample utterances.
- Support for pre/post execution before every HTTP POST request (useful for error handling).
- Session parameters are handled within HTTP messages.
- Lacking support for FSM, internationalization and default intent handlers.
- FSM: while it is possible to pair it up with FSM packages like machina, the lack of native FSM support forced me to write a lot of useless code. Adding native FSM capabilities is definitely an area of improvement.
- Default intent handlers: this is a direct consequence of the lack of FSM support. Adding support for FSM should solve this feature gap as well.
- i18n: through the use of custom helper functions, I was able to overcome this limitation somewhat easily by using i18next.
Here is a summary on the two approaches:
- alexa-sdk: as expected, it is AWS specific, so not the right choice unless you plan to use AWS Lambda to deploy your Alexa skill. The current simplistic FSM approach leads to code repetition.
- alexa-app: the lack of FSM, i18n and default handlers will make harder to develop more complex skills. Also, it is anyone’s guess how long contributors will stick around to up keep this package.
Bottom line, Alexa is still in its infancy, so be ready for change on Alexa Skill Kit, alexa-sdk and alexa-app as each one of these technologies mature.
Based on my own Alexa skill development experience, I am collection a set of Node.js patterns associated with Alexa skills and I plan to share them on github soon (time permitting).
What is your take? Feel free to share your point of view. And please follow me, if you would like to be automatically notified when I publish new articles.