M A N N I N G Andrew Freed Cari Jacobs Enikő Rózsa Foreword by Jesús Mantas Chatbots that work
2 EPILOGUE Improvements are based on analyzing conversation against these outcome dimensions. There’s more to success than “just” containing a conversation! Is the conversational AI meeting your goals? What do users think? What is the impact of recent changes? MEASURE There is always opportunity. What are the low-performance areas? How can they be improved? IDENTIFY Estimate expected effort and improvement. Prioritize your backlog. Implement what’s most important. IMPLEMENT Release to production. Inform your users about improvements! DEPLOY Failure Success Automated resolution Containment Detailed outcome Summary outcome Bot not wanted Intentional transfer Abandonment Failure to understand Escalation (by user) Disconnect (immediate) Escalation (immediate) Contained by bot Transferred to human Improve your conversational AI's effectiveness by following this cycle
Effective Conversational AI
Effective Conversational AI CHATBOTS THAT WORK ANDREW R. FREED CARI JACOBS ENIKŐ RÓZSA FOREWORD BY JESÚS MANTAS M A N N I N G SHELTER ISLAND
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: orders@manning.com ©2025 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. The author and publisher have made every effort to ensure that the information in this book was correct at press time. The author and publisher do not assume and hereby disclaim any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from negligence, accident, or any other cause, or from any usage of the information herein. Manning Publications Co. Development editor: Rebecca Senninger 20 Baldwin Road Technical editors: Jack C. Crawford PO Box 761 Stéfan van der Stockt Shelter Island, NY 11964 Review editor: Kishor Rit Production editor: Kathy Rossland Copy editor: Andy Carroll Proofreader: Melody Dolab Typesetter and cover designer: Marija Tudor ISBN 9781633436404 Printed in the United States of America
Andrew: Thank you to my wife Elise and kids Greg and Jeff for supporting me in writing another book! Cari: To Jason, for your never-ending support throughout my writing process and life in general. And to my dad, Jim. (Surprise! I wrote a book!) Enikő: Thanks to my family, whose unwavering support and encouragement have made this book-writing journey possible. And to my late father, a prolific technical author who paved the way—I stand on your shoulders as I continue your legacy.
brief contents PART 1 FRAMEWORK FOR IMPROVING CONVERSATIONAL AI .......... 1 1 ■ What makes conversational AI work? 3 2 ■ Building a conversational AI 23 3 ■ Planning for improvement 44 PART 2 PATTERN: AI DOESN’T UNDERSTAND .............................. 77 4 ■ Understanding what your users really want 79 5 ■ Improving weak understanding for traditional AI 105 6 ■ Enhancing responses with retrieval-augmented generation 135 7 ■ Augmenting intent data with generative AI 170 PART 3 PATTERN: AI IS TOO COMPLEX .................................... 191 8 ■ Streamlining complex flows 193 9 ■ Harnessing context for an adaptive virtual assistant experience 207 10 ■ Reducing complexity with generative AI 230 PART 4 PATTERN: REDUCE FRICTION ....................................... 249 11 ■ Reducing opt-outs 251 12 ■ Conversational summarization for smooth handoff 278vi
contents foreword xiii preface xv acknowledgments xvii about this book xix about the authors xxii about the cover illustration xxiv PART 1 FRAMEWORK FOR IMPROVING CONVERSATIONAL AI ....................................... 1 1 What makes conversational AI work? 3 1.1 Introduction to conversational AI 4 Why use conversational AI? 5 ■ How does conversational AI work? 6 ■ How you build conversational AI 7 1.2 Introduction to generative AI in conversational AI 10 What is generative AI 11 ■ Generative AI guardrails 12 Effectively using generative AI in conversational AI 13 1.3 Introducing continuous improvement in conversational AI 15 Why continuously improve 16 ■ The continuous improvement cycle 17 ■ Communicating continuous improvement to stakeholders 19 1.4 Follow along 22vii
CONTENTSviii2 Building a conversational AI 23 2.1 Building an FAQ bot 24 FAQ bot foundations 24 ■ Static question and answering 26 ■ Dynamic question and answering 31 2.2 Routing agents and process-oriented bots 33 Routing agents 33 ■ Transitioning from a routing agent to a process-oriented bot 35 2.3 Responding to the user with generative AI 38 Integrating with an LLM 38 ■ Routing requests to an LLM 40 3 Planning for improvement 44 3.1 Knowing when you need to improve 45 3.2 Your cross-functional team 46 3.3 Driving to the same goal 49 Revisit business goals 50 ■ Effectiveness 53 Coverage 62 3.4 Identifying and resolving problems 64 Finding problems 65 ■ Group review 67 ■ Determining acceptance criteria 72 3.5 Developing and delivering fixes 74 Sprint planning 74 ■ Measure again 75 PART 2 PATTERN: AI DOESN’T UNDERSTAND .............. 77 4 Understanding what your users really want 79 4.1 Fundamentals of understanding 80 The impact of weak understanding 80 ■ What causes weak understanding? 81 ■ How do we achieve understanding with traditional conversational AI? 83 ■ How do we achieve understanding with generative AI? 84 4.2 How is understanding measured? 87 Measuring understanding for traditional (classification-based) AI 87 ■ Measuring understanding for generative AI 89 Measuring understanding with direct user feedback 90 4.3 Assessing where you are today 91 Assessing your traditional (classification-based) AI solution 91 Assessing your generative AI solution 92
CONTENTS ix4.4 Obtaining and preparing test data from logs 93 Obtaining production logs 93 ■ Guidelines for identifying candidate test utterances 94 ■ Preparing and scrubbing data for use in iterative improvements 98 ■ The annotation process 99 4.5 What does the data tell us? 101 Interpreting annotated logs for traditional (classification- based) AI 101 ■ Interpreting annotated logs for generative AI 103 ■ The case for iterative improvement 103 5 Improving weak understanding for traditional AI 105 5.1 Building your improvement plan 106 Identify problematic patterns in misunderstood utterances 106 Incremental improvements 110 ■ Where to start: Identifying the biggest problems 110 5.2 Solving “wrong intent matched” 116 Improve recall for one intent 116 ■ Improve precision for one intent 118 ■ Improve the F1 score for one intent 120 Improve precision and recall for multiple intents 120 5.3 Solving “no intent matched” 125 Clustering utterances for new intents 125 ■ When to stop adding intents 130 5.4 Supplementing traditional AI with generative content 131 Combining traditional and generative AI for an intent 132 Prompting to convey understanding 133 6 Enhancing responses with retrieval-augmented generation 135 6.1 Beyond intents: The role of search in conversational AI 136 Using search in conversational AI 137 ■ Benefits of traditional search 138 ■ Drawbacks of traditional search 139 6.2 Beyond search: Generating answers with RAG 140 Using RAG in conversational AI 140 ■ Benefits of RAG 142 Combining RAG with other generative AI use cases 144 Comparing intents, search, and RAG approaches 145 6.3 How is RAG implemented? 146 High-level implementation 147 ■ Preparing your document repository for RAG 148
CONTENTSx6.4 Additional considerations of RAG implementations 151 Can’t we just use an LLM directly? 151 ■ Keeping answers current and relevant with RAG 152 ■ How easy is it to set up the ingestion pipeline? 152 ■ Handling latency 157 ■ When to use a fallback mechanism and when to search 158 6.5 Evaluating and analyzing RAG performance 159 Indexing metrics 159 ■ Retrieval metrics 161 ■ Generation metrics 163 ■ Comparing efficiency of indexing and embedding solutions for RAG 165 7 Augmenting intent data with generative AI 170 7.1 Getting started 171 Why do it: Pros and cons 172 ■ What you need 173 How to use the augmented data 173 7.2 Hardening your existing intents 175 Get creative with synonyms 176 ■ Generate new grammatical variations 179 ■ Build strong intents from LLM output 182 Creating even more examples with templates 185 7.3 Getting more creative 188 Brainstorm additional intents 188 ■ Check for confusion 188 PART 3 PATTERN: AI IS TOO COMPLEX ..................... 191 8 Streamlining complex flows 193 8.1 The pain of complexity 194 Complexity’s effect on the end user 194 ■ Complexity’s effect on business metrics 196 ■ The incremental cost and benefit of reducing complexity for the user 198 8.2 Simplifying and streamlining the user journey 199 Spotting complex dialogue flows 199 ■ Using what is known about the user 199 ■ Aligning with the user’s mental model 201 Allowing flexibility in the expected user responses 202 Supporting self-service task flows with API/backend processes 204 9 Harnessing context for an adaptive virtual assistant experience 207 9.1 Importance of context in virtual assistant performance 208 How context influences user interactions 209 ■ What is contextual information? 212
CONTENTS xi9.2 Understanding modality 217 Comparing modalities 217 ■ Importance of modality in designing virtual assistant flows 219 ■ Examples of how modality affects user experience 220 ■ Voice bot design considerations 222 9.3 Enhancing context awareness and improving the overall user experience with RAG 223 Designing adaptive flows with RAG 224 ■ Strategies for retrieving and generating contextually relevant responses 226 Maintaining and updating adaptive flows 227 10 Reducing complexity with generative AI 230 10.1 AI-assisted process flows at build time 231 Generating dialogue flows with generative AI 232 ■ Improving dialogue flow with generative AI 235 10.2 AI-assisted process flows at run time 237 Executing dialogue flows with generative AI 238 ■ Using LLM for a search process 240 10.3 AI-assisted flows at test time 243 Setting up generative AI to be the user 244 ■ Setting up the conversational test 246 PART 4 PATTERN: REDUCE FRICTION ....................... 249 11 Reducing opt-outs 251 11.1 What drives opt-out behavior? 252 Immediate opt-out drivers 252 ■ Motivations for later opt-outs 253 ■ Gathering data on opt-out behavior 254 11.2 Reducing immediate opt-outs 256 Start with a great experience: Greetings and introductions 257 Convey capabilities and set expectations 259 ■ Incentivize self-service 259 ■ Allow the user to opt in 260 11.3 Reducing other opt-outs 262 Try hard to understand 262 ■ Try hard to be understood 262 Be flexible and accommodating 263 ■ Convey progress 264 Anticipate additional user needs 264 ■ Don’t be rude 265 11.4 Opt-out retention 266 Start right away by collecting opt-out data 267 ■ Implementing an opt-out retention flow 267
CONTENTSxii11.5 Improving dialogue with generative AI 270 Improving error messages with generative AI 270 ■ Improving greeting messages with generative AI 272 11.6 Sometimes it’s okay to escalate 277 12 Conversational summarization for smooth handoff 278 12.1 Intro to summarization 279 Why summarization is needed 279 ■ Elements of effective summaries 280 12.2 Preparing your chatbot for summarization 284 Using out-of-the-box elements 284 ■ Instrumenting your chatbot for transcripts 285 ■ Instrumenting your chatbot (for data points) 288 12.3 Improving summaries with generative AI 290 Generating a text summary of a transcript with summarizing prompts 290 ■ Generating a structured summary of a transcript with extractive prompts 294 index 299
foreword The artificial intelligence revolution will do to our intelligence what the lever did to our physical strength. It will change the world at micro and macro levels, from how each of us writes, thinks, or makes decisions, to how large organizations redesign work and transform jobs. And one of the most common ways in which people will use AI is conversational user applications. Conversational AI is a powerful tool that allows businesses and organizations to serve their customers in better and faster ways. It increases self-service capabilities and handles common inquiries, freeing human agents for focus on higher-value work. As common as this conversational interface of AI is, there are not many books that describe how to do it well. I was happy to encourage my colleagues Andrew Freed, Cari Jacobs, and Enikő Rózsa to share their hands-on experience and provide a framework that others can benefit from. In this book, they have organized and outlined a frame- work of common challenges to take into account when interacting with conversational applications and interfaces, and provided practical solutions using a variety of tech- niques, including data science, generative AI, and conversational design principles. Conversational AI is rarely perfect when switched on. That’s one of the most com- mon misconceptions of leaders who want an “instant gratification” implementation of AI. Conversational AI requires a solid data platform as a foundation, an architecture supporting security and identity, and well-thought-out experience and journey designs. You will find many of these in the examples provided in this book, based on the authors’ hands-on experience building and enhancing conversational AI systems. The book is structured around common pain points that users experience while using conversational user interfaces, and it describes methods for solving each of them. By following the techniques and best practices outlined in this book, organizations canxiii
FOREWORDxivcreate more engaging, effective, and reliable conversational AI systems that will be adopted faster, deliver a greater experience, and translate to a faster return on invest- ment and incremental business value. In short, Effective Conversational AI is a must-read for anyone interested in designing highly effective conversational AI applications. Whether you’re just starting out with conversational AI or you’re a seasoned pro, this book will have something for you. It is a timely and essential resource for anyone looking to harness the power of conversa- tional AI to drive innovation, improve user experiences, and drive business value. —JESÚS MANTAS, GLOBAL MANAGING PARTNER, IBM
preface Conversational AI is an exciting technology that helps users fulfill their needs faster and helps companies handle user inquiries with lower cost. Conversational AI solutions (often called chatbots) have exploded in popularity, especially since the COVID-19 pandemic. There are many books and blogs on how to get started with conversational AI, but most of these books stop at building your first chatbot and do not describe how to improve a production solution. Many enterprises use this technology so that their customers can self-service on a scale that may be prohibitively expensive or impossible with a human workforce. Unfortunately, a significant proportion of these AI solutions underperform. There have also been plenty of hype and resources on generative AI, including prompt engineering and small demos. However, these are often small-scale in nature, such as proofs of concept and prototypes. There are few resources for maintaining and improving these solutions at an enterprise scale. Generative AI has reignited interest in this space, but it is not a panacea, especially for enterprises offering end- to-end task completion. We have delivered many conversational AI solutions to production in the past decade. We have worked with a variety of chatbots: question-answering, process- oriented, and routing agents. We have seen the joys and challenges of conversational AI up close. We wrote this book to help you overcome those challenges. Too often, we have seen chatbots treated as a “set-and-forget” solution. We have also seen chatbots get worse through improper or ill-informed maintenance. As conversational AI builders, we love to dig into underperforming AI solutions and bring them up to excellence. As conversational AI consumers, we want to encounter better chatbots in the wild!xv
PREFACExvi This book helps conversational AI solution owners and stakeholders learn how to identify and remediate the problems that cause chatbots to fail or not reach their full- est potential. Within these pages, you will find a collection of patterns, strategies, and approaches framed around common pain points that exist in conversational AI solutions.
acknowledgments We’ve heard that writing a book is “an act of insanity.” It’s at least a labor of love! We are grateful for the incredible support we’ve received while writing this book for you. ANDREW I’m thankful for my friends and colleagues who helped us refine our think- ing and reviewed early chapters of our book, including Dan Toczala, Jennifer Gao, and Stéfan van der Stockt. We also thank the innumerable colleagues who have built and improved chatbots alongside us, including but not limited to Leo Mazzoli, Victor Povar, Rebecca James, Jasmeet Singh, Greg Ecock, Tomi Jenkins, Morgan Carroll, Jon- athan Roe, Preeth Muthusamy, Marco Noel, Taylor Wood, Jim Kennedy, Elizabeth Smith, Richie Limpijankit, Janice Chan, Yugandhar Chejarla, Kanchan Pandey, Syed Taher, Anirban Mukherjee, Anik Majumder, Swapnil Sharma, and Terrence Nixa. I’m especially thankful to my wife Elise, children Greg and Jeff, and parents Ron and Deb- bie for their support throughout this process. CARI I would like to extend personal thanks to my amazing partner, Jason Kerns. This past year has been especially grueling. Your support, patience, and encourage- ment have meant the world to me. I would also like to express my gratitude to several other former colleagues and mentors who, over the past three decades, shaped my career trajectory and influenced my work ethic: Jared Young, Sean Higgens, Bart Day, Lori Workman, Cory Yochens (rest in peace), Jeff Fetherolf, Tim Shera, Heidi (Piper) Morgan, and Jeff Matteo. Thanks also to my kids (Lani, Ryan, Joe), my bonus kids (Alex, Josh, Lily), my grandson Cameron, Ashley Jacobs, and Bruce Kerns for the enthusiasm and kind words every time the topic of this book came up. xvii
ACKNOWLEDGMENTSxviiiENIKŐ Writing this book has been a journey I could not have completed without my family’s encouragement and support. To my husband Shahram, and to our wonderful kids, Jennifer, Alex, Rachelle, and our bonus kids, Mehr, Margaret, and Tal, thank you for the countless late nights spent discussing ideas around the kitchen island, fueling this endeavor with your insights and laughter. Lisa and Erik, thank you for walking and taking care of Theo so I could spend more time writing. Your kindness and sup- port have been invaluable. I also extend my heartfelt thanks to my colleagues, former colleagues, and men- tors, Will Raabe, Currie Boyle, Craig Trim, Claire Turner, Victor Povar, Brenda Had- dock, Xavier Vergés, and Les Yip, with whom we built chatbots before they were even called chatbots. Thanks to those working on conversational AI and the continuous improvement of chatbots with me, including but not limited to Monisankar Das, Chayan Ray, Avi Yaeli, Sergey Zeltyn, Ignas Valancius, Romanas Marčenko, Eimantas Pėlikis, Kristina Ribačionkaitė, Ateret Anaby-Tavor, Ella Rabinovich, Madhusmita Patil, Arzoo Sabharwal, Richa Manral, and many more. I am grateful for your hard work, dedication, and insights. We are grateful to the entire staff of Manning Publications for their support and help throughout this process. Special thanks to our technical editors, Jack C. Crawford and Stéfan van der Stockt. Jack is a highly skilled AI architect with a Master’s in Computer Information Systems from Claremont Graduate University. He leads generative AI efforts for the virtual assistant of a high-impact mobile application serving millions of users. Stéfan is an AI Solution Architect for IBM who focuses on generative AI, machine learning, and artificial intelligence. He helps IBM clients scope out and define projects to implement production-grade solutions that rely on these technologies. To all the reviewers: Abdullah Al Imran, Anandaganesh Balakrishnan, Artem Daineko, Ayush Bihani, Brandon Smith, Bruno Sonnino, Erico Lendzian, Felipe Coutinho, Gary Pass, Harinath Mallepally, Igor Vieira, James Black, Jiri Pik, John Kel- vie, Jonathan Reeves, Lucas Petralli, Marco Kotrotsos, Maxim Volgin, Nahid Alam, Oleg Kopychko, Parth Santpurkar, Piotr Pindel, Richard Vaughan, Scott Ling, Simone Sguazza, Stefano Ongarello, Swapneelkumar Deshpande, Tong Zhu, Umesh Hode- ghatta, and Venkatraman Umbalacheri Ramasamy, your suggestions helped make this a better book. Finally, heartfelt thanks to Jesús Mantas for his excellent foreword that captures the essence of using conversational AI in the wild.
Comments 0
Loading comments...
Reply to Comment
Edit Comment