chatbots

51
February 2017 – Seattle JS Meetup Find the content here: http://bit.do/spark-bot Follow me on Twitter and/or tweet at me. @tessamero By Tessa Mero Building Chatbots using JavaScript

Upload: tessa-mero

Post on 12-Apr-2017

69 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Chatbots

February 2017 – Seattle JS MeetupFind the content here: http://bit.do/spark-bot

Follow me on Twitter and/or tweet at me. @tessamero

By Tessa Mero

Building Chatbots using JavaScript

Page 2: Chatbots

2© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

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!

Page 3: Chatbots

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

What You Will Need• Cisco Spark API Account: https://developer.ciscospark.com/• Create Cloud9 Account: http://c9.io• [optional] JSON Viewer: https://

chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh

Page 4: Chatbots

4© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Objective

Page 5: Chatbots

5© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Who is Tessa?

* Developer Evangelist* Teacher* Open Source Contributor* Community Leader* Mother

Page 6: Chatbots

6© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

What are Chat Bots?

Page 7: Chatbots

7© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Clippy!

Page 8: Chatbots

8© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 9: Chatbots

9© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 10: Chatbots

10© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 11: Chatbots

11© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 12: Chatbots

12© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

What are the Benefits?

Page 13: Chatbots

13© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 14: Chatbots

14© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 15: Chatbots

15© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 16: Chatbots

16© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Integrations vs Bots

Page 17: Chatbots

17© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

An integration acts as YOU and can see and do

the things you can do.

Page 18: Chatbots

18© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 19: Chatbots

19© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 20: Chatbots

20© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

A bot appears as another member of the room, but can only see messages

that mention it.

Page 21: Chatbots

21© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Getting Started with a Collaboration API

Page 22: Chatbots

22© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 23: Chatbots

23© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

In this case, we will use Cisco Spark API:https://developer.ciscospark.com/

Then Log In!

Create an Account on the API website

Page 24: Chatbots

24© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

https://web.ciscospark.com/

Create an Account on the Spark website

Page 25: Chatbots

25© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Creating a Chat Bot

Page 26: Chatbots

26© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Click on “My Apps” and Add New (+)

Page 27: Chatbots

27© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Select ”Create a Bot”

Page 28: Chatbots

28© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Add a Bot Image

http://bit.ly/SparkBot-512x512

Page 29: Chatbots

29© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 30: Chatbots

30© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Copy API Access Token

Page 31: Chatbots

31© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Copy API Access Token

Page 32: Chatbots

32© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Deploy a bot on Cloud9

Page 33: Chatbots

33© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

c9.io/signup

Page 34: Chatbots

34© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 35: Chatbots

35© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

A closer look at the Github URL:

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

Page 36: Chatbots

36© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 37: Chatbots

37© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

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

Page 38: Chatbots

38© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Create Variables• Click the ENV button at the bottom right of the Cloud9

Terminal

• Create two variables:NAME VALUE

DEBUG sparkbotSPARK_TOKEN yourtokenkeyhere

Page 39: Chatbots

39© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 40: Chatbots

40© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Make Your Application Public to Share

Page 41: Chatbots

41© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Create Webhook events

Page 42: Chatbots

42© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Page 43: Chatbots

43© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Create Cisco Spark Webhooks

Page 44: Chatbots

44© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

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

Page 45: Chatbots

45© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

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!

Page 46: Chatbots

46© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Test your Cisco Spark Bot

Page 47: Chatbots

47© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Test Bots Response – type /hello

Page 48: Chatbots

48© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Mention your bot in Group rooms

Page 49: Chatbots

49© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Type /hello to test Group chat with bot

Page 50: Chatbots

50© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

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.

Page 51: Chatbots

51© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential

Thank You

@tessamero@auhyland

http://bit.do/spark-bot