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

To start this Lambda, create another folder in the Lambda directory called addToCart with an index.js file inside. In your folder, we need to run npm install --save aws-sdk to make sure that we have access to AWS. We start, as normal, with our default node 8.10 function, and there are two things we need to do at the start of this function: check whether there is a Denied confirmation status, and call a handleAddToCart function.

If the confirmation status is denied, we can ask the user whether they want to find another product, using Lex.confirmIntent. We have already programmed our productFind Lambda to deal with confirmIntent triggers so that should already be working:

exports.handler = async (event) => { if (event.currentIntent ...

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