Hands-On Chatbots and Conversational UI Development
eBook - ePub

Hands-On Chatbots and Conversational UI Development

Srini Janarthanam, Phil D Hall, Vamsi Venigalla

Share book
  1. 392 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On Chatbots and Conversational UI Development

Srini Janarthanam, Phil D Hall, Vamsi Venigalla

Book details
Book preview
Table of contents
Citations

About This Book

Build over 8 chatbots and conversational user interfaces with leading tools such as Chatfuel, Dialogflow, Microsoft Bot Framework, Twilio, Alexa Skills, and Google Actions and deploying them on channels like Facebook Messenger, Amazon Alexa and Google HomeAbout This Book• Understand the different use cases of Conversational UIs with this project-based guide• Build feature-rich Chatbots and deploy them on multiple platforms• Get real-world examples of voice-enabled UIs for personal and home assistanceWho This Book Is ForThis book is for developers who are interested in creating interactive conversational UIs/Chatbots. A basic understanding of JavaScript and web APIs is required.What You Will Learn• Design the flow of conversation between the user and the chatbot• Create Task model chatbots for implementing tasks such as ordering food• Get new toolkits and services in the chatbot ecosystem • Integrate third-party information APIs to build interesting chatbots • Find out how to deploy chatbots on messaging platforms• Build a chatbot using MS Bot Framework• See how to tweet, listen to tweets, and respond using a chatbot on Twitter• Publish chatbots on Google Assistant and Amazon AlexaIn DetailConversation as an interface is the best way for machines to interact with us using the universally accepted human tool that is language. Chatbots and voice user interfaces are two flavors of conversational UIs. Chatbots are real-time, data-driven answer engines that talk in natural language and are context-aware. Voice user interfaces are driven by voice and can understand and respond to users using speech. This book covers both types of conversational UIs by leveraging APIs from multiple platforms. We'll take a project-based approach to understand how these UIs are built and the best use cases for deploying them. We'll start by building a simple messaging bot from the Facebook Messenger API to understand the basics of bot building. Then we move on to creating a Task model that can perform complex tasks such as ordering and planning events with the newly-acquired-by-Google Dialogflow and Microsoft Bot framework. We then turn to voice-enabled UIs that are capable of interacting with users using speech with Amazon Alexa and Google Home. By the end of the book, you will have created your own line of chatbots and voice UIs for multiple leading platforms.Style and approachThis is a practical book, where each chapter focuses on a chatbot project. The chapters take a step-by-step approach to help you build intelligent chatbots that act as personal assistants.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Hands-On Chatbots and Conversational UI Development an online PDF/ePUB?
Yes, you can access Hands-On Chatbots and Conversational UI Development by Srini Janarthanam, Phil D Hall, Vamsi Venigalla in PDF and/or ePUB format, as well as other popular books in Computer Science & Artificial Intelligence (AI) & Semantics. We have over one million books available in our catalogue for you to explore.

Information

Restaurant Search

In previous chapters, we dealt with conversation management in one of the two ways—built from scratch (Chapter 3, Let's Talk Weather) or using GUI tools such as Dialogflow (Chapter 4, Building a Persona Bot) and Chatfuel (Chapter 1, Introduction). In Dialogflow and Chatfuel, the conversational flow was specified by the developer using visual elements (such as forms) on their custom-built web-based editor. However, it may not always be the best way to tell the system how to manage the conversation. On the other hand, we built a simple conversation manager in Java. Conversation management can get complicated in complex human-chatbot conversations. Luckily, we have got toolkits that allow us to build conversation management modules using code libraries specifically built for the purpose.
In this chapter, we are going to explore how a conversation management module can be built using an existing library—Bot Builder SDK. First, we will understand the MS Bot Framework that Bot Builder SDK is a part of. We will install the necessary software and libraries and learn to build chatbots using the SDK, test them on the emulator, and deploy them in the cloud. Next, we will learn about the rich presentation options, and the devices for which the conversational flow can be designed. We will then explore the Zomato service for restaurant data and integrate it into a chatbot built using the Bot Builder SDK. We will finally deploy it on Skype.
By the end of this chapter, you will be able to:
  • Understand the basics of MS Bot Framework
  • Build a chatbot with the Botbuilder Node.js library
  • Register the bot with Bot Framework
  • Host the bot in the cloud
  • Understand message types and card types
  • Manage context and conversational flow
  • Integrate with the Zomoto data API
  • Integrate the bot with Skype

MS Bot Framework

MS Bot Framework is a Microsoft product for chatbot development. It houses three products: Bot Builder SDK, Bot Framework Portal, and channels. Bot Builder SDK is the toolkit for building chatbots. It has libraries of classes and code that represent various elements of a conversation. These can be used in our development process to build chatbots at a faster pace than building them from scratch. The Bot Framework Portal is used to register the bot in order to manage it efficiently and there is a host of tools for analytics and diagnostics that can be used on this portal. Finally, the framework provides a unified approach to integrating with several channels.
There are a huge number of channels that you can integrate your bot with, including Skype, Facebook Messenger, Kik, Telegram, Slack, MS Teams, and Twilio. You can also create a web chat client using the portal that can be embedded on any website. In addition to the three tools, there are two other tools that are very useful during the development process: channel emulator and channel inspector.

Channel emulator

Before we begin, we need to install software called a channel emulator. We will be using this to emulate the channel (for example, Skype) to connect to the bot locally for development and testing purposes. You can chat with your bot as well as inspect the messages sent and received to identify any bugs.
To download it, go to the following page:
https://github.com/Microsoft/BotFramework-Emulator/releases/tag/v3.5.31
Download the version based on your needs and install it on your computer.

Building a bot

Let us now look at the steps to build a chatbot. Here we will use the botbuilder library and create a bot using Node.js:
  1. Create a Node.js project called foodie-bot:
> npm init
  1. Install the two libraries that we need to use:
> npm install botbuilder --save
> npm install restify --save
  1. Create a file named app.js.
  2. In app.js, paste the following code (from the Bot Framework tutorials):
var restify = require('restify');
var builder = require('botbuilder');

// Lets setup the Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});


// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});


// Listen for messages from users
server.post('/foodiebot', connector.listen());

// Echo their message back.. just parrotting!
var bot = new builder.UniversalBot(connector, function (session) {
session.send("You said: %s", session.message.text);
});
Notice that there are two classes, UniversalBot and ChatConnector, that the Bot Framework's Node.js SDK provides. UniversalBot is the class where we define the conversation flow, while the ChatConnector class connects the bot to the chat channel. In the previous code, we used the session.send() method to send text messages to the chat channel.
  1. Save the file.
  2. Run the emulator. In the address bar, type the following address and connect:
http://localhost:3978/api/messages
At this stage, you don't have to provide an app ID or password.
  1. The emulat...

Table of contents