Inspiration - The Missing SDK

There currently was not an SDK for writing a Chatbot using Java for Amazon Lex and deploying to Amazon Lambda. Without this SDK, you would need to process the request and response JSON manually from Lex.

What it does

Provides a simple framework for writing a Chatbot using Java and deploying to Lambda. The framework takes care of serialising/deserialising the Lex requests into Java POJOs. It also provides helper methods for easily creating Lex responses.

There is also a sample bot sample ChatBot which demonstrates how to use this SDK.

How I built it

I modeled this SDK off the Alexa Skills Kit SDK. It's written in Java 8 using IntelliJ and Maven.

Challenges I ran into

The documentation for the requirements of the request/response JSON was a several places. It took a bit of digging to gather the details in order to implement the verifiers (which check the Lex response for size and collection limits).

There was a bit of trial and error involved in making sure the response JSON was formatted correctly so replies would make it back to Facebook Messenger. I ran into some cases where an empty element or empty collection would cause the response to not display in Messenger.

Accomplishments that I'm proud of

The Maven pom file of the sample ChatBot is configured with an Execute plugin to update the code of your Lambda function. This provides an efficient workflow for making updates in your IDE and getting them deployed into Lambda.

I also used this SDK to write my Petrol Bot entry into the AWS Chatbot Challenge.

What I learned

I learned the requirements for the Lex request and response JSON as well as the specifications of the Facebook Messenger and Slack equivalents.

What's next for Lex Lambda SDK

As Amazon Web Services adds more features to Lex, I'll keep this SDK updated.

Built With

  • amazon-lamba
  • amazon-lex
  • java
Share this project:

Updates