CHAT Bots

beyond the hype

Guido García · @palmerabollo

Telefónica I+D

 

DataBeers@DT 2016

ME & EXPECTATIONS

agent able to imitate and have human-like conversations that may result in the execution of actions

What is a bot

productivity tools, automate tasks, book flights, get recommendations, find restaurants, personal assistant, customer service, etc

MANY UseLESS cases IN DIFFERENT DOMAINS

JUST ANOTHER PRESENTATION LAYER...

...WITH A Natural User Experience

  • Natural Language
  • Known Tools (no new apps)

No need to learn anything new

Overall architecture

ARCHITECTURE: Adapter

  • Speech To Text
  • Spell Check
  • Input normalization
  • Authorization
  • Analytics
    • Language detection
    • Sentiment analysis
    • Language style (formal, informal, slang, ...)

ex. "ber mifatura"

ARCHITECTURE: Input processing

extract intent + entities

a. Regular expressions

robot.respond /switch off the (.*)/i, (res) ->
    device = res.match[1]
    if device is "television"
	// do something with intent “switch off” and
        // entity “television”
    else
	// do something else

a. TEMPLATES / AIML / ...

<aiml>
<category>
    <pattern>WHAT ARE YOU</pattern>
    <template>
        <think><set name="topic">Me</set></think> 
        I am the latest result in artificial intelligence.
    </template>
</category>
</aiml>

B. Natural Language Processing (NPL)

"Ey bot, switch off the television"

intent: turn_off_device
entities: [device = television]

model trained

with a "large" data set

NLP cloud players

  • Microsoft · https://luis.ai
    (Language Understanding Intelligent Service)
  • Facebook · https://wit.ai
  • Google · https://api.ai
  • IBM Watson
  • Also related:
    • Siri (Apple)
    • Alexa (Amazon)
    • Cortana (Microsoft)

LUIS DEMO

  1. Create LUIS app
  2. Define intents and entities
  3. Train
  4. Publish app
  • Retrieval-based (tree, if/else)
    • Boring UX
    • No grammatical mistakes
  • Generational (machine translation, deep learning)

ARCHITECTURE: OUTPUT GENERATION

"A Neural Conversational Model", Google 2015

Challenges

  • Add facts.
  • Reasoning, inferences.
  • Integrate knowledge in the conversation.

ARCHITECTURE: Context !

- Who is the president of the US?

- Donald Trump

- How old is he?

Microsoft

Bot Framework

pros

Multichannel support

SDK available in node.js / .net

Support from microsoft

Cognitive Services suite

cons

Additional network element

Always doing catch up

REGISTER

DEVELOP
DEPLOY

const restify = require('restify');
const builder = require('botbuilder');

// Setup HTTP Server
let server = restify.createServer();
server.listen(8080, () => {
   console.log('server listening'); 
});
  
// Create chat bot
let connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
let bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());

// Add dialogs
bot.dialog('/', (session) => {
    session.send("Hello World");
});

http server + dialogs

Limitations

  • No Context.
  • Still retrieval-based responses (tree).
  • Difficult to work in parallel
  • No CLI training tools
  • No voice support
  • Limited multimedia tooling
  • No automatic language detection
  • HTTP server management

Telefonica bot platform

https://bots.tid.es

NOW WE ARE TALKING

THIN LAYER ON TOP OF MS BOT FRAMEWORK

Optional

Architecture

  • Plugin mechanism
  • Predefined set of middlewares
    • Language detection
    • Audio support
    • Slack integration
  • Multimedia support (audio / images) integrated with S3
  • Training tools
  • MS Bot SDK extensions
    • Break dialogs/prompts anytime.
  • Support from TDAF Team :)

COMES WITH some benefits

DEMO

build a bot FROM A SEED PROJECT

git clone git@github.com/Telefonica/seed-bot.git
cd seed-bot

npm login # request access to tdaf@tid.es
npm install
npm run dev

build a bot FROM SCRATCH

import { Bot, BotConsoleRunner } from '@telefonica/bot-core';

const bot = new Bot({
    plugins: [ 'bot-plugin-helloworld' ],
    modelMapSet: [{
        'en-us': 'your-luis-app-url'
    }];
});

new BotConsoleRunner({ bot }).start();

Create a plugin

import { BotBuilder } from '@telefonica/bot-core';

let plugin = new BotBuilder.Library('notes');

plugin.dialog('builtin.intent.note.create', create);

function create(session: BotBuilder.Session) {
    session.endDialog('Note created');
}

export default plugin;

Future ideas

  • From DB to Knowledge Graph
  • Stream processing
  • Delegate conversation to other bots/people
  • Understand different inputs: images, positions, etc
  • Improve multilanguage support
  • Understand negative sentences
Rufus - es_un - perro
perro - numero_patas - 4

Knowledge Base: RDF, SPARQL

SELECT *
WHERE {
    Rufus es_un ?animal .
    ?animal numero_patas ?patas .
}

- Cuántas patas tiene Rufus?

- 4

STREAM PROCESSING

Sentiment Analysis, Language Classification

questions

Made with Slides.com