SlideShare une entreprise Scribd logo
1  sur  30
1
Serverless Chatbots
with PubNub and Conversation
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
Watson / Presentation Title / Date3
Our Expert
Josh Marinacci
Head of Developer Evangelism
PubNub
josh@pubnub.com
Serverless Chatbots
What is Serverless?
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
Introducing PubNub BLOCKS
 Promise based modern JavaScript
 Runs in the network, nearest to user
 Very low latency
 Very high security
 Infinitely Scalable
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
Heart Bot
Demo
9
Heart Bot
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
}
Image
Bot Demo
12
Image Bot
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);
...
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;
}
…
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 Rockbot
Demo
17
Mr Rockbot
18
Watson Alchemy APIs
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
Conversation Service
Create Intents
Create Entities
Create Dialogs
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
Mr Rockbot
26
Lessons Learned
 Use a Serverless Network
 Use stateless AI micro-services
 Store 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/conversatio
n/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 8
Easily Deploy your Chat Bot to Multiple Channels with Stamplay - March 22
30
Thank you for attending!
Contact us
Phone: 1-877-253-0308
Email: wdc-dev@bg.vnet.ibm.com
Online: Watson Developer Cloud

Contenu connexe

Tendances

Infrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStackInfrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStack
ke4qqq
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabric
andymccurdy
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
Wesley Beary
 

Tendances (20)

Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled InfrastructureCloud meets Fog & Puppet A Story of Version Controlled Infrastructure
Cloud meets Fog & Puppet A Story of Version Controlled Infrastructure
 
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
Elasticsearch (R)Evolution — You Know, for Search… by Philipp Krenn at Big Da...
 
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine YardHow I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
How I Learned to Stop Worrying and Love the Cloud - Wesley Beary, Engine Yard
 
Triple Blitz Strike
Triple Blitz StrikeTriple Blitz Strike
Triple Blitz Strike
 
Cyansible
CyansibleCyansible
Cyansible
 
Ansible
AnsibleAnsible
Ansible
 
fog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloudfog or: How I Learned to Stop Worrying and Love the Cloud
fog or: How I Learned to Stop Worrying and Love the Cloud
 
Building Docker images with Puppet
Building Docker images with PuppetBuilding Docker images with Puppet
Building Docker images with Puppet
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
(APP310) Scheduling Using Apache Mesos in the Cloud | AWS re:Invent 2014
(APP310) Scheduling Using Apache Mesos in the Cloud | AWS re:Invent 2014(APP310) Scheduling Using Apache Mesos in the Cloud | AWS re:Invent 2014
(APP310) Scheduling Using Apache Mesos in the Cloud | AWS re:Invent 2014
 
OpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudOpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid Cloud
 
Capistrano, Puppet, and Chef
Capistrano, Puppet, and ChefCapistrano, Puppet, and Chef
Capistrano, Puppet, and Chef
 
Scaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachScaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approach
 
Infrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStackInfrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStack
 
Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019Happy Browser, Happy User! WordSesh 2019
Happy Browser, Happy User! WordSesh 2019
 
Deployment with Fabric
Deployment with FabricDeployment with Fabric
Deployment with Fabric
 
Chef solo the beginning
Chef solo the beginning Chef solo the beginning
Chef solo the beginning
 
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
fog or: How I Learned to Stop Worrying and Love the Cloud (OpenStack Edition)
 
Custom Non-RDS Multi-AZ Mysql Replication
Custom Non-RDS Multi-AZ Mysql ReplicationCustom Non-RDS Multi-AZ Mysql Replication
Custom Non-RDS Multi-AZ Mysql Replication
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 

En vedette

Ibm's watson
Ibm's watsonIbm's watson
Ibm's watson
Hdavey01
 
The MD Anderson / IBM Watson Announcement: What does it mean for machine lear...
The MD Anderson / IBM Watson Announcement: What does it mean for machine lear...The MD Anderson / IBM Watson Announcement: What does it mean for machine lear...
The MD Anderson / IBM Watson Announcement: What does it mean for machine lear...
Health Catalyst
 

En vedette (19)

Application Developer Predictions 2017 - It's All About Cognitive
Application Developer Predictions 2017 - It's All About CognitiveApplication Developer Predictions 2017 - It's All About Cognitive
Application Developer Predictions 2017 - It's All About Cognitive
 
Building with Watson - Advanced Integrations with Watson Conversation
Building with Watson - Advanced Integrations with Watson ConversationBuilding with Watson - Advanced Integrations with Watson Conversation
Building with Watson - Advanced Integrations with Watson Conversation
 
Easily Deploy your Chat Bot to Multiple Channels with Stamplay
Easily Deploy your Chat Bot to Multiple Channels with StamplayEasily Deploy your Chat Bot to Multiple Channels with Stamplay
Easily Deploy your Chat Bot to Multiple Channels with Stamplay
 
IBM Watson Analytics Presentation
IBM Watson Analytics PresentationIBM Watson Analytics Presentation
IBM Watson Analytics Presentation
 
Watson DevCon 2016 - The Flu Fighters: Using IBM Cognitive Computing to Fight...
Watson DevCon 2016 - The Flu Fighters: Using IBM Cognitive Computing to Fight...Watson DevCon 2016 - The Flu Fighters: Using IBM Cognitive Computing to Fight...
Watson DevCon 2016 - The Flu Fighters: Using IBM Cognitive Computing to Fight...
 
Watson DevCon 2016: Myca - My Career Advisor: Providing Individualized Career...
Watson DevCon 2016: Myca - My Career Advisor: Providing Individualized Career...Watson DevCon 2016: Myca - My Career Advisor: Providing Individualized Career...
Watson DevCon 2016: Myca - My Career Advisor: Providing Individualized Career...
 
Refinery Advisor
Refinery Advisor Refinery Advisor
Refinery Advisor
 
Cognitive Overview
Cognitive Overview Cognitive Overview
Cognitive Overview
 
Watson DevCon 2016 - Watson Beat: Making Music Cognitive
Watson DevCon 2016 - Watson Beat: Making Music CognitiveWatson DevCon 2016 - Watson Beat: Making Music Cognitive
Watson DevCon 2016 - Watson Beat: Making Music Cognitive
 
Watson DevCon 2016 - The Future of Discovery: Deep Insights with Cognitive APIs
Watson DevCon 2016 - The Future of Discovery: Deep Insights with Cognitive APIsWatson DevCon 2016 - The Future of Discovery: Deep Insights with Cognitive APIs
Watson DevCon 2016 - The Future of Discovery: Deep Insights with Cognitive APIs
 
Ibm's watson
Ibm's watsonIbm's watson
Ibm's watson
 
Watson DevCon 2016: Why Audience Intelligence Requires a Modular AI Approach
Watson DevCon 2016: Why Audience Intelligence Requires a Modular AI ApproachWatson DevCon 2016: Why Audience Intelligence Requires a Modular AI Approach
Watson DevCon 2016: Why Audience Intelligence Requires a Modular AI Approach
 
Watson DevCon 2016 - From Jeopardy! to the Future
Watson DevCon 2016 - From Jeopardy! to the FutureWatson DevCon 2016 - From Jeopardy! to the Future
Watson DevCon 2016 - From Jeopardy! to the Future
 
Building Cognitive Applications with Watson APIs
Building Cognitive Applications with Watson APIs Building Cognitive Applications with Watson APIs
Building Cognitive Applications with Watson APIs
 
Putting IBM Watson to Work.. Saxena
Putting IBM Watson to Work.. SaxenaPutting IBM Watson to Work.. Saxena
Putting IBM Watson to Work.. Saxena
 
Building with Watson - Training and Preparing Your Conversational System
Building with Watson - Training and Preparing Your Conversational SystemBuilding with Watson - Training and Preparing Your Conversational System
Building with Watson - Training and Preparing Your Conversational System
 
The MD Anderson / IBM Watson Announcement: What does it mean for machine lear...
The MD Anderson / IBM Watson Announcement: What does it mean for machine lear...The MD Anderson / IBM Watson Announcement: What does it mean for machine lear...
The MD Anderson / IBM Watson Announcement: What does it mean for machine lear...
 
What Watson Explorer is and How it works
What Watson Explorer is and How it worksWhat Watson Explorer is and How it works
What Watson Explorer is and How it works
 
Multi tone am | Communication Systems
Multi tone am | Communication SystemsMulti tone am | Communication Systems
Multi tone am | Communication Systems
 

Similaire à Building with Watson - Serverless Chatbots with PubNub and Conversation

Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Getting Started with Couchbase Ruby
Getting Started with Couchbase RubyGetting Started with Couchbase Ruby
Getting Started with Couchbase Ruby
Sergey Avseyev
 

Similaire à Building with Watson - Serverless Chatbots with PubNub and Conversation (20)

Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
A Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to BluemixA Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to Bluemix
 
One-Man Ops
One-Man OpsOne-Man Ops
One-Man Ops
 
Cutting through the fog of cloud
Cutting through the fog of cloudCutting through the fog of cloud
Cutting through the fog of cloud
 
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
 
From Ruby to Node.js
From Ruby to Node.jsFrom Ruby to Node.js
From Ruby to Node.js
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud Foundry
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
 
Real World Lessons on the Pain Points of Node.js Applications
Real World Lessons on the Pain Points of Node.js ApplicationsReal World Lessons on the Pain Points of Node.js Applications
Real World Lessons on the Pain Points of Node.js Applications
 
오픈소스 게임 서버 엔진 스터디 캠프 - CloudBread
오픈소스 게임 서버 엔진 스터디 캠프 - CloudBread오픈소스 게임 서버 엔진 스터디 캠프 - CloudBread
오픈소스 게임 서버 엔진 스터디 캠프 - CloudBread
 
Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
StrongLoop Overview
StrongLoop OverviewStrongLoop Overview
StrongLoop Overview
 
Azure Bootcamp 2016 - Docker Orchestration on Azure with Rancher
Azure Bootcamp 2016 - Docker Orchestration on Azure with RancherAzure Bootcamp 2016 - Docker Orchestration on Azure with Rancher
Azure Bootcamp 2016 - Docker Orchestration on Azure with Rancher
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Bare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and ChefBare Metal to OpenStack with Razor and Chef
Bare Metal to OpenStack with Razor and Chef
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
Getting Started with Couchbase Ruby
Getting Started with Couchbase RubyGetting Started with Couchbase Ruby
Getting Started with Couchbase Ruby
 
Scaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container ServiceScaling Docker Containers using Kubernetes and Azure Container Service
Scaling Docker Containers using Kubernetes and Azure Container Service
 

Plus de IBM Watson

Plus de IBM Watson (19)

Watson Equipment Advisor
Watson Equipment Advisor Watson Equipment Advisor
Watson Equipment Advisor
 
Cognitive Reservoir Analytics
Cognitive Reservoir Analytics Cognitive Reservoir Analytics
Cognitive Reservoir Analytics
 
Watson DevCon 2016 - Do More with Less Code: Enriched Communications with Twi...
Watson DevCon 2016 - Do More with Less Code: Enriched Communications with Twi...Watson DevCon 2016 - Do More with Less Code: Enriched Communications with Twi...
Watson DevCon 2016 - Do More with Less Code: Enriched Communications with Twi...
 
Watson DevCon 2016 - Engage and Be Engaging: Building Compassionate and Perso...
Watson DevCon 2016 - Engage and Be Engaging: Building Compassionate and Perso...Watson DevCon 2016 - Engage and Be Engaging: Building Compassionate and Perso...
Watson DevCon 2016 - Engage and Be Engaging: Building Compassionate and Perso...
 
Get More From Your Messages with Twilio + Watson Add-Ons
Get More From Your Messages with Twilio + Watson Add-OnsGet More From Your Messages with Twilio + Watson Add-Ons
Get More From Your Messages with Twilio + Watson Add-Ons
 
5 Reasons to Attend the Upcoming Watson Developer Conference
5 Reasons to Attend the Upcoming Watson Developer Conference5 Reasons to Attend the Upcoming Watson Developer Conference
5 Reasons to Attend the Upcoming Watson Developer Conference
 
Application Starter Kits for Developers - Building with Watson
Application Starter Kits for Developers - Building with WatsonApplication Starter Kits for Developers - Building with Watson
Application Starter Kits for Developers - Building with Watson
 
Cognitive Business: Where digital business meets digital intelligence
Cognitive Business: Where digital business meets digital intelligenceCognitive Business: Where digital business meets digital intelligence
Cognitive Business: Where digital business meets digital intelligence
 
What Does It Mean To Be A Cognitive Company
What Does It Mean To Be  A Cognitive CompanyWhat Does It Mean To Be  A Cognitive Company
What Does It Mean To Be A Cognitive Company
 
Custom Image Classifier with Visual Recognition: Building with Watson
Custom Image Classifier with Visual Recognition: Building with Watson Custom Image Classifier with Visual Recognition: Building with Watson
Custom Image Classifier with Visual Recognition: Building with Watson
 
Leading in the Cognitive Age
Leading in the Cognitive AgeLeading in the Cognitive Age
Leading in the Cognitive Age
 
Applications for Cognitive Computing
Applications for Cognitive Computing Applications for Cognitive Computing
Applications for Cognitive Computing
 
How is Watson Changing the Future of the Automative Industry?
How is Watson Changing the Future of the Automative Industry?How is Watson Changing the Future of the Automative Industry?
How is Watson Changing the Future of the Automative Industry?
 
Building with Watson - Conversational Apps: What We've Learned and Where We'r...
Building with Watson - Conversational Apps: What We've Learned and Where We'r...Building with Watson - Conversational Apps: What We've Learned and Where We'r...
Building with Watson - Conversational Apps: What We've Learned and Where We'r...
 
Building with Watson: Watson Developer Certification Program
Building with Watson: Watson Developer Certification ProgramBuilding with Watson: Watson Developer Certification Program
Building with Watson: Watson Developer Certification Program
 
Innovation and Inspiration through Cognitive Computing: IBM Watson
Innovation and Inspiration through Cognitive Computing: IBM WatsonInnovation and Inspiration through Cognitive Computing: IBM Watson
Innovation and Inspiration through Cognitive Computing: IBM Watson
 
Building with Watson - Enhancing the Results of Your BI Dashboard
Building with Watson - Enhancing the Results of Your BI DashboardBuilding with Watson - Enhancing the Results of Your BI Dashboard
Building with Watson - Enhancing the Results of Your BI Dashboard
 
Transforming Business with Cognitive APIs: What Innovative Business Strategie...
Transforming Business with Cognitive APIs: What Innovative Business Strategie...Transforming Business with Cognitive APIs: What Innovative Business Strategie...
Transforming Business with Cognitive APIs: What Innovative Business Strategie...
 
Deploying Your Application on Bluemix in 4 Easy Steps
Deploying Your Application on Bluemix in 4 Easy StepsDeploying Your Application on Bluemix in 4 Easy Steps
Deploying Your Application on Bluemix in 4 Easy Steps
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Building with Watson - Serverless Chatbots with PubNub and Conversation

  • 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. Watson / Presentation Title / Date3 Our Expert Josh Marinacci Head of Developer Evangelism PubNub josh@pubnub.com
  • 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 Introducing PubNub BLOCKS  Promise based modern JavaScript  Runs in the network, nearest to user  Very low latency  Very high security  Infinitely Scalable
  • 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
  • 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 }
  • 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. 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. 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(); });
  • 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); });
  • 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(); }); }); });
  • 26. 26 Lessons Learned  Use a Serverless Network  Use stateless AI micro-services  Store context in the network, near the users
  • 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 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 Thank you for attending! Contact us Phone: 1-877-253-0308 Email: wdc-dev@bg.vnet.ibm.com Online: Watson Developer Cloud

Notes de l'éditeur

  1. these were all built with a serverless platform this is a serverless platform, not a cloud provider. the different is that you aren't provisioining a server, even a virtual one. there is no administration. you are working at the level of functions that you put into the network. also, you aren't just switching one providers cloud server for another. this code runs in the network. it's more like a CDN. the message goes from the phone to some place on the edge. it goes to whatever part of the network is closest to the end user. of course there are real servers somewhere, but it's serverless because there isn't one server or even a group of servers. underneath is computing infrastructure around the globe acting as a single unit, always putting computation as close as possible to the end user for the lowest latency and greatest security. the serverless provider then talks to an service for the AI. it may also talk to other services for other parts of the chatbot. the important thing is that provider in the middle has the controlling computation and stores all the state. Each of these providers are simple microservices that do one thing well and are as stateless as possible, making them easier to build and more reliable. Further more, as your chatbot becomes more popular which we hope it well, you don't have to worry about scaling. the infrastructure scales for you. Most of the providers in this space have usage based pricing so your costs only go up when your revenue does. No cliffs to worry about. Scaling becomes a non-issue, so you can focus on what you are trying to actually do.
  2. When you make a chatbot you need some sort of realtime infrastructure. A chatbot involves constant communication between the end user and your bot, possibly with other platform proxies in the way, and possibly with other webservices which provide the knowledge or actions that the chatbot needs. So you need some realtime infrastructure to tie all this together with very low latency and high security. The other thing you need is some level of Artificial Intelligence. Some chatbots need full natural language processing. some need a backend end with a rich neural net. Some just need a glorified phone tree. It really depends on what you are doing.
  3. so today I'm going to show you how to build a simple chatbot we are going to use serverless infrastructure and some 3rd party services. But before we get into how to build them. let me show them to you.
  4. Okay. all of these were built with the same basic architecture. The client, which can be a phone or webpage or really anything, talks to the realtime network provider. In this case PubNub. For the Emoji demo all of the computation is done in the network's serverless compute system called PubNub BLOCKS.
  5. so today I'm going to show you how to build a simple chatbot we are going to use serverless infrastructure and some 3rd party services. But before we get into how to build them. let me show them to you.
  6. The cloudinary image chat demo used a simple natrual language parser implemented as JavaScript running in a BLOCK. Then it hands it off to cloudinary to do the image processing. the important thing here is that the network and the computation is as close as possible to the end user. if the user is here, then it uses a compute node near them if over here, then uses one over here. this network spans the globe so it's also as close as possible to the user. when it communicates between users or to a 3rd party service then it can route to wherever is closest.
  7. so today I'm going to show you how to build a simple chatbot we are going to use serverless infrastructure and some 3rd party services. But before we get into how to build them. let me show them to you.
  8. Now here's the Mr Rockbot diagram again.
  9. Mr rockbot is the most complicated because he uses several services. In my original version I used IBM Alchemy language API to look at the input text. it pulls out entities and intents. Unfortunately this API is really meant for looking at larger documents, not tiny snippets of text.
  10. However, IBM recently introduced a new api specifically for conversational interactions called, appropriately enough: Conversations. It was originally called the Dialog Service, so you might see some tutorials with that name. With Conversations you actually train the system by giving it examples of the kinds of things you are looking for.
  11. First you create 'intents.' These are the things the user could ask the chatbot to do for it. For example, if this was a home automation bot you might use an intent like 'turn on'.
  12. Next you create entities. These are things the user could ask about, or are the target of an intent. For example: in a home automation bot you might use an entity like 'lights' or 'door'. You can also specify synonyms so that it can recognize many forms of the request.
  13. Finally you can create dialogs. These are workflows that the user can go through. This lets you specify what the bot actually says to the end user in different circumstances. If you arlready have a knowledgebase of facts and responses then you can skip this part and just use the intents and entities.
  14. After you teach Watson about your problem domain you can call it from your serverless code using a simple HTTP POST. It's important to note that Conversations is a stateless API. In order to understand the context of a conversation you have to provide this context on each request using a context structure. I'm storing this in the serverless platform. But remember that this code will always be run on the edge nearest to the end user, and that user might move. So i store this context in our Key Value store which is eventually consistent. If the user moves to another part of the network the context will follow them.
  15. Now here's the Mr Rockbot diagram again.