Book Image

Hands-On Chatbot Development with Alexa Skills and Amazon Lex

By : Sam Williams
Book Image

Hands-On Chatbot Development with Alexa Skills and Amazon Lex

By: Sam Williams

Overview of this book

Have you ever wondered how Alexa apps are made, how voice-enabled technologies work, or how chatbots function? And why tech giants such as Amazon and Google are investing in voice technologies? A better question is: why should I start developing on these platforms? Hands-On Chatbot Development with Alexa Skills and Amazon Lex covers all features of the Alexa Skills kit with real-world examples that help you develop skills to integrate Echo and chatbots into Facebook, Slack, and Twilio with the Amazon Lex platform. The book starts with teaching you how to set up your local environment and AWS CLI so that you can automate the process of uploading AWS Lambda from your local machine. You will then learn to develop Alexa Skills and Lex chatbots using Lambda functions to control functionality. Once you’ve come to grips with this, you will learn to create increasingly complex chatbots, integrate Amazon S3, and change the way Alexa talks to the user. In the concluding chapters, we shift our focus to Amazon Lex and messaging chatbots. We will explore Alexa, learn about DynamoDB databases, and add cards to user conversations. By the end of this book, you will have explored a full set of technologies that will enable you to create your own voice and messaging chatbots using Amazon.
Table of Contents (13 chapters)

What this book covers

Chapter 1, Understanding Chatbots, starts by explaining the concepts involved in building a conversational interface. We will learn how to start with an example user conversation and build flow diagrams to visualize the path that the user takes with the chatbot. The chapter will then discuss the types of chatbots and will introduce us to voice skills for Amazon Alexa and text-based chatbots for Amazon Lex.

Chapter 2, Getting Started with AWS and Amazon CLI, teaches us about AWS Lambdas and how these serverless functions can be built and tested in the browser. After building our first Lambda, we discuss three different ways to build and deploy them, comparing the merits and limits of each. To create the most powerful development environment possible, we use aws-cli to build a script that allows us to deploy Lambdas from our local development environment.

Chapter 3, Creating Your First Alexa Skill, introduces us to the Alexa Skills Kit and has us build our first Alexa Skill. We learn about how to build a Lambda to handle our users' requests and return the response that we want to send to the user. To create a more realistic situation, we create a skill that suggests a car for the user, based on a series of questions. We use the flow design process discussed in Chapter 1, Understanding Chatbots, to map out our users' interactions with our skill before creating the intents. The Lambdas that we use also increase in complexity with slot eliciting and with the inclusion of data that is stored in S3.

Chapter 4, Connecting Your Alexa Skills to External APIs, takes our Alexa skills to a new level of functionality by accessing external APIs. API access can provide massive amounts of functionality to your chatbots, but it needs to be done correctly. We'll learn about two of the best ways to handle errors and use them to build a weather skill.

Chapter 5, Building Your First Amazon Lex Chatbot, moves the focus onto Amazon Lex chatbots. The concepts and components are similar to those we used to build our Alexa skills, so we only need a quick refresher before building our first Lex chatbot. While Lex and Alexa are similar, we quickly see how there are some key differences in the way that the intents are handled. To create a more realistic project, we build an FAQ chatbot. This Lex chatbot takes advantage of the intent handling by triggering one of three Lambdas, based on the intent that was hit. These Lambdas access the responses from S3 and reply using a LexResponses class, which we will build.

Chapter 6, Connecting a Lex Bot to DynamoDB, introduces us to DynamoDB databases and how we can use them to store information about the users' interactions. We use this to build ourselves a shopping chatbot that stores a user's cart, even allowing them to save their cart for later. The complexity of the flows for this chatbot is a lot closer to what you would expect from a real project, and that is reflected in the amount of code.

Chapter 7, Publishing Your Chatbot to Facebook, Slack, Twilio, and HTTP, teaches us how we can publish our chatbots and integrate them into platforms, including Facebook and Slack. We use Amazon Lex's built-in integration tools to make this process as easy as possible. Next, we build an API endpoint, using API Gateway and Lambdas, so that we can develop integrations for other services. We use this API ourselves to create our own front-end interface, which we could integrate into other websites.

Chapter 8, Improving User Experience for Your Bots, discusses a few ways to make the experiences of your users more enjoyable. This covers creating and sending cards in Lex conversations and using search query slot types in Alexa skills. Cards provide the user with a much more visual interaction, while search query slots allow a user to search for a much wider range of values that we could allow with a custom or built-in slot type.

Chapter 9, Review and Continued Development, gives us a few pointers on the directions we can go to continue developing our chatbot skills. There are separate pieces of advice for people who prefer Alexa, and those who want to pursue more Lex skills, as well as a set of skills that will improve your abilities with both chatbot platforms. After this, we discuss the future of chatbots, where they are going, and what needs to happen before they become truly integrated into our daily lives.