Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building with Watson - Serverless Chatbots with PubNub and Conversation

590 views

Published on

PubNub helps you manage your streaming data, and now it is easy to add Watson-powered machine intelligence to those streams with BLOCKS. In this Building with Watson webinar, Josh Marinacci, Head of Developer Relations at PubNub, demonstrates how he used the Watson Conversation PubNub BLOCK to build a geology themed chatbot, Mr. Rockbot.

Published in: Technology
  • Be the first to comment

Building with Watson - Serverless Chatbots with PubNub and Conversation

  1. 1. 1 Serverless Chatbots with PubNub and Conversation
  2. 2. 2 Housekeeping Items  Webinar slides, live recording and Q&A will be emailed  Ask questions at any time during the presentation  Use chat window on the webinar panel  We're on Twitter: @IBMWatson #BuildingWithWatson
  3. 3. Watson / Presentation Title / Date3 Our Expert Josh Marinacci Head of Developer Evangelism PubNub josh@pubnub.com
  4. 4. Serverless Chatbots What is Serverless?
  5. 5. 5 What does Serverless Mean  Program functions, not apps or servers.  CDN for computation, in the network, near the user.  Acts as a single computer  Talks to 3rd party micro-services  Infinitely Scalable
  6. 6. 6 Introducing PubNub BLOCKS  Promise based modern JavaScript  Runs in the network, nearest to user  Very low latency  Very high security  Infinitely Scalable
  7. 7. 7 Chatbot Requirements  Realtime Infrastructure  Some level of Artificial Intelligence  Domain specific knowledge But remember...  Requirements, not focus So...  Don’t build your own Realtime Infrastructure  Don’t build your own Artificial Intelligence
  8. 8. Heart Bot Demo
  9. 9. 9 Heart Bot
  10. 10. 10 Aggregation query export default (request) => { var txt = request.message.text; txt = txt.replace(/poop/g,"uD83DuDCA9"); txt = txt.replace(/crap/g,"uD83DuDCA9"); txt = txt.replace(/love/g,"uD83DuDE0D"); txt = txt.replace(/heart/g,"uD83DuDC9C"); txt = txt.replace(/sad/g,"uD83DuDE1E"); txt = txt.replace(/happy/g,"uD83DuDE04"); 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 }
  11. 11. Image Bot Demo
  12. 12. 12 Image Bot
  13. 13. Parse Text var 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); ...
  14. 14. Process Command return 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; } …
  15. 15. 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(); });
  16. 16. Mr Rockbot Demo
  17. 17. 17 Mr Rockbot
  18. 18. 18 Watson Alchemy APIs
  19. 19. Check Language const 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. 20. 20 Conversation Service
  21. 21. Create Intents
  22. 22. Create Entities
  23. 23. Create Dialogs
  24. 24. Process Dialog var 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. 25. 25 Mr Rockbot
  26. 26. 26 Lessons Learned  Use a Serverless Network  Use stateless AI micro-services  Store context in the network, near the users
  27. 27. 27 Q&A
  28. 28. 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/conversatio n/index.html
  29. 29. 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 8 Easily Deploy your Chat Bot to Multiple Channels with Stamplay - March 22
  30. 30. 30 Thank you for attending! Contact us Phone: 1-877-253-0308 Email: wdc-dev@bg.vnet.ibm.com Online: Watson Developer Cloud

×