O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming the Microsoft Bot Framework: A Multiplatform Approach to Building Chatbots

Book Description

This is the only comprehensive, authoritative guide to building Conversational User Interfaces (CUI, a.k.a. bots, chatbots, or chatterbots) with the Microsoft Bot Framework. Reflecting the next radical revolution in human-computer interaction, it will help you leverage advanced artificial intelligence (AI) and natural language processing to empower new and existing applications with stunningly intuitive conversational interfaces.

 

Long-time Microsoft MVP Joe Mayo begins with high-level explanations of what Microsoft Bot Framework is, what you can do with it, and why it matters so much. Next, he presents the foundational knowledge you need to start creating real bots and CUIs. Step by step, you'll learn how to build message dialogs, manage conversations, interact with framework APIs, and incorporate powerful natural language processing with Microsoft's advanced Language Understanding Intelligent Service (LUIS). Mayo also offers detailed guidance on deploying your customized bots to key platforms such as Slack, Skype, and Facebook Messenger.

 

Throughout, Mayo's practical examples combine code with clear explanations of when and why you would perform each task. From start to finish, Programming the Microsoft Bot Framework is relentlessly practical, helping you translate the advanced "magic" of intelligent bots into real solutions right now.

Table of Contents

  1. Cover Page
  2. About This E-Book
  3. Title Page
  4. Copyright Page
  5. Dedication Page
  6. Table of Contents
  7. Introduction
    1. Who should read this book
      1. Assumptions
    2. This book might not be for you if….
    3. Organization of this book
    4. Conventions and features in this book
    5. System requirements
    6. Downloads: Code samples
      1. Installing the code samples
      2. Using the code samples
    7. Acknowledgments
    8. Errata, updates, & book support
    9. Free ebooks from Microsoft Press
    10. We want to hear from you
    11. Stay in touch
  8. Part I Getting Started
    1. Chapter 1 Exploring Bot Framework Architecture
      1. What Is a Chatbot?
        1. Defining a Chatbot
        2. Why Conversation?
        3. Chatbot Benefits
        4. To Bot or Not
      2. Bot Framework Architecture
        1. Visualizing Chatbots, Connector, and Channels
        2. Overview of Channels
        3. Bot Connector Services
        4. Characteristics of a Chatbot
        5. Chatbot Communications
      3. Summary
    2. Chapter 2 Setting Up a Project
      1. Steps to Building a Chatbot
      2. Creating a Bot Framework Project
        1. Installing the Project Template
        2. Starting a New Project
      3. Examining the Default Code
        1. Assembly References
        2. Folder and File Layout
        3. The Default Chatbot
      4. Initial Testing with the Emulator
        1. Installing the Bot Emulator
        2. Configuring the Chatbot
        3. Communicating with the Chatbot
      5. Publishing and Registering a Chatbot
        1. Publishing the Chatbot
        2. Registering a Chatbot
      6. Summary
    3. Chapter 3 Building Conversations: The Essentials
      1. The Rock, Paper, Scissors Game Bot
        1. The PlayType Enum
        2. The Game Class
        3. The MessagesController Class
      2. Conversation State Management
        1. Elements of a Conversation
        2. Saving and Retrieving State
      3. Participating in Conversations
        1. Responding to Conversations
        2. Building a Custom Message Activity
        3. Using a Custom Message Activity
      4. Summary
    4. Chapter 4 Fine-Tuning Your Chatbot
      1. Reviewing Bot Emulator Details
      2. Handling Activities
        1. The Activity Class
        2. The ActivityType Class
        3. Code Design Overview
        4. Sending Activities with the Bot Emulator
        5. Relationship Changes
        6. Conversation Updates
        7. Deleting User Data
        8. Pinging
        9. Typing Indications
      3. Advanced Conversation Messages
        1. Sending Typing Activities
        2. Sending Independent Messages
      4. Summary
  9. Part II Bot Builder
    1. Chapter 5 Building Dialogs
      1. Introducing WineBot
      2. Using the Wine.com API
      3. Implementing a Dialog
        1. Creating a Dialog Class
        2. Dialog Initialization and Workflow
        3. Examining IDialogContext
        4. Dialog Conversation Flow
        5. Dialog Prompt Options
        6. Performing the Search
      4. Calling a Dialog
      5. Summary
    2. Chapter 6 Using FormFlow
      1. Out-of-the-Box Features
      2. A Basic FormFlow Chatbot
        1. The Wine API Interface
        2. WineForm: A FormFlow Form
        3. Using WineForm as a Dialog
      3. Enhancing FormFlow Conversations
        1. The Describe Attribute
        2. The Numeric Attribute
        3. The Optional Attribute
        4. The Pattern Attribute
        5. The Prompt Attribute
        6. The Terms Attribute
      4. Advanced Templates and Patterns
        1. Pattern Language
        2. Basic Templates
        3. Template Usage
        4. Template Options
      5. Summary
    3. Chapter 7 Customizing FormFlow
      1. Understanding the FormFlow Fluent Interface
      2. The Configuration Property
        1. Configuring Responses
        2. Configuring Templates
        3. Configuring Commands
      3. The Message Method and Common Parameters
        1. The condition Parameter
        2. The dependencies Parameter
        3. The prompt Parameter
        4. The generateMessage Parameter
      4. The Confirm Method
      5. Working with Fields
        1. Dynamic Field Definition
        2. Field Validation
        3. The AddRemainingFields Method
        4. The HasField Method
      6. The OnCompletion Method
      7. The Build Method
      8. Initializing FormFlow
      9. Summary
    4. Chapter 8 Using Natural Language Processing (NLP) with LUIS
      1. Learning Essential LUIS Concepts
      2. Setting up LUIS and Training Models
        1. Creating Models
        2. Building Intents
        3. Specifying Entities
        4. Training and Deploying
      3. Using LUIS in Your Chatbots
        1. Introducing WineBotLuis
        2. Adding Intents
        3. Handling Entities
      4. Continuous LUIS Model Improvement
      5. Summary
    5. Chapter 9 Managing Advanced Conversation
      1. Managing the Dialog Stack
        1. What is the Dialog Stack?
        2. Navigating to Other Dialogs
        3. Navigating via Forward
        4. Navigating via Call
        5. Finishing a Dialog
      2. Managing Conversations with Chaining
        1. The WineBotChain Program
        2. Chain.From
        3. Chain.Loop
        4. Chain.Switch
        5. Chain.ContinueWith
        6. An Assortment of Posting and Waiting Chain methods
        7. LINQ to Dialog
      3. Handling Interruptions with IScorable
      4. Formatting Text Output
      5. Summary
  10. Part III Channels and Gui
    1. Chapter 10 Attaching Cards
      1. Music Chatbot Overview
        1. The Groove API
        2. The Root Dialog
        3. The Profile Dialog
        4. The Browse Dialog
        5. The Playlist Dialog
        6. The Search Dialog
      2. Building Blocks
        1. Presenting Suggested Actions
        2. Working with Attachments
      3. Displaying Cards
        1. Implementing BrowseDialog
        2. Implementing PlaylistDialog
      4. Adaptive Cards
        1. Layout with Containers
        2. Using Controls
        3. Handling Actions
      5. Summary
    2. Chapter 11 Configuring Channels
      1. Channel Overview
        1. The Channel Configuration Page
        2. Chatbot Analytics
      2. Configuring Teams
        1. Channel Setup
        2. Using the Chatbot
      3. Configuring Bing
        1. Channel Setup
        2. Using in Search
      4. The Channel Inspector
      5. Summary
    3. Chapter 12 Creating Email, SMS, and Web Chatbots
      1. Emailing Chatbot Conversations
        1. Creating the Email Account
        2. Configuring the Email Channel
      2. Texting a Chatbot
      3. Embedding the Webchat Control
        1. Adding the Webchat IFrame Placeholder
        2. Client-Side Coding
        3. Handling the Server Request
      4. Summary
  11. Part IV Apis, Integrations, and Voice
    1. Chapter 13 Coding Custom Channels with the Direct Line API
      1. Overview of the Console Channel
        1. Console Channel Components
        2. Examining Console Channel Code
      2. Starting a Conversation
      3. Listening for New Activities
      4. Keeping the Conversation Open
      5. Sending Activities
      6. Ending Conversations
        1. Examining CancellationTokenSource and CancellationToken
        2. Handling User Exits
      7. Summary
    2. Chapter 14 Integrating Cognitive Services
      1. Searching with Bing
      2. Interpreting an Image
      3. Translating Text
      4. Building FAQ Chatbots with QnA Maker
      5. Summary
    3. Chapter 15 Adding Voice Services
      1. Adding Speech to Activities
      2. Adding Speech with SayAsync
      3. Adding Speech to PromptDialog
      4. Specifying Input Hints
      5. Setting up Cortana
      6. Summary
  12. Index
  13. Code Snippets