2018
Do You Wanna Build A Chatbot?
Paul Withers – Intec Systems Ltd
Paul Withers
ICS Developer, Intec Systems Ltd
OpenNTF Board Member
IBM Lifetime Champion
Notes Developer XPages Developer Java Developer
Microservices
Developer
Statbot
• Most chatbot conversations start with “Hi”
• There are more than 30,000 Facebook chatbots
• 63% would message online chatbot to speak to business / brand
• 37% of Americans willing to purchase through a chatbot
• 73% of Americans wouldn’t use a company’s chatbot after a bad
experience
• 75% want to know if they’re talking to a chatbot or a person
https://chatbotsmagazine.com/11-amazing-facts-you-might-not-know-about-chatbots-7764213406e0
What is Watson Assistant?
Watson Assistant (formerly Watson Conversation) is an IBM chat cloud
service that uses natural language processing and more structured
processing to build a dialog workflow that an external system can interact
with and tracking the session for a specific conversation, fronted by a
browser-based interface for development, testing and DevOps.
IBM Chat Cloud Service
• Other providers may have similar services for managing a chatbot’s flow
• Cloud only currently. Product Manager has confirmed on prem is coming
• Training doesn’t retain personal data, conversations available for a period of
time for review and training
• You can’t improve the results if you don’t know what was asked
• Obviously includes a database for storing intents, entities etc
• But no setup or management required
• Intents, entities and dialog flow can be exported / imported as JSON
• Programmatic APIs to add / modify intents etc
Natural Language Processing
INTENTS
• Phrases and variants
• Case sensitivity is irrelevant
• Grammar is irrelevant
• Will cope with some mis-typing
• Can include entities
• Training algorithms will extrapolate
More Structured Processing
ENTITIES
• Key values
• Can include fuzzy matching
• Synonyms (database, Notes, Domino, NSF)
• Regex pattern matching (e.g. email format)
• Also some system entities available, e.g. @sys-person
• System entities cannot be trained
Dialog Flow
• “Welcome” and “Anything Else” nodes
• Workflow rules to respond to intents or entities or static conditions
• Flow can define how to deal with follow-on responses
• Flow can define how to handle digressions
• Steps can set / modify state
• Steps return a JSON object containing text, images, buttons etc and
additional JSON data
External Systems
• Watson Assistant is not a User Interface
• Does not typically interact directly with external databases
• But can be directly connected to cloud functions
• Does not manage authentication
Tracking the Session
• Done via context JSON object
• Passed into and out of every interaction with Watson Assistant
• Can be updated by dialog flow
• E.g. depending on entities recognised
• Can be updated by external systems
Browser-based Tool
• Accessible from your IBM Cloud dashboard
• Managing workspaces for a conversation
• Developer panel for the intents, entities and dialog
• APIs are available for programmatically managing
• Basic testing client in sidebar allows testing / training
• DevOps area for reviewing usage and updating training
This is Watson Assistant
What Is A Chatbot?
A chatbot comprises a user interface where a person provides dialog
content which is passed with any metadata on through one or more
services and receives a fixed-format response for the application to return
for the person.
User Interface
• User interface will vary, including e.g.
• Custom interface (e.g. XPage, Java UI, JavaScript UI)
• Out-of-the-box configurable plugin (e.g. WordPress)
• Hooked service (e.g. Watson Workspace app + “Make it Cognitive”)
• Speech interface (e.g. Alexa, IBM Voice Gateway)
Dialog Content with Metadata
• Remember context JSON object
One or More Services
• Watson Assistant may be just one of the services
• Out-of-the-box plugins / hooked services will be limited
• How do you integrate with external systems / additional services?
• How many calls will it make, how to avoid abuse?
• Custom application (“orchestration layer”) provides greater flexibility,
control and ability to hook in whatever you want
• E.g. SSJS, XPages Java, LotusScript, Node-RED, JavaScript
Don’t Understate Architecture!
• Create an investment management chatbot
Fixed-format Response
• Watson Assistant returns JSON object
• UI layer handles manipulation of e.g. JSON object to user-friendly
output
This Is A Chatbot
This Is What I’m Covering
Not This
Workspaces
• Not the Notes Workspace
• Not a Watson Workspace
• One of a collection of chat “spaces” – 5 for Lite, 20 for Standard
• Avoids conflicts or misunderstanding in larger “chats”
• Has its own id, URL, username and password
• Your app / plugin will need these to interact with the
correct workspace
Intents
• Groupings for particular requests
• “buy a ticket”, “get directions”, “hotel”
• 100 for Lite, 2000 for Standard
• Examples add alternative phrasing, 25000 max
• Can be imported or exported as CSV
• Can be managed programmatically
Intents
• Phrasing may include entities
• Either explicit values or @entity-name – read Documentation!
• Intent example + entity variants + a bit of magic = training variants
Entities
• Groupings for specific nomenclature
• 25 for Lite, 1000 for Standard – system entities count too
• An entity can include different entity values
• Entity “@beer” includes “beer”, “beer_types” and “wine”
• Will identify entity as e.g. @beer:beer, @beer:wine
• Values can use synonyms up to 64 characters, entity can be enabled
for fuzzy matching
• 100,000 entity values and 100,000 synonyms max
Entities
• Values can alternative use pattern matching
• Up to 5 patterns per entity value
• Enter as regex, max 512 characters
• Synonyms or Patterns – not both!
System Entities
• Can be enabled for more generic recognitions
• E.g. @sys-date, @sys-number, @sys-person
• Cannot be trained
• What you get is what you get!
• Tend to be US-focused
• Dates are always MM/dd/yyyy, can’t be defined as dd/MM/yyyy
Dialog
• Dialog is a tree-based flow of nodes
• 25,000 for Lite, 100,000 for Standard
• “If” statements based on recognitions of intents, entities, context etc
• Customise for:
• Gathering multiple pieces of information in one go (slots)
• Define multiple responses based on sub-conditions
• Allow digressions into / out of this node
Dialog
• Steps
• Define responses, if required
• Text, Option, Pause, Image
• But does your UI handle all these response types?
• Set or modifies (optionally) context variables
• Define what to do next
Context
• Dialog is stateless
• Context is JSON object of context variables for each conversation
• Use “context editor” to manage
• Expression language methods available, e.g. <? input.text ?>, <?
@email:literal ?> etc
• Variables can be complex JSON objects and arrays
• Can be passed in and is passed out of nodes
• If it can be passed in, it can be modified externally!
External Integration
• How do you interact with third-party services from Watson Assistant?
• Code it in your orchestration layer, update context object, pass result back
• Make programmatic call from Watson Assistant node
• Client: defines programmatic name your chatbot client understands and
can interpret to return result to dialog
• E.g. JS function if chatbot is a web page
• Not all chatbot clients may support client calls
• Server: IBM Cloud Function, see video
• Runs after context variables have been updated
Cloud Functions
• Repository for “Serverless” REST APIs
• Currently beta, only in US South and Germany regions
• Cloud Functions instance uses same location as Watson Assistant instance
• Can’t call Cloud Functions web action
• Single call must complete in 5 seconds, multiple calls must complete within 7
seconds
• Up to 5 calls from a node, processed in parallel
• To call in series, use Cloud Functions sequence or multiple nodes
Testing
• Use “Try it out” panel
• “Manage Context” allows view / edit
of context variables
• Change intent recognised or mark
irrelevant
• Turn on “node tracing” to highlight
visited nodes for this response
Debugging Dialog
• Adam Newbold’s Dialog Debugger PHP app
• PHP app can be run
on IBM Cloud
• One of three utilities
also on GitHub including
utility to rename entities
Training
• Are you / your business analysts omniscient?
• No? You need to regularly review and train
• Look to update where there is weak understanding
• Review conversations for:
• Incorrect understanding
• Incorrect flows – reorder nodes
• Requirements for additional flows
• Requirements for digression handling
Best Practice
• Challenge your users:
• Is a chatbot the right approach?
• Is the chatbot in the right point of access?
• What value is the chatbot adding?
• What is the right tone for the chatbot?
• Design on paper, document on cloud
• Group nodes into folders for easier manageability
Best Practice
• More nodes = more complexity = greater risk of ambiguity
• This is why you may want multiple workspaces
• Disambiguation is only available to Premium users
• May need to handle multiple intents, see Compound Questions blog
• May need to handle multiple entities
• Use contextual entities – add annotations to intents
• RTFM to understand how to best code conditions
Resources
• Watson Assistant Documentation
• Watson Assistant Demo
• Watson Assistant GitHub Samples
• Watson Assistant YouTube channel
• SDKs for Node, Java and XPages (needs Java 8 and Java security changes)
• Watson Node-Red Nodes (automatically added when creating Node-RED starter on IBM
Cloud)
• Watson Developer Cloud Node-Red Labs
• Chatbots and Watson Assistant blog post
• Simon O’Doherty blog
• Watson Developer Community inviter on Slack
Thanks to our 2018 Sponsors
Questions?
Paul Withers
Intec Systems Ltd & OpenNTF
pwithers@intec.co.uk
@paulswithers
https://www.intec.co.uk/blog
https://paulswithers.github.io

ICONUK 2018 - Do You Wanna Build a Chatbot

  • 1.
    2018 Do You WannaBuild A Chatbot? Paul Withers – Intec Systems Ltd
  • 2.
    Paul Withers ICS Developer,Intec Systems Ltd OpenNTF Board Member IBM Lifetime Champion Notes Developer XPages Developer Java Developer Microservices Developer
  • 3.
    Statbot • Most chatbotconversations start with “Hi” • There are more than 30,000 Facebook chatbots • 63% would message online chatbot to speak to business / brand • 37% of Americans willing to purchase through a chatbot • 73% of Americans wouldn’t use a company’s chatbot after a bad experience • 75% want to know if they’re talking to a chatbot or a person https://chatbotsmagazine.com/11-amazing-facts-you-might-not-know-about-chatbots-7764213406e0
  • 4.
    What is WatsonAssistant? Watson Assistant (formerly Watson Conversation) is an IBM chat cloud service that uses natural language processing and more structured processing to build a dialog workflow that an external system can interact with and tracking the session for a specific conversation, fronted by a browser-based interface for development, testing and DevOps.
  • 5.
    IBM Chat CloudService • Other providers may have similar services for managing a chatbot’s flow • Cloud only currently. Product Manager has confirmed on prem is coming • Training doesn’t retain personal data, conversations available for a period of time for review and training • You can’t improve the results if you don’t know what was asked • Obviously includes a database for storing intents, entities etc • But no setup or management required • Intents, entities and dialog flow can be exported / imported as JSON • Programmatic APIs to add / modify intents etc
  • 6.
    Natural Language Processing INTENTS •Phrases and variants • Case sensitivity is irrelevant • Grammar is irrelevant • Will cope with some mis-typing • Can include entities • Training algorithms will extrapolate
  • 7.
    More Structured Processing ENTITIES •Key values • Can include fuzzy matching • Synonyms (database, Notes, Domino, NSF) • Regex pattern matching (e.g. email format) • Also some system entities available, e.g. @sys-person • System entities cannot be trained
  • 8.
    Dialog Flow • “Welcome”and “Anything Else” nodes • Workflow rules to respond to intents or entities or static conditions • Flow can define how to deal with follow-on responses • Flow can define how to handle digressions • Steps can set / modify state • Steps return a JSON object containing text, images, buttons etc and additional JSON data
  • 9.
    External Systems • WatsonAssistant is not a User Interface • Does not typically interact directly with external databases • But can be directly connected to cloud functions • Does not manage authentication
  • 10.
    Tracking the Session •Done via context JSON object • Passed into and out of every interaction with Watson Assistant • Can be updated by dialog flow • E.g. depending on entities recognised • Can be updated by external systems
  • 11.
    Browser-based Tool • Accessiblefrom your IBM Cloud dashboard • Managing workspaces for a conversation • Developer panel for the intents, entities and dialog • APIs are available for programmatically managing • Basic testing client in sidebar allows testing / training • DevOps area for reviewing usage and updating training
  • 12.
    This is WatsonAssistant
  • 13.
    What Is AChatbot? A chatbot comprises a user interface where a person provides dialog content which is passed with any metadata on through one or more services and receives a fixed-format response for the application to return for the person.
  • 14.
    User Interface • Userinterface will vary, including e.g. • Custom interface (e.g. XPage, Java UI, JavaScript UI) • Out-of-the-box configurable plugin (e.g. WordPress) • Hooked service (e.g. Watson Workspace app + “Make it Cognitive”) • Speech interface (e.g. Alexa, IBM Voice Gateway)
  • 15.
    Dialog Content withMetadata • Remember context JSON object
  • 16.
    One or MoreServices • Watson Assistant may be just one of the services • Out-of-the-box plugins / hooked services will be limited • How do you integrate with external systems / additional services? • How many calls will it make, how to avoid abuse? • Custom application (“orchestration layer”) provides greater flexibility, control and ability to hook in whatever you want • E.g. SSJS, XPages Java, LotusScript, Node-RED, JavaScript
  • 17.
    Don’t Understate Architecture! •Create an investment management chatbot
  • 18.
    Fixed-format Response • WatsonAssistant returns JSON object • UI layer handles manipulation of e.g. JSON object to user-friendly output
  • 19.
    This Is AChatbot
  • 20.
    This Is WhatI’m Covering
  • 21.
  • 22.
    Workspaces • Not theNotes Workspace • Not a Watson Workspace • One of a collection of chat “spaces” – 5 for Lite, 20 for Standard • Avoids conflicts or misunderstanding in larger “chats” • Has its own id, URL, username and password • Your app / plugin will need these to interact with the correct workspace
  • 23.
    Intents • Groupings forparticular requests • “buy a ticket”, “get directions”, “hotel” • 100 for Lite, 2000 for Standard • Examples add alternative phrasing, 25000 max • Can be imported or exported as CSV • Can be managed programmatically
  • 24.
    Intents • Phrasing mayinclude entities • Either explicit values or @entity-name – read Documentation! • Intent example + entity variants + a bit of magic = training variants
  • 25.
    Entities • Groupings forspecific nomenclature • 25 for Lite, 1000 for Standard – system entities count too • An entity can include different entity values • Entity “@beer” includes “beer”, “beer_types” and “wine” • Will identify entity as e.g. @beer:beer, @beer:wine • Values can use synonyms up to 64 characters, entity can be enabled for fuzzy matching • 100,000 entity values and 100,000 synonyms max
  • 26.
    Entities • Values canalternative use pattern matching • Up to 5 patterns per entity value • Enter as regex, max 512 characters • Synonyms or Patterns – not both!
  • 27.
    System Entities • Canbe enabled for more generic recognitions • E.g. @sys-date, @sys-number, @sys-person • Cannot be trained • What you get is what you get! • Tend to be US-focused • Dates are always MM/dd/yyyy, can’t be defined as dd/MM/yyyy
  • 28.
    Dialog • Dialog isa tree-based flow of nodes • 25,000 for Lite, 100,000 for Standard • “If” statements based on recognitions of intents, entities, context etc • Customise for: • Gathering multiple pieces of information in one go (slots) • Define multiple responses based on sub-conditions • Allow digressions into / out of this node
  • 29.
    Dialog • Steps • Defineresponses, if required • Text, Option, Pause, Image • But does your UI handle all these response types? • Set or modifies (optionally) context variables • Define what to do next
  • 30.
    Context • Dialog isstateless • Context is JSON object of context variables for each conversation • Use “context editor” to manage • Expression language methods available, e.g. <? input.text ?>, <? @email:literal ?> etc • Variables can be complex JSON objects and arrays • Can be passed in and is passed out of nodes • If it can be passed in, it can be modified externally!
  • 31.
    External Integration • Howdo you interact with third-party services from Watson Assistant? • Code it in your orchestration layer, update context object, pass result back • Make programmatic call from Watson Assistant node • Client: defines programmatic name your chatbot client understands and can interpret to return result to dialog • E.g. JS function if chatbot is a web page • Not all chatbot clients may support client calls • Server: IBM Cloud Function, see video • Runs after context variables have been updated
  • 32.
    Cloud Functions • Repositoryfor “Serverless” REST APIs • Currently beta, only in US South and Germany regions • Cloud Functions instance uses same location as Watson Assistant instance • Can’t call Cloud Functions web action • Single call must complete in 5 seconds, multiple calls must complete within 7 seconds • Up to 5 calls from a node, processed in parallel • To call in series, use Cloud Functions sequence or multiple nodes
  • 33.
    Testing • Use “Tryit out” panel • “Manage Context” allows view / edit of context variables • Change intent recognised or mark irrelevant • Turn on “node tracing” to highlight visited nodes for this response
  • 34.
    Debugging Dialog • AdamNewbold’s Dialog Debugger PHP app • PHP app can be run on IBM Cloud • One of three utilities also on GitHub including utility to rename entities
  • 35.
    Training • Are you/ your business analysts omniscient? • No? You need to regularly review and train • Look to update where there is weak understanding • Review conversations for: • Incorrect understanding • Incorrect flows – reorder nodes • Requirements for additional flows • Requirements for digression handling
  • 36.
    Best Practice • Challengeyour users: • Is a chatbot the right approach? • Is the chatbot in the right point of access? • What value is the chatbot adding? • What is the right tone for the chatbot? • Design on paper, document on cloud • Group nodes into folders for easier manageability
  • 37.
    Best Practice • Morenodes = more complexity = greater risk of ambiguity • This is why you may want multiple workspaces • Disambiguation is only available to Premium users • May need to handle multiple intents, see Compound Questions blog • May need to handle multiple entities • Use contextual entities – add annotations to intents • RTFM to understand how to best code conditions
  • 38.
    Resources • Watson AssistantDocumentation • Watson Assistant Demo • Watson Assistant GitHub Samples • Watson Assistant YouTube channel • SDKs for Node, Java and XPages (needs Java 8 and Java security changes) • Watson Node-Red Nodes (automatically added when creating Node-RED starter on IBM Cloud) • Watson Developer Cloud Node-Red Labs • Chatbots and Watson Assistant blog post • Simon O’Doherty blog • Watson Developer Community inviter on Slack
  • 39.
    Thanks to our2018 Sponsors
  • 40.
    Questions? Paul Withers Intec SystemsLtd & OpenNTF pwithers@intec.co.uk @paulswithers https://www.intec.co.uk/blog https://paulswithers.github.io