Recently I got excited about developing skills for Amazon Echo. So, I started working on it and developed my first Alexa skill Today Learnings which you can find it here. This skill is available in India, U.K, U.S, Australia, and Canada regions. You can view the source code of this skill in my GitHub repository. This skill provides interesting and specific facts from TodayILearned subreddit. I would like to share my learnings on developing my Alexa skill.

Building the skill

Since I have experience of developing apps in Ruby with Sinatra, I started developing the Alexa skill using Ruby Programming. Amazon Alexa team provides the tutorial videos about developing skills using Ruby. It was pretty good experience to get started to developing the skill. In that tutorials, they used ngrok to host the skill for the testing purpose.

Every interaction with the user, Alexa maps the utterance with the corresponding Intents. For example, If the user asks, “Tell me a fact”, then Alexa maps this to the “FactRequestIntent”. For this mapping, The developer must build a valid Interaction model for their Alexa skill. The Developer can use built-in intents as well as they can create the custom intents.

Ralyxa Ruby gem is an easy way to handle the intent mapping functions in Ruby. It automates the process of mapping the intents with their corresponding methods in the project.

Redditkit is the gem which I used to fetch the data from the Reddit website. I have used this gem to get the facts from TodayILearned subreddit.

Building the whole project takes just one and half day. The actual problems started while deploying the project.

Deploying the project

I have hosted the project by using ngrok while development phase. For production I decided to deploy this skill in AWS Lambda. Because, Amazon provides lot of free credits for using AWS Lambda to deploy the Alexa skills. Then only, I came to know that AWS Lambda doesn’t support the deployment of Ruby project currently.

But they have given the instructions to wrap Ruby, PHP, and Go projects with Node.js language. You can view the article here.

While wrapping the ruby project with Node.js, I had faced lots of hassles.

First, they recommends to create an EC2 instance which runs in Linux OS. Because Lambda runs in Linux OS. For the file compatibility, We need to do all the wrapping up stuff in EC2 instance with Linux OS. So, I created an EC2 instance and uploaded my project to EC2.

After uploading the files to EC2, we need to download Travelling Ruby in the EC2 instance. Travelling Ruby makes an portable version for our Ruby project. The portable version of the project can be executed in any other machines without the need of Ruby installation.

While creating AWS Lambda, I couldn’t find the Trigger named “Alexa skills kit”. After Googling it, I realised that the trigger is not supported in the “Asia Pacific (Mumbai)” region. So, I changed the region to “US East (N. Virginia)”. After that, I could find the trigger used in my project.

The next step is to create a Node.js wrapper file which invokes your Ruby application. The file takes the inputs of the Lambda invocations and pass it to your Ruby application. The Node.js code was given in their instruction. But there is a minor mistake that causes runtime error while testing my Alexa skill. In the Node.js file there is a line,

const child = exec(‘./lambdaRuby.rb ‘ + ‘’’ + JSON.stringify(event) + ‘’’, (result) =>{

But this line caused me an error. Since I didn’t have the basic knowledge of Node.js language, It takes me lot of time to realise the error. The correct code should be,

const child = exec(‘./lambdaRuby.rb ‘ + “ ‘ “+ JSON.stringify(event) + “ ‘ “, (result) => {

Note that 3 single quotes (‘’’) are replaced with one single quote between double quotes ( “ ‘ “ ).

Next step is to create the zip file for our project. So, I have created a zip file and downloaded that zip file from EC2 instance. After downloading the zip file, I had uploaded it to Lambda function.

After all these steps, I tested my Lambda function with custom input. But the test causes an error that “Sinatra” and “ralyxa” gems couldn’t be loaded. It turns out that Travelling Ruby requires exactly Ruby 2.2.0 version and all the required gems should be bundled with that. But “ralyxa” is supported by Ruby 2.3.1 and above. That’s when I gave up on AWS Lambda and Finally hosted it with Heroku platform(Which supports Ruby projects deployment). If you have successfully deployed your Ruby-based Alexa skill on AWS Lambda, Please comment what I had missed in the process.

Do you have an Amazon Echo device with you? If so, please give it a try on my “Today Learnings” skill and share your feedback on it.