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);}

Get Hands-On Chatbot Development with Alexa Skills and Amazon Lex now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.