Slide 1

Slide 1 text

Building your own chatbots with API.AI & Cloud Functions

Slide 2

Slide 2 text

Serverless with Cloud Functions

Slide 3

Slide 3 text

Chatbots API.AI conversational UX Google Home / Assistant Actions on Google

Slide 4

Slide 4 text

@glaforge @manekinekko Google Assistant — the assistant platform Google Home — the hardware device connecting you to the assistant Assistant SDK — a hardware kit to create your own Home-like devices Agent / chatbot / action — an actual app serving a particular purpose Built-in actions — actions that can be invoked directly from Home / assistant Conversation actions — your own actions, with your own voice Actions SDK — a software SDK for creating actions API.AI — a platform for creating conversational interfaces A bit of vocabulary!

Slide 5

Slide 5 text

@glaforge @manekinekko Assistant world chatbots world Cloud / on-prem business logic Assistant SDK API.AI SDKs API.AI’s integrations API.AI SDKs or REST API API.AI world

Slide 6

Slide 6 text

Chatbots of the past...

Slide 7

Slide 7 text

Bots of today & tomorrow...

Slide 8

Slide 8 text

@glaforge @manekinekko Game changer: ML-powered voice recognition

Slide 9

Slide 9 text

@glaforge @manekinekko Game changer: Natural Language Processing @glaforge @manekinekko

Slide 10

Slide 10 text

The concept Ok Google, let me talk to Cloud Next! Hi, I’ll be your guide to Cloud Next, I can help you explore topics or pick a session to attend. What would you like to know? When is the next Machine Learning talk? Sure! Here’s Cloud Next. Enter Earcon The next session about Machine Learning is “A bot to schedule the agenda of your conference” in room 220 on Thursday at 1:55pm. Is there another topic you’re interested in? Exit Earcon . . .

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Modern chatbot concepts I want to eat some bananas How many of them? INTENT → “eat-something” ENTITY → “banana”

Slide 13

Slide 13 text

Modern chatbot concepts How many calories are there? There are 89 calories in a banana A natural conversation that learns from past exchanges CONTEXT → remember the details of the conversation

Slide 14

Slide 14 text

@glaforge @manekinekko From idea to development

Slide 15

Slide 15 text

@glaforge @manekinekko Your chatbot workflow What to build How to build it How to deliver it Design Develop Deploy

Slide 16

Slide 16 text

Design What to build

Slide 17

Slide 17 text

@glaforge @manekinekko Create your persona 1. List out your core brand attributes What words define the experience you’re shooting for? 2. Correlate to attributes that will define your functional design principles How will those manifest in the design? 3. Define some attributes that you’d want to infuse into the voice, style of writing, and personality of the dialog What personality traits match your strategy? 4. Style guide & “bio sketch” Practical application and maintain consistency for longevity of your experience knowledgeable helpful encouraging data rich recommending proactive geeky eager motivating

Slide 18

Slide 18 text

@glaforge @manekinekko Example style guide INSTEAD OF... IS MORE LIKELY TO SAY... I found Up for that? Does that sound good? Maybe later While you’re at it... what’s going on I did not receive a response if you feel you have reached this message in error please select from one of the following X options to help us serve you better for questions related to... you have entered that was an invalid… we require that you... please try again for faster answers we’re sorry, we are unable to… I did not understand MIGHT SAY THINGS LIKE... so you can keep up to date on, I’ll look it up right now Sure, that’s coming up Right around the corner from… That session’s full, but… You might like lets need can’t because more about help right now one sec stay allows require unable to due to additional regarding assist currently please hold remain WOULD NEVER SAY... @glaforge @manekinekko

Slide 19

Slide 19 text

@glaforge @manekinekko Resources — sample dialogs & checklist 1. Canonical “Happy path” 2. First time experience 3. Tapered experience (return user) 4. Repair 5. Personality questions g.co/dev/ActionsChecklist

Slide 20

Slide 20 text

@glaforge @manekinekko Resources — conversation design guides g.co/dev/ActionsDesign

Slide 21

Slide 21 text

@glaforge @manekinekko Cross-platform tool for building advanced conversational interfaces ListSessions( topics.ComputeEngine); “What Compute Engine talks are there?”

Slide 22

Slide 22 text

#gcfchatbots @glaforge #gcfchatbots @glaforge DEMO API.AI

Slide 23

Slide 23 text

Develop How to build it

Slide 24

Slide 24 text

@glaforge @manekinekko Life of a conversation “Ok Google, talk to Cloud Next” Invoke “Cloud Next” action “Hi! Welcome to Cloud Next...” Speech to Text “The next Machine Learning Session is…” “I want to hear more about Machine Learning” Text to Speech “Sure, here’s Cloux Next” Speech to Text, NLP, Knowledge Graph, ML Ranking, User Profile Text to Speech

Slide 25

Slide 25 text

@glaforge @manekinekko Serverless! @glaforge @manekinekko

Slide 26

Slide 26 text

@glaforge @manekinekko A “serverless platform for building event-based microservices”. Function-as-a-service approach Great fit for event-oriented architectures, supporting 3 kind of triggers: ● Cloud Storage updates ● Cloud Pub/Sub messages ● Direct HTTP calls Cloud Functions

Slide 27

Slide 27 text

@glaforge @manekinekko Cloud Functions Completely serverless & fully managed service ⇒ don’t worry about the ops! Automatic scaling and super-fast ⇒ grows with the success of your project ⇒ cost-effective Open and familiar ⇒ JavaScript / Node.js

Slide 28

Slide 28 text

@glaforge @manekinekko server.js NPM dependencies ● actions-on-google ● node-fetch Export a function with the ApiAiAssistant handling the requests const Assistant = require('actions-on-google').ApiAiAssistant; const fetch = require('node-fetch'); function listTopicsIntent(assistant) { fetch('https://cloudnext.withgoogle.com/api/v1/categories') .then(response => response.text()) .then(text => { let data = JSON.parse(text.split('\n')[1]); let topics = data.categories .filter(cat => cat.name === "Topics"); .children.map(topic => topic.name).join(', ')); assistant.ask(`The topics covered are: ${topics}. What do you want to learn?'`); }); } exports.agent = function(request, response) { var assistant = new Assistant({ request, response }); assistant.handleRequest(listTopicsIntent); };

Slide 29

Slide 29 text

@glaforge @manekinekko Architecture in development

Slide 30

Slide 30 text

@glaforge @manekinekko Architecture in development ngrok

Slide 31

Slide 31 text

@glaforge @manekinekko Fast feedback loop: Ngrok + Functions emulator Google Cloud Functions emulator Ngrok secure internet tunnels to localhost LIVE RELOADING DEBUG IN CHROME

Slide 32

Slide 32 text

#gcfchatbots @glaforge #gcfchatbots @glaforge DEMO Cloud Functions (emulator + ngrok)

Slide 33

Slide 33 text

@glaforge @manekinekko

Slide 34

Slide 34 text

Deploy How to deliver it

Slide 35

Slide 35 text

@glaforge @manekinekko Deploying Cloud Functions In production gcloud beta functions deploy agent \ --trigger-http \ --stage-bucket gs://gcp-next-2017-agent/ Locally functions deploy agent --trigger-http

Slide 36

Slide 36 text

@glaforge @manekinekko Review & approval Web-based portal ● Triggering Information ● Merchandising and information Approvals ● Automatic and manual policy checks ● Turn around in about 1 week

Slide 37

Slide 37 text

@glaforge @manekinekko Discovery Discovery patterns ● Guaranteed invocation ○ “Talk to Cloud Next” ● Discovery Patterns ○ “What’s happening at Next?” Google Home app

Slide 38

Slide 38 text

API.AI integrations Assistant surface area, and many others

Slide 39

Slide 39 text

@glaforge @manekinekko Integrations Actions on Google ● Google Home, Pixel… ● and more to come External integrations ● Slack, Facebook Messenger, ● Twitter, Twilio, Skype, Tropo, ● Telegram, Kik, LINE, Cisco Spark, ● Alexa, Cortana

Slide 40

Slide 40 text

API.AI features

Slide 41

Slide 41 text

Summary

Slide 42

Slide 42 text

@glaforge @manekinekko Key takeaways 1. You can extend the Google Assistant with your custom action 2. Talking with humans is challenging, but API.AI makes it approachable 3. GCP offers a powerful platform for hosting business logic

Slide 43

Slide 43 text

Thank You.