rome 2017: building advanced voice assistants and chat bots

65
uilding advanced Chat Bots & Voice Interactive Assistants Stève SFARTZ API Evangelist - Cisco DevNet [email protected], @SteveSfartz, github://ObjectIsadvantag

Upload: cisco-devnet

Post on 11-Apr-2017

207 views

Category:

Technology


6 download

TRANSCRIPT

Page 1: Rome 2017: Building advanced voice assistants and chat bots

Building advanced Chat Bots & Voice Interactive Assistants

Stève SFARTZAPI Evangelist - Cisco [email protected], @SteveSfartz, github://ObjectIsadvantag

Page 2: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

/Cisco/DevNet/SteveSfartz

• API Evangelist @CiscoDevNet• Cisco Spark Apps & Tropo APIs • code addict, nodejs, love story

with #golang• France and all around Europe• hosted @PIRL – Paris Innovation

Center & Research Lab• twitter://@SteveSfartz• github://ObjectIsAdvantag

“vision without execution is

hallucination”

-- Thomas Edison

[email protected]@SteveSfartz

Page 3: Rome 2017: Building advanced voice assistants and chat bots

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Public 3

Zero to advanced Voice Machines, ChatBots

Demoes & code samples +39-069-480-4685, [email protected]

Challenges & Lessons learntT

so what’s on the menu

Page 4: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

From Zero to advanced Voice Machines with Tropo

4

Page 5: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

What is Tropo ?

5

Cloud APIs enabling developers to quickly and easily embed communication capabilities into their applications and business processes.

Page 6: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 6

+• Ask

• Call

• Conference

• Hangup

• Record

• Reject

• Say

• Transfer

Tropo in a nutshell

Page 7: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 7

say("hello world");

Text to Speech

Page 8: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 8

Play an Audio File

say(“http://.../troporocks.mp3");

Page 9: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public9

Outbound Voice Call

call("+14155550100");say("Tag, you’re it!");

Page 10: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public10

Send a Text Message

call("+14155550100", {network:"SMS"});say("Tag, you’re it!");

Page 11: Rome 2017: Building advanced voice assistants and chat bots

11

Asking a Questionvar result = ask("What's your favorite color? Choose red, blue or green.", { choices:"red, blue, green"});say("You said " + result.value);log("They said " + result.value);

Page 12: Rome 2017: Building advanced voice assistants and chat bots

12

Voicemail Applicationrecord("Leave your message. Press pound when finished.", { beep:true, timeout:10, silenceTimeout:7, maxTime:60, terminator:'#', recordFormat:"audio/mp3", recordURI:"ftp://.../file.mp3" });

Page 13: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 13

How to setup your own Voice Machine

• Signup at http://tropo.com

• Create a new Scripting app

• Point to an IVR script: http://bit.ly/TROPO-IVR

• Pick a phone number

• Save the application

Page 14: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 14

Globally availableGlobal Outgoing Calls & MessagesNumbers in 42 countries80 speech languages

Page 15: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 15

Account Types

• Free• Low-volume• Restricted use• No production

usage• 24x7 support

Developer

• Pre-paid• Credit Card• Self-service

signup• Shared Cloud• one minute

billing increments

Production

Page 16: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Check upcoming talksvia CodeMotion Rome’s

Voice Machine

+39 069 480 468516

Page 17: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

CodeMotion Rome Voice MachineIVR = Interactive Voice Responder

• Call +39 069 480 4685 and listen…

• Dial 1 to receive more details by SMS, 2 for next• Check a session details on your mobile phone• Text your email to the caller /!\ you’re texting US !!! • Launch CiscoSpark, and meet the bot…

17

Page 18: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 18

{CodeMotion} Rome Voice Machine

Page 19: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 19

How to setup a custom IVR• The IVR is composed of :

• a local phone number • a custom script executed by the Tropo Scripting platform

dials #1

+39 069 480 4685« Welcome »

details via SMScalls

Voice Machinescript

Page 20: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 20

IVR script highlights

• Forking a new session to send a SMS

Page 21: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Join the Cisco DevNet code labshttps://github.com/CiscoDevNet/codemotion-rome-2017

Page 22: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Serverless is great• no deployment hurdles, scalability from day 1

… but • tedious dev cycles (commit, push, test)• painful to diagnose (read logs through)

Þ local emulators to the rescue run and debug locally integrate in a CI/CD tool chain

Lessons learnt

Page 23: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Tropo Ready!

• Tropo Ready!

• + URL to the project

• Browse the project

https://github.com/ObjectIsAdvantag/tropo-ready-vscode

Page 24: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Tropo Emulator in practicehttps://github.com/ObjectIsAdvantag/tropo-ready-vscode

Page 25: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Best practices: ChatOpsDiagnose & follow real time activity

“Follow your application usage in

real-time”

Page 26: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Best practices: ChatOpsDiagnose & follow real time activity

“Follow your application usage in

real-time”

Page 27: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Best practices: ChatOpsDiagnose & follow real time activity

“Diagnose a Serverless script”

Page 28: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 28

How to setup ChatOps

To stream logs and get instant view about your Voice Machine activity:

1. Create a ChatOps room

2. Add an Incoming Webhook

3. Post messages

Voice Machinescript

Log2Sparklibrary

/newlogs

POSTmessage

« ChatOps »Room

12

3

Page 29: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

From Zero to advanced Chat Bots with Cisco Spark

29

Page 30: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 30

Cisco Spark

Secure & Open

Complete & Simple

Spark for DevelopersUser Integrations, APIs/SDKs...

Spark Hybrid ServicesCloud + Prem

Partner ServicesInterconnect

Message Meeting Call1:1 and team messaging Cloud-based phone systemAudio, video, and web meetings

Page 31: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 31

‘Your App’ now with

Cisco Collab!

Spark APIs extend Cisco Collaboration Cloud

GET

POST

DELETE

PUT/Rooms

/Memberships

/Messages

/Webhooks

/People

/Teams

https://developer.ciscospark.com/

Page 32: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 32

Meet the roomId bot

• Add [email protected] to a room

1. The bot sniffs room identifier,

2. Posts the identifier in a 1-1 space,

3. And finally leaves the space you originally invited it to join

https://github.com/CiscoDevNet/node-sparkbot-samples

Page 33: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

• nothing more than an API responding to events

• a few lines of code with a Bot framework

What it takes to build a Chat Bot

33

Page 34: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Run a bot sample

• Leverages the node-sparkbot framework• aimed at Cisco Spark bot education • https://github.com/CiscoDevNet/node-sparkbot

• Community frameworks• Flint: https://github.com/flint-bot/flint • BotKit: https://github.com/howdyai/botkit

34

https://github.com/CiscoDevNet/node-sparkbot-samples

Page 35: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Cisco Spark Cloud Service

1. interacts in spacesvia a Cisco Spark client

Cisco Spark User

Your Bot code runningOn-premise or on a Public Coud

2. posts notifications to registered WebHooks

Publicly accessible APIs

3. posts messages as notifications fly in

Bot Architecture

Register WebHook events your bot is interested to listened to Messages /

created Memberships /

created

As events happen in spaces, receive notifications from Cisco Spark

Page 36: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Cisco Spark Cloud Service

1. interacts in spacesvia a Cisco Spark client

Cisco Spark User

DMZ

2. posts notifications to registered WebHooks

Publicly accessible

3. responds to Webhook events

Your Bot code runningon-premises

Enterprise secured

2b. forwards notifications

Bot Architecture: on-premises

Page 37: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Cisco Spark Cloud Service

1. interacts in Roomsvia the various Spark Clients

Cisco Spark User

Tunneling infrastructure

Your Bot code runningon your local machine

2. posts notifications to registered WebHooks

Dev environmentPublicly accessible

2b. forwards Webhook events

3. responds to Webhook events

Bot Architecture: dev machine

ngrok, localtunnel…

Page 38: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 38

Bot Contest

Sign in on CiscoSpark

Meet the [email protected]

Take the challenge

Win an iPhone7…

Page 39: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Meet the QuizBot

39

https://github.com/LucaCalabrese/codemotion-spark-bot Java, AWS, PostGreSQL, WebHooks @LukeCalab

Page 40: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 40

@QuizBot help

Page 41: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

@QuizBot now

41

Page 42: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Enhance the User Experience

• Help command• better show at the invite, welcome message• But how much help do the bot really

provide?• /hlp • Help• #help• HELP!!!

Þ Fallback command

Page 43: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Fallback command

43

Page 44: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 44

Add conversations to the game…https://github.com/ObjectIsAdvantag/devnet-botkit-sample

Page 45: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 45

…and context storagehttps://github.com/CiscoDevNet/botkit-ciscospark-samples

Page 46: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 46

Bot Frameworks survey

Page 47: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Bot community frameworks

• Flint, https://github.com/flint-bot/flint

• BotKit, https://github.com/howdyai/botkit

Page 48: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Community frameworks for Cisco SparkFlint

First Bot framework for Cisco Spark

Highly tuned for the Cisco Spark API (webhooks events, moderation…)

Basic Key/Value data store

Coding best practices (ES6, exception handling, logs, retries, rate limitation)

BotKit

Largest community Bot framework

Cross platform support with code reuse (no magic convert button: events name, message formatting)

Advanced Key/Value data store (user / space level)

Powerful conversational paradigm

https://github.com/flint-bot/flint https://github.com/howdyai/botkit

Page 49: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 49

Taking bots to the next stage

Page 50: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Taking bots to the next stage

• But who created the bot ?• What is the usage policy ?• How can I contact support, send feedback ?• What about my data privacy ?

Page 51: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 51

@CiscoDevNet /about

Page 52: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Taking bots to the next stage

Is the bot down ?

Page 53: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 53

Bot MetadataHealthCheck

Page 54: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 54

Is the bot down ? a proposal

• Register the Bot in a Universal Database• Chat services supported• Healthcheck endpoints• Author, Policies• Metadata again…

• chatbot.land domain reserved• who’s in ? twitter://@SteveSfartz

Page 55: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Taking bots to the next stageHosting

• Many options: IaaS, Containers, PaaS• Concerns: Availability, Scalability,

Security, Rate Limitation• Pricing balance: who’s willing to pay for

the bot, and how much• Heroku PaaS Free Dynos• AWS/Google/Microsoft free plans• Currently testing Serverless Functions

Page 56: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 56

Google Functions pricing

Page 57: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 57

The Serverless Functions opportunityhttps://github.com/ObjectIsAdvantag/devnetexpress-bot

Remember? a bot is nothing more than a POST endpoint …with an healthcheck !

Page 58: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 58

The Serverless Functions opportunity

> gcloud alpha functions deploy sparkbot --entry-point googlefunction --stage-bucket objectisadvantag-functions --trigger-http --memory 128MB --timeout 1s

https://github.com/ObjectIsAdvantag/devnetexpress-bot

Page 59: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 59

The Serverless Functions opportunity

• An easy way to remove the Serverless burden

https://github.com/ObjectIsAdvantag/devnetexpress-bot

Page 60: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Taking bots to the next stage

• Pick Bots coding best practices & frameworks• Exception management, Retries• Help, Fallback command, Healthcheck• Conversations (test is challenging)

• Choose the best hosting approach • Monitor your bot activity

• Chatops + Analytics

• Think twice before going to NLP and then choose the best approach (local vs 3rd party)

https://devnetcreate.io/2017 Nick Marus’s Talk

• Hosting• Security• Rate limitation

Page 61: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Taking bots to the next stageMachine Learning

• The bot companion learns from interactions

• Use case: classify my Twitter Followers

• Who’s ready to pay for it ?• Data Privacy vs Real Cost

Page 62: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Join the Cisco DevNet code labshttps://github.com/CiscoDevNet/codemotion-rome-2017

Page 63: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 63

Bot Contest

• Sign in on Cisco Spark

• Meet the [email protected]

• Take the challenge• Win iPhone7…

Page 64: Rome 2017: Building advanced voice assistants and chat bots

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

Meet Cisco at CodeMotion Rome

March 24th 9:40: It's all about Developers, discover Cisco DevNet11:30: Build advanced Voice Assistants and Chat Bots14:10: How to embed Video Calls and Messaging without being a Media, WebRTC, XMPP or SIP expert

All day: Learn by taking a code lab with proctors

March 25th

11:30: Microservices and containers networking: Contiv, an industry leading open source solution from Cisco

https://github.com/CiscoDevNet/codemotion-rome-2017

Page 65: Rome 2017: Building advanced voice assistants and chat bots

Thank you

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 65

@CiscoDevNet@CiscoSparkDev@SteveSfartz