Chatbots

181 views

Published on

Building chat bots at the Seattle JS Meetup

Published in: Technology
  • Be the first to comment

Chatbots

  1. 1. Find the content here: http://bit.do/spark-bot Find the slides here: http://tiny.cc/sparkbot Follow me on Twitter and/or tweet at me. @tessamero By Tessa Mero Building Chatbots with JavaScript
  2. 2. SUMMARY • Who Am I? • What Are Chat Bots? • What are the Benefits? • Integrations vs Bots • Getting Started with a Collaboration API • Create a Chat Bot • Using Cloud9 (c9.io) • Create Webhook Events • Test Your Bot!
  3. 3. What You Will Need • Cisco Spark API Account: https://developer.ciscospark.com/ • Create Cloud9 Account: http://c9.io • JSON Viewer: http://tiny.cc/json-viewer • C9 Alternative (local tunnels): Localtunnel.me or ngrok.com
  4. 4. Objective
  5. 5. Who is Tessa? * Developer Evangelist * Teacher * Open Source Contributor * Community Leader * Mother
  6. 6. What are Chat Bots?
  7. 7. Clippy!
  8. 8. What are the Benefits?
  9. 9. Integrations vs Bots
  10. 10. An integration acts as YOU and can see and do the things you can do.
  11. 11. A bot appears as another member of the room, but can only see messages that mention it.
  12. 12. Getting Started with a Collaboration API
  13. 13. In this case, we will use Cisco Spark API: https://developer.ciscospark.com/ Then Log In! Create an Account on the API website
  14. 14. https://web.ciscospark.com/ Create an Account on the Spark website
  15. 15. Creating a Chat Bot
  16. 16. Click on “My Apps” and Add New (+)
  17. 17. Select ”Create a Bot”
  18. 18. Add a Bot Image http://bit.ly/sparkicon
  19. 19. Copy API Access Token
  20. 20. Add Your Bot into a Chat Room
  21. 21. Deploy a bot on Cloud9
  22. 22. c9.io/signup
  23. 23. A closer look at the Github URL: https://github.com/CiscoDevNet/node- sparkbot-samples
  24. 24. Install Node.js in Cloud9
  25. 25. Install Node.js in Cloud9 • In Cloud9, look at the shell terminal at the bottom. • Type: “npm install” – The nodejs libraries used by our code sample get downloaded to your Cloud9 Workspace • Now go to helloworld.js under “examples” • Click “Run” at the top
  26. 26. helloworld.js
  27. 27. Create Variables • Click the ENV button at the bottom right of the Cloud9 Terminal • Create two variables: NAME VALUE DEBUG sparkbot SPARK_TOKEN yourtokenkeyhere
  28. 28. Variables!
  29. 29. Make Your Application Public to Share
  30. 30. Create Webhook events
  31. 31. Create Cisco Spark Webhooks https://developer.ciscospark.com/endpoint-webhooks-post.html
  32. 32. Create Cisco Spark Webhooks
  33. 33. 200 Success! • Click “Run” • See a “200/success” displayed – webhook assigned to unique identifier • Fired off every time a new message is added to a room your bot is a member of
  34. 34. Create Another Webhook • Receive an event every time our bot is added to a room • Modify “resource” field: replace “messages” with “memberships” • Click “Run” again • See a ”200 / success” message!
  35. 35. Test your Cisco Spark Bot
  36. 36. Test Bots Response – type /hello
  37. 37. Mention your bot in Group rooms
  38. 38. Type /hello to test Group chat with bot
  39. 39. Go Further? • Add a few breakpoints in helloworld.js, restart in debug mode • Add some commands. Find samples here: https://github.com/CiscoDevNet/node-sparkbot-samples • Note: Lots of nodejs bot frameworks exist for Cisco Spark, from basic to advanced in various languages.
  40. 40. Thank You @tessamero Learning Lab: http://bit.do/spark-bot Slides: http://tiny.cc/sparkbot

×