O'Reilly logo

Hands-On Chatbot Development with Alexa Skills and Amazon Lex by Sam Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the Lambda

The Lambda that handles this intent is going to need to do a few things:

  • It needs to check whether it has an item number or all of the correct slots are filled.
  • It then needs to get our S3 stock data and check the stock levels of the item requested.
  • If there is stock, it will ask the user whether they want to add it to their cart. If there's no stock, it will tell the user and ask whether they want to find another product.

Start by creating a new folder in Lambdas called productFind and create an index.js file inside there. The index.js file can start with our default Node 8.10 handler and we will pass the event to a handleProductFind function:

exports.handler = async (event) => {    return handleProductFind(event);}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required