Amazon's AWS Lambda and Alexa Skill with Microsoft Machine Learning Server Operationalization

In my previous blog, I talked about creating Enterprise-friendly Java clients for Machine Learning Server web-services. In this blog, we will see how easily we can extend this Java client to (1) work with  Amazon's AWS Lambda function and (2) call this lambda function from a Amazon's Alexa skill.


For this demo, I will assume that you have published a 'rainService' prediction service that takes a zipcode and returns a percentage number for rain prediction for that day. Here is how the swagger for our service looks. You can also find the code here: AWS Lambda-Alexa-enabled Java client for rainService.


1. Java Client with AWS Lambda function:

  • Install AWS Lambda SDK/ toolkit for your IDE. I used this for eclipse:

  • Create an AWS Lambda Java project

  • Make sure you select Input trigger as type "Custom"

  • Download swagger client for our service's swagger from Extract the zip and copy the "io" folder under your Lambda project we just created.

  • Edit the handleRequest() method to login to Machine Learning Server, and get response from web server


  • Let's go ahead and build this project by running "maven install" in your IDE/command line. This will generate the JAR for your project.

  • You can now login to, create your lambda function and upload the JAR.

  • Congratulations! You have successfully used the Machine Learning Server 'web-services' from an AWS lambda function.


2. Use Machine Learning Server web service with Amazon's Alexa:


We can extend the Java client generated from step 1 to handle inputs from Amazon Alexa skill.

  • We will follow steps and create 2 additional classes and These will help us process the inputs from Alexa skill.
  • Okay, our backend is now ready to handle requests from Alexa skill. Let's setup the Alexa skill now on
  • Enter Skill name and invocation details.
  • Save changes and copy the Application ID.  You will need to copy this to your class.
  • Let's recompile the Java client and upload the updated JAR file to our lambda function from step 1.
  • Continue making changes to the Alexa skills:
  • Specify the lambda function's ARN identifier in the Alexa skill as shown below.
  • We now test the skill on next screen:
  • At this stage, if your Alexa device is registered under same Amazon account, you can also test using your actual device.
  • Congratulations! You have successfully used Microsoft's Machine Learning Server web-service from your Amazon Alexa skill :) if you wish, you can go ahead and publish the skill for all Amazon Alexa users.

I am excited to see all the things that you can achieve using Microsoft Machine Learning Server to make your Alexa skills smarter! Happy coding :)