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 advanced Chats Bots and Voice Interactive Assistants - Stève Sfartz - Codemotion Rome 2017

630 views

Published on

If it takes minutes to code a simple bot, building professional bots represents quite a challenge. Soon you realize you need serious programming and API architecture experience but also “Bot” specific skills. In this session, we'll first show the code of advanced Chat and Voice interactions, and then explore the challenges faced when building advanced Bots (Context storage, NLP approaches, Bot Metadata, OAuth scopes), and discuss interesting opportunities from latest industry trends (Bot platforms, Serverless, Microservices). This talk is about showing the code and sharing lessons learnt.t

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Building advanced Chats Bots and Voice Interactive Assistants - Stève Sfartz - Codemotion Rome 2017

  1. 1. Building advanced Chat Bots & Voice Interactive Assistants Stève SFARTZ API Evangelist - Cisco DevNet stsfartz@cisco.com, @SteveSfartz, github://ObjectIsadvantag
  2. 2. © 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 stsfartz@cisco.com @SteveSfartz
  3. 3. 3  Zeroto advanced Voice Machines & ChatBots  Demoes & Code samples  +39 069 480 4685,  QuizBot@sparkbot.io  Challenges & Lessons learnt T so what’s on the menu
  4. 4. From Zero to advanced Voice Machines with Tropo
  5. 5. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public What is Tropo ? Cloud APIs enabling developers to quickly and easily embed communication capabilities into their applications and business processes.
  6. 6. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public + • Ask • Call • Conference • Hangup • Record • Reject • Say • Transfer 6 Tropo in a nutshell
  7. 7. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public say("hello world"); 7 Text to Speech
  8. 8. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 8 Play an Audio File say(“http://.../troporocks.mp3");
  9. 9. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Outbound Voice Call call("+14155550100"); say("Tag, you’re it!"); 9
  10. 10. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Send a Text Message call("+14155550100", {network:"SMS"} ); say("Tag, you’re it!"); 1
  11. 11. Asking a Question var 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); 1
  12. 12. Voicemail Application record("Leave your message. Press pound when finished.", { beep:true, timeout:10, silenceTimeout:7, maxTime:60, terminator:'#', recordFormat:"audio/mp3", recordURI:"ftp://.../file.mp3" }); 1
  13. 13. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 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 13
  14. 14. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Globally available Global Outgoing Calls & Messages Numbers in 42 countries 80 speech languages 14
  15. 15. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 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 15
  16. 16. Check upcoming talks via CodeMotion Rome’s Voice Machine +39 069 480 4685
  17. 17. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public CodeMotion Rome Voice Machine IVR = 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…
  18. 18. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public {CodeMotion} Rome Voice Machine 18
  19. 19. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 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 SMS calls Voice Machine script 19
  20. 20. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public IVR script highlights • Forking a new session to send a SMS 20
  21. 21. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Join the Cisco DevNet code labs https://github.com/CiscoDevNet/codemotion-rome-2017
  22. 22. © 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)  a local Emulator to the rescue  run and debug locally  integrate in a CI/CD tool chain Lessons learnt
  23. 23. © 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
  24. 24. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Emulator in practice https://github.com/ObjectIsAdvantag/tropo-ready-vscode
  25. 25. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Best practices: ChatOps Diagnose & follow real time activity “Follow your application usage in real-time”
  26. 26. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Best practices: ChatOps Diagnose & follow real time activity “Follow your application usage in real-time”
  27. 27. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Best practices: ChatOps Diagnose & follow real time activity “Diagnose a Serverless script”
  28. 28. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 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 Machine script Log2Spark library /new logs POST message « ChatOps » Room 1 2 3 28
  29. 29. From Zero to advanced Chat Bots with Cisco Spark
  30. 30. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Cisco Spark Secure & Open Complete & Simple Spark for Developers User Integrations, APIs/SDKs... Spark Hybrid Services Cloud + Prem Partner Services Interconnect Message Meeting Call 1:1 and team messaging Cloud-based phone systemAudio, video, and web meetings 30
  31. 31. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public ‘Your App’ now with Cisco Collab! Spark APIs extend Cisco Collaboration Cloud GET POST DELETE PUT /Rooms /Memberships /Messages /Webhooks /People 31 /Teams https://developer.ciscospark.com/
  32. 32. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 32 Meet the roomId bot • Add roomId@sparkbot.io to a room 1. The bot enters the room 2. Sniffs the room identifier, 3. Posts the identifier in a 1-1 space, 4. And finally leaves the space you originally invited it to join • Check the code https://github.com/CiscoDevNet/node-sparkbot-samples
  33. 33. © 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
  34. 34. © 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 https://github.com/CiscoDevNet/node-sparkbot-samples
  35. 35. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Cisco Spark Cloud Service 1. interacts in spaces via a Cisco Spark client Cisco Spark User Your Bot code running On-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
  36. 36. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Cisco Spark Cloud Service 1. interacts in spaces via a Cisco Spark client Cisco Spark User DMZ 2. posts notifications to registered WebHooks Publicly accessible 3. responds to Webhook events Your Bot code running on-premises Enterprise secured 2b. forwards notifications Bot Architecture: on-premises
  37. 37. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Cisco Spark Cloud Service 1. interacts in Rooms via the various Spark Clients Cisco Spark User Tunneling infrastructure Your Bot code running on 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…
  38. 38. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Bot Contest Sign in on CiscoSpark Meet the Bot quizbot@sparkbot.io Take the challenge Win an iPhone7…
  39. 39. © 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
  40. 40. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 40 @QuizBot help
  41. 41. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public @QuizBot now 41
  42. 42. © 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
  43. 43. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Fallback command 43
  44. 44. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Add conversations to the game 44 https://github.com/ObjectIsAdvantag/devnet-botkit-sample
  45. 45. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public and context storage 45 https://github.com/CiscoDevNet/botkit-ciscospark-samples
  46. 46. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 46 Bot Frameworks survey
  47. 47. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Cisco Spark Bot community frameworks • Flint, https://github.com/flint-bot/flint • BotKit, https://github.com/howdyai/botkit
  48. 48. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Community frameworks for Cisco Spark Flint 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
  49. 49. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Taking our 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 ?
  50. 50. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public @CiscoDevNet /about 50
  51. 51. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Taking your bot to the next stage Is the bot down ?
  52. 52. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 52 Bot Metadata HealthCheck
  53. 53. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 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 53
  54. 54. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Taking your bot to the next stage Hosting • 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
  55. 55. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Google functions pricing 55
  56. 56. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public The Serverless Functions opportunity 56 https://github.com/ObjectIsAdvantag/devnetexpress-bot Remember? a bot is nothing more than a POST endpoint … with an healthcheck !
  57. 57. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public The Serverless Functions opportunity > gcloud alpha functions deploy sparkbot --entry-point googlefunction --stage-bucket objectisadvantag-functions --trigger-http --memory 128MB --timeout 1s 57 https://github.com/ObjectIsAdvantag/devnetexpress-bot
  58. 58. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public The Serverless Functions opportunity • Easy way to remove the Serverless burden 58 https://github.com/ObjectIsAdvantag/devnetexpress-bot
  59. 59. © 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
  60. 60. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Taking your bot to the next stage Machine Learning • The bot: my companion • Learn from interactions • Classify my Twitter Followers • Who’s ready to pay for it ? • Data Privacy vs Real Cost
  61. 61. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Join the Cisco DevNet code labs https://github.com/CiscoDevNet/codemotion-rome-2017
  62. 62. © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public Bot Contest • Sign in on Cisco Spark • Meet the Bot quizbot@sparkbot.io • Take the challenge • Win iPhone7…
  63. 63. © 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 DevNet 11:30: Build advanced Voice Assistants and Chat Bots 14: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
  64. 64. Thank you @CiscoDevNet @CiscoSparkDev @SteveSfartz

×