Cognitive Virtual Assistants Using Google Dialogflow Develop Complex Cognitive Bots Using the Google Dialogflow Platform
Total Page:16
File Type:pdf, Size:1020Kb
Cognitive Virtual Assistants Using Google Dialogflow Develop Complex Cognitive Bots Using the Google Dialogflow Platform Navin Sabharwal Amit Agrawal Cognitive Virtual Assistants Using Google Dialogflow Navin Sabharwal Amit Agrawal New Delhi, Delhi, India Mathura, India ISBN-13 (pbk): 978-1-4842-5740-1 ISBN-13 (electronic): 978-1-4842-5741-8 https://doi.org/10.1007/978-1-4842-5741-8 Copyright © 2020 by Navin Sabharwal, Amit Agrawal This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Celestin Suresh John Development Editor: Matthew Moodie Coordinating Editor: Aditee Mirashi Cover designed by eStudioCalamar Cover image designed by Freepik (www.freepik.com) Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, email [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit http://www.apress.com/ rights-permissions. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-5740-1. For more detailed information, please visit http://www.apress.com/source-code. Printed on acid-free paper Dedicated to the people I love and the God I trust. —Navin Sabharwal Dedicated to my family and friends. —Amit Agrawal Table of Contents About the Authors ................................................................................ix About the Technical Reviewer .............................................................xi Acknowledgments .............................................................................xiii Introduction ........................................................................................xv Chapter 1: Introduction to Cognitive Virtual Bots .................................1 Cognitive Virtual Assistants ...................................................................................2 Use Cases for Cognitive Virtual Assistants ............................................................4 Self-Service/Help Desk for IT Services ...........................................................4 Triage ...............................................................................................................5 Lead Generation ..............................................................................................5 E-commerce ....................................................................................................6 Google Ecosystem .................................................................................................6 Google AI Platform ...........................................................................................7 Products and Services .....................................................................................7 Chapter 2: Introduction to Google Dialogflow .....................................13 Example: Human-to-Human Interactions ............................................................13 Building Your First Bot Using Google Dialogflow .................................................16 Creating a Google Dialogflow Account ..........................................................16 Using the Dialogflow Agent ...........................................................................18 Defining the Intents and Entities ...................................................................20 v TABLE OF CONTENTS Defining an Action and Parameters ...............................................................40 Defining the Responses .................................................................................44 Integrating with the Built-in Bot Framework Web Demo ...............................49 Trying Your First Bot ............................................................................................51 Conclusion ..........................................................................................................54 Chapter 3: Advanced Concepts in Google Dialogflow .........................55 Input and Output Contexts ..................................................................................55 Follow-Up Intents ................................................................................................65 Handling Multiple Intents (Intent Priority) ...........................................................75 Intent Training ................................................................................................79 Conversation List ...........................................................................................79 Agent Settings .....................................................................................................84 Multilingual Chatbots ..........................................................................................94 Prebuilt Agents ....................................................................................................98 Fulfillment: Integration with the Weather API ....................................................106 Fulfillment ...................................................................................................107 Webhook Service .........................................................................................107 Open Source Weather API ............................................................................108 Conclusion ........................................................................................................117 Chapter 4: Chatbot Enrichment ........................................................119 Chatbot Personality ...........................................................................................119 Windows Server ..........................................................................................130 Linux Server ................................................................................................135 Personality JSON .........................................................................................138 Personality Intent.........................................................................................140 Sentiment Analysis ...........................................................................................143 vi TABLE OF CONTENTS Event Configuration: Chatbot Transfer ...............................................................151 Integration with Facebook Messenger ..............................................................158 Google Dialogflow’s Knowledge Base Integration .............................................170 Enable Beta Features ..................................................................................171 Create a Knowledge Base............................................................................172 Spell Correction.................................................................................................177 Conclusion ........................................................................................................181 Chapter 5: New Research in the Field of Cognitive Virtual Chatbots ................................................................................183 Current Research ..............................................................................................184 Research Acquisitions .......................................................................................185 Index .................................................................................................187 vii About the Authors Navin Sabharwal has 20+ years of industry experience and is an innovator, thought leader, patent holder, and author