Building an Alexa Skill with Litexa

A recent project allowed us to try out Litexa, a new language and framework released by the Alexa Games team

Katherine Wren

Junior Developer

Litexa is a new language and framework released by the Alexa Games team, specifically written for building Alexa Skills.

It reminds me of Rails in the best ways – I can see it being the entry level step that allows more companies to easily code their own skills, but it has the flexibility to allow more experienced developers to customise easily. We decided recently to produce our own Christmas game in time for the holidays, and I’ve been wanting to try using Litexa since it was released, so this was the perfect opportunity to test it out!

Litexa compiles into JavaScript, and it’s really easy to write the two interchangeably in the same file, which was great as I usually write in Node.js so the learning curve wasn’t too steep. My first impression was that everything took SO FEW LINES. The Alexa team describe the syntax as ‘succinct’ and this is definitely the case. I think this is the first app I’ve ever written that’s been completed in under 500 lines of code, and I wasn’t even trying to be particularly brief. Litexa is also white space dependent, and initially it’s a little weird to have to be so careful with how I’m using my spaces and alignment. It also makes me realise that I’ve become a sloppy typist and am way too dependent on VS code extensions to keep my formatting nice. The Alexa team have released a VS code extension for syntax highlighting, but sadly not yet autoformatting.

 

I absolutely love the design of having the different invocation phrases (the things a user might be saying to have a particular intent) alongside the logic and output, rather than in different files. When I’m debugging it can sometimes be hard to work out whether issues are coming from the way I’ve structured invocation phrases or from my logic, and I usually have to keep switching between files. This makes it considerably easier for me to spot problems simply by eyeballing the code.

The Book’, as the code documents are entitled, is well written and links really nicely to the relevant parts of the Alexa documentation when necessary. I’ve sometimes found the Amazon documentation a little dense to navigate but that’s not an issue here. As it’s such a new language, there isn’t really any information other than this out there, but luckily it seemed pretty intuitive to work out.

After building the very basics of a skill, I was keen to test out what I found to be one of the trickiest parts when starting to build skills – the deployment! This was the moment of truth: if I couldn’t work out how to deploy the skill relatively quickly, I’d have to switch back to using Jovo as there wasn’t really time to waste and we needed to get this built pretty quickly. Luckily, ‘The Toolchain’, as it’s called, was one of the most miraculous parts of the Litexa system. When you run the ‘litexa deploy’ command, Litexa will

  • Create a new bucket, and deploy your images, mp3 files, and anything else you’d need to store in a bucket directly from the assets folder (!!!)
  • Build the language model
  • Deploy the skill to your Alexa developer account
  • Deploy the code to AWS
  • Create a dynamo database for your skill

The only thing I had to do was to add a new custom IAM policy and add it to my user account (the steps of which are explained very coherently in the Litexa documentation here). After this, the single command took care of all the little annoying bits that I usually spend a good hour or so on when deploying a skill for the first time, which made me very very happy. You can also easily deploy to different skill and AWS accounts at different stages by creating different deployment configurations in the Litexa configuration file, which will make it nice and simple for me to move skills over to client accounts. I had some weirdness initially when I tried to create a bucket for myself and put the name in the Litexa config file (related to the bucket being in a different locale to the one Litexa automatically deploys the code to in AWS) so I would suggest just providing the name you want and letting Litexa handle creation for you.

Are there any downsides? If you’re wanting to build a Google Action at the same time, then this isn’t any use for you and Jovo will still be the way to go. I also found that I missed the debugger that comes with Jovo for quick iterative testing, and VS code doesn’t highlight errors for me, so I don’t tend to notice minor errors until compilation. (Which has again taught me that I need to be writing more tests – on the subject of which, the testing framework is also excellent). The error messages at compilation aren’t hugely detailed, but that wasn’t a huge problem after I got used to what was and wasn’t allowed. Jovo version 2 also has a load of great plugins, such as the CMS integrations, that have been great for easily adding extra functionality to my apps quickly and I’ve missed that a bit, but it’s perfectly possible to create your own extensions and ‘The Book’ provides clear guidance on how to do so. Hopefully as the language becomes more widely used more of these will be developed.

It’s easy to pick up - I went from opening ‘The Book’ to having a skill fully deployed over the course of an afternoon.

The reviews of Litexa so far have been very positive and it’s clear to see why. Litexa seems to have been designed in a similar way to Ruby – that is, to make a voice developer happy whilst writing it. Some things just make more sense in JavaScript, but pretty much everything that’s directly Alexa related is nicer in Litexa. Every time I come across a new thing I want to add in I’m struck by how NICE it is to implement. It’s easy to pick up – I went from opening ‘The Book’ to having a skill fully deployed over the course of an afternoon, and I would highly recommend it to anyone looking to build an Alexa skill. I’m definitely going to be using it when we’re only building for Alexa. Now here’s hoping that Google come out with something similar!

Katherine Wren

Junior Developer

Rabbit & Pork

+44 (0)20 8102 8500

[email protected]

2nd Floor,
1-2 Berners Street,
London,
W1T 3LA

Rabbit & Pork are part of TIPi Group