Table Of ContentDeveloping Bots
with QnA Maker
Service
Integration with Azure Bot Service
and Microsoft Bot Framework
—
Kasam Shaikh
Developing Bots with
QnA Maker Service
Integration with Azure Bot
Service and Microsoft Bot
Framework
Kasam Shaikh
Developing Bots with QnA Maker Service: Integration with Azure Bot
Service and Microsoft Bot Framework
Kasam Shaikh
Mumbai, Maharashtra, India
ISBN-13 (pbk): 978-1-4842-4184-4 ISBN-13 (electronic): 978-1-4842-4185-1
https://doi.org/10.1007/978-1-4842-4185-1
Library of Congress Control Number: 2018964830
Copyright © 2019 by Kasam Shaikh
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: Smriti Srivastava
Development Editor: Matthew Moodie
Coordinating Editor: Shrikant Vishwakarma
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, e-mail
orders-ny@springer-sbm.com, 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 rights@apress.com, 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-4184-4. For
more detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
To my father, the late Mr. Ahmed Kasam Shaikh, who is
always a source of inspiration for me, and to my mentor,
Mr. Sabarinath Iyer.
Table of Contents
About the Author ���������������������������������������������������������������������������������ix
About the Technical Reviewer �������������������������������������������������������������xi
Acknowledgments �����������������������������������������������������������������������������xiii
Chapter 1: Eagle-Eye View of Azure Cognitive Services ����������������������1
The What and Why of Cognitive Services ��������������������������������������������������������������1
Artificial Intelligence ����������������������������������������������������������������������������������������2
Machine Learning ��������������������������������������������������������������������������������������������2
Azure Cognitive Services ���������������������������������������������������������������������������������3
Who Offers Cognitive Services ������������������������������������������������������������������������������4
Azure Cognitive Services APIs at a Glance ������������������������������������������������������������4
The Vision Category �����������������������������������������������������������������������������������������5
The Speech Category ������������������������������������������������������������������������������������11
The Language Category ���������������������������������������������������������������������������������13
The Knowledge Category �������������������������������������������������������������������������������15
The Search Category �������������������������������������������������������������������������������������15
Cognitive Services Labs ��������������������������������������������������������������������������������������16
Pricing of Azure Cognitive Services ��������������������������������������������������������������������18
Using Azure Cognitive Services���������������������������������������������������������������������������18
Summary�������������������������������������������������������������������������������������������������������������28
v
TTaabbllee ooff CCoonnTTeennTTss
Chapter 2: The What, When, Why, and How of the
QnAMaker Service ������������������������������������������������������������������������������31
Why You Need the QnAMaker Service �����������������������������������������������������������������32
What Is QnAMaker? ���������������������������������������������������������������������������������������������33
The QnAMaker Architecture ��������������������������������������������������������������������������������35
The Control Plane ������������������������������������������������������������������������������������������35
The Data Plane ����������������������������������������������������������������������������������������������37
Creating a QnAMaker Service �����������������������������������������������������������������������������39
Registering Your Service �������������������������������������������������������������������������������45
Using Automation Options �����������������������������������������������������������������������������54
Finishing the Project ��������������������������������������������������������������������������������������54
Summary�������������������������������������������������������������������������������������������������������������59
Chapter 3: Creating the FAQ Bot Backend from Scratch ���������������������61
Ways to Create a Knowledgebase �����������������������������������������������������������������������62
The Lifecycle of a Knowledgebase ����������������������������������������������������������������������62
Associating with the QnAMaker Service �������������������������������������������������������63
Save and Train �����������������������������������������������������������������������������������������������72
Publishing the Knowledgebase ���������������������������������������������������������������������73
Summary�������������������������������������������������������������������������������������������������������������76
Chapter 4: Talk with Azure Bot Framework ����������������������������������������77
Recap: What Is a Bot? �����������������������������������������������������������������������������������������77
The Azure Web App Bot ���������������������������������������������������������������������������������������79
Getting Started with Azure Web App Bot �������������������������������������������������������79
Integrating with the QnAMaker Knowledgebase �������������������������������������������94
Summary�������������������������������������������������������������������������������������������������������������97
vi
TTaabbllee ooff CCoonnTTeennTTss
Chapter 5: Connecting FAQ Bot to Social Channels ����������������������������99
Available Social Channels �����������������������������������������������������������������������������������99
Connecting the Bot to Telegram ������������������������������������������������������������������������101
Exploring the Default Web Chat Channel�����������������������������������������������������������106
Deleting a Connected Channel ��������������������������������������������������������������������������109
Summary�����������������������������������������������������������������������������������������������������������109
Chapter 6: Bot Build Management ����������������������������������������������������111
Building a Bot Online �����������������������������������������������������������������������������������������111
Using the Online Code Editor �����������������������������������������������������������������������112
Changing the Bot Code Online ���������������������������������������������������������������������113
Spinning Up the Bot Code ����������������������������������������������������������������������������116
Building the Bot Code Locally ���������������������������������������������������������������������������118
Continuous Deployment ������������������������������������������������������������������������������������123
Summary�����������������������������������������������������������������������������������������������������������130
Chapter 7: Things You Must Know About the QnAMaker
Knowledgebase ��������������������������������������������������������������������������������131
Updating the Knowledgebase ���������������������������������������������������������������������������132
Edit Settings ������������������������������������������������������������������������������������������������132
Adding Filters ����������������������������������������������������������������������������������������������137
Adding Multiple Users to a Knowledgebase ������������������������������������������������138
Supported Languages ���������������������������������������������������������������������������������������141
The Settings Page of QnAMaker �����������������������������������������������������������������������143
Live Chat Logs ���������������������������������������������������������������������������������������������������146
Testing the Knowledgebase ������������������������������������������������������������������������������153
Summary�����������������������������������������������������������������������������������������������������������155
vii
TTaabbllee ooff CCoonnTTeennTTss
Chapter 8: A Step Toward Having an Interactive and
Cost-Effective FAQ Bot ����������������������������������������������������������������������157
Adding Hyperlinks ���������������������������������������������������������������������������������������������157
Rich Cards ���������������������������������������������������������������������������������������������������������159
Implementing a Hero Card ���������������������������������������������������������������������������160
Testing the Hero Card ����������������������������������������������������������������������������������166
Queries and Myths ��������������������������������������������������������������������������������������������168
How I Can Make QnA Maker Extract My Organization’s Intranet Page? ������168
Can I Identify Who Is Talking to My FAQ Bot? ����������������������������������������������169
Can QnA Maker Extract an Unstructured Format? ���������������������������������������169
What Is the Max Data Size in Knowledgebase?�������������������������������������������169
Does the FAQ Bot Update Its Knowledgebase Automatically as Questions
and Queries Come In? ���������������������������������������������������������������������������������171
Summary�����������������������������������������������������������������������������������������������������������172
Index �������������������������������������������������������������������������������������������������175
viii
About the Author
Kasam Shaikh is a certified Azure architect,
global AI speaker, technical blogger, and a C#
Corner MVP. He has more than 10 years of
experience in the IT industry and is a regular
speaker at various events on Azure. He is also a
founder of DearAzure.net. He leads the Azure
INDIA (azINDIA) online community, the
fastest growing online community for learning
Microsoft Azure. He has a concrete technical
background with good hands-on experience
in Microsoft technologies. At DearAzure.net, he has been organizing free
online webinars and live events for learning Microsoft Azure. He also gives
sessions and speaks on developing bots with Microsoft Azure cognitive
and QnA Maker service at international conferences, online communities,
and local user groups. He owns a YouTube channel and shares his
experiences on his website at https://www.kasamshaikh.com.
ix
About the Technical Reviewer
Adwait Churi is a certified Microsoft Azure
Solution Architect and MuleSoft Certified
Architect, a seasoned professional with 12+
years of experience (in the banking, financial
service, and insurance fields), with LMS
(Learning Management System), and in the
healthcare and hospitality domains.
He is passionate about learning about
technologies, including cloud, integration,
micro-services, ETL, and DevOps. He has worked in various technologies,
including Microsoft BizTalk Server, Microsoft Azure, MuleSoft, Microsoft
Business Intelligence, and Microsoft SQL and has a range of experience
in software application architecture and design, pre-sales, performance
engineering, project management, and software development.
He also gives courses on Microsoft BizTalk Server, MuleSoft, and
Microsoft Azure.
xi
Description:Learn to develop bots with zero coding knowledge using the Azure Cognitive QnA Maker service, a GUI cognitive service from Microsoft. This book shows you how to integrate QnA Maker with the Azure Bot Service and Microsoft Bot Framework, along with how to integrate your bot with social channels such