building with watson - serverless chatbots with pubnub and conversation
TRANSCRIPT
1
Serverless Chatbotswith PubNub and Conversation
2
Housekeeping ItemsWebinar slides, live recording and Q&A will be
emailedAsk questions at any time during the presentation Use chat window on the webinar panel We're on Twitter: @IBMWatson
#BuildingWithWatson
Serverless Chatbots
What is Serverless?
5
What does Serverless MeanProgram functions, not apps or servers.CDN for computation, in the network, near the
user.Acts as a single computerTalks to 3rd party micro-services Infinitely Scalable
6
Introducing PubNub BLOCKSPromise based modern JavaScriptRuns in the network, nearest to userVery low latencyVery high security Infinitely Scalable
7
Chatbot RequirementsRealtime InfrastructureSome level of Artificial IntelligenceDomain specific knowledge
But remember...Requirements, not focus
So... Don’t build your own Realtime InfrastructureDon’t build your own Artificial Intelligence
Heart Bot
Demo
9
Heart Bot
10
Aggregation queryexport default (request) => { var txt = request.message.text; txt = txt.replace(/poop/g,"\uD83D\uDCA9"); txt = txt.replace(/crap/g,"\uD83D\uDCA9"); txt = txt.replace(/love/g,"\uD83D\uDE0D"); txt = txt.replace(/heart/g,"\uD83D\uDC9C"); txt = txt.replace(/sad/g,"\uD83D\uDE1E"); txt = txt.replace(/happy/g,"\uD83D\uDE04");
request.message.text = "Your message isn't hearty enough!" +" There I fixed it: <br/>" + txt; return request.ok(); // Return a promise when you're done}
Image Bot
Demo
12
Image Bot
Parse Textvar words = text.split(" ") .map((w)=>w.toLowerCase()) .filter((w)=>{ if(w === 'the')return false; if(w === 'to') return false;… return true; });if(!words.includes("please")) return false;var n = words.findIndex((w) => w === 'please');var verb = words[n+1];if(verb === 'upload') return upload(words);if(verb === 'display') return display(rest);if(verb === 'show') return show(rest);if(verb === 'resize') return resize(rest);...
Process Commandreturn db.get('context').then((context) => { if(!context) context = {}; var command = request.message; if(command.action === 'resize')
context.width = command.size; if(command.action === 'crop') { context.crop = true; context.shape = 'square'; context.gravity = command.gravity; } …
Generate Cloudinary URL let apiUrl = 'http://res.cloudinary.com/' + cloudName + '/' + resource + '/' + operation + '/'; apiUrl += filename + '.' + context.format;
request.message.cloudinaryURL = apiUrl;
db.set('context',context); return request.ok();});
Mr RockbotDemo
17
Mr Rockbot
18
Watson Alchemy APIs
Check Languageconst query_params = { outputMode:'json', apikey:'494a8df6f920d85b1de4a8172c21dbc264d6446f', extract:'keywords,relations,language', maxRetrieve: 1, text:request.message.text};var url = "http://gateway-a.watsonplatform.net/calls/text/TextGetCombinedData?" +query.stringify(query_params);
return xhr.fetch(url).then((x)=>{ var ret = JSON.parse(x.body); if(ret.language != 'english') { return translateMessage(request.message, ret.language); } return cookMessage(ret);});
20
Conversation Service
Create Intents
Create Entities
Create Dialogs
Process Dialogvar url = creds.url+'/v1/workspaces/'+creds.workspaceID+'/message?version=2016-09-20';
var payload = { input: { text: request.message.text } }
return kvstore.get("context").then((ctx) => { if(ctx) payload.context = ctx;
const http_options = { method:'POST', body: JSON.stringify(payload) }
return xhr.fetch(url, http_options).then((x)=>{ var body = JSON.parse(x.body); return kvstore.set("context",body.context).then(()=>{ request.message.text = body.output.text[0]; request.message.watson = body; return request.ok(); }); });});
25
Mr Rockbot
26
Lessons LearnedUse a Serverless NetworkUse stateless AI micro-servicesStore context in the network, near the users
27
Q&A
28
Are you ready to get started? BLOCKS Catalog:https://www.pubnub.com/blocks-catalog/
Conversation API BLOCK:https://www.pubnub.com/blocks-catalog/pubnub-tutoring-bot/
Conversation Documentation:https://www.ibm.com/watson/developercloud/doc/conversation/index.html
29
What’s next? Look out for a follow up email with a copy of these slides, a recording of
the webinar, Q&A recap, and additional resources
The series will continue bi-weekly on Wednesdays @ 1pm ET / 10am PT
Advanced Audio Transcription with Watson Speech-to-Text - March 8Easily Deploy your Chat Bot to Multiple Channels with Stamplay -
March 22
30
Thank you for attending!
Contact usPhone: 1-877-253-0308
Email: [email protected]: Watson Developer Cloud