devnet 1056 wit spark api and chat bot workshop

120

Upload: tessa-mero

Post on 20-Mar-2017

160 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: DevNet 1056 WIT Spark API and Chat Bot Workshop
Page 2: DevNet 1056 WIT Spark API and Chat Bot Workshop

Intro to Sparkan introduction to REST APIs and Creating Spark Bots

Adrienne Moherek and Tessa MeroDEVNET-1056

Page 3: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

• REST API Basics:• What is an API?• Why APIs?• How does it work?

• Tour of Cisco Spark API• Interactive Documentation Hands-on• Postman Hands-on• Python examples

Agenda Part 1 (REST Basics and Spark)

DEVNET-1056

Page 4: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

• 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!

Agenda Part 2 (Build a Spark Bot)

DEVNET-1056 4

Page 5: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Who Are We?

DEVNET-1056 5

Page 6: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Cisco DevNet

• What is Cisco DevNet?• What is the Purpose?• Why do we go to events?

• We’re on Facebook and Twitter @CiscoDevNet

• Free tools and sandboxes

Page 7: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

What is an API?

7Presentation ID

Page 8: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Application Programming Interface

”It’s a way for two pieces of software to talk to each other”

Page 9: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

For a long time.. Humans were the only users

Page 10: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

For a long time.. Humans were the only users

1. User asks for data or takes action by interacting with UI

2. Software displays results in User Interface (UI)

Page 11: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

But what about when the user is another software system….

1. Software asks for data or takes action by interacting with API

2. Software returns results via API

My Software System

Your Software System

Page 12: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Why APIs?

12Presentation ID

Page 13: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Why are API’s so important?

Page 14: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

API Growth from 2000 to 2016

2000 2005 2007 2009 2011 2013 2015 20160

5000

10000

15000

20000

25000

30000

35000API's

API's

Source: 2016 data from nordicapis.com. 2005-2015 data from rubenverborgh.github.io and 2000-2004 data from blog.cutter.com

Page 15: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

The API is the User Interface for software systems

15Presentation ID

Page 16: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

APIs are sets of requirements that govern how one application can talk to another.

16Presentation ID

Page 17: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

An API is like an electrical outlet.What would it be like to power a hair dryer without an outlet?- Open wall- Unsheath wires- Splice wires

together- Understand all the

wires in the wall

The outlet is a service that conforms to specifications.- sockets deliver 120

volts of alternating current (AC) operating at 60Hz

- Sets expectation on behalf of consuming devices and provider.

Page 18: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

An API is like …

An API (Application Programming Interface) is best thought of as a contract provided by one piece of computer software to another.

Page 19: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

APIs help developers create apps that benefit the end user.

1. Yelp asks for Map Data

2. Google Maps returns map data

via API

Users sees list of

restaurants close to

them

Page 20: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

-- Programmable Web

APIs are often referred to as “an engine of innovation.”

Page 21: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Web Pages, Requests, Response & REST APIs

21Presentation ID

Page 22: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

View a Web Page

Presentation ID

Page 23: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

View a Web Page

Presentation ID

Request GET /index.htm HTTP/1.1

ResponseHTTP 200 OK

<html>

Page 24: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Good• 200 OK• 201 Created• 204 No Content

Common HTTP Status CodesBad• 400 Bad Request• 403 Forbidden• 404 Not Found• 500 Internal Server

Error• 550 Permission

Denied

Page 25: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

REST APIs use Request and Response to

Page 26: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Get Data using an API

Presentation ID

Page 27: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Get Data using an API

Presentation ID

Request GET /rooms

ResponseHTTP 200 OK

{json data}

API Consumer API Provider

Page 28: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Example Spark API Flow

1. My App asks Spark for members

in a room

2. Spark returns member data via

API

4. Users sees diff of users on

team and in room

Cisco Spark

3. My App Compares

members of a room with team

members

Page 29: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 29DEVNET-1056

Methods

Page 30: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

What is so great about REST?

30

• Rooms• People• Memberships• Messages

Easy to use:

• In mobile apps• In console apps• In web apps

Spark REST APIs

Page 31: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Setup with Spark

31DEVNET-1056

Page 32: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Let’s get your computer setup1. Create an account with Spark - https://web.ciscospark.com

2. Login to the Spark app - https://web.ciscospark.com ORDownload the Spark app - https://www.ciscospark.com/downloads.html

3. Bookmark the Spark developer documentation - https://developer.ciscospark.com(You will need to login to use the interactive documents)

DEVNET-1056

Page 33: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Cisco Spark for DevelopersTour of Cisco Spark APIs

33DEVNET-1056

Page 34: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Cisco Spark

Secure & Open

Complete & Simple

Spark for DevelopersUser Integrations, APIs/SDKs, etc.

Spark Hybrid ServicesCloud + Prem

Partner ServicesInterconnect

Message Meeting Call

DEVNET-1056

Page 35: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

‘Your App’ now with

Cisco Collab!

Spark APIs Extend Cisco Collaboration Cloud

GET

POST

DELETE

PUT /Rooms

/Memberships

/Messages

/Teams

/People

/Webhooks

DEVNET-1056

Page 36: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Cisco Spark API v1/People /Rooms /Membership /Messages /Teams /Webhooks

List People List Rooms List Memberships List Messages List Teams List Webhooks

Create a Room Create a Membership Create a Message Create a Team Create a Webhook

Get Person Details Get Room details Get Membership details Get Message details Get Team details Get Webhook details

Update a Room Update a Membership Update a Team Update a Webhook

Delete a Room Delete a Membership Delete a Message Delete a Team Delete a Webhook

GET

POST

DELETE

PUT

DELETE DELETE DELETE

PUT PUT

POST POST POST

GET GET GET

GET GET

GET

GET GETGET

DELETE

PUT

POST

GET

GET

DEVNET-1056

Page 37: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Demo: List Rooms

Page 38: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

For a long time.. Humans were the only users

1. User asks for data or takes action by interacting with UI

2. Software displays results in User Interface (UI)

Page 39: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

View your Spark roomsIf this is your first time using Spark, you will only see 1 Spark room

1. What is the name of the room?

DEVNET-1056

Page 40: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

But what about when the user is another software system….

1. Software asks for data or takes action by interacting with API

2. Software returns results via API

My Software System

Your Software System

Page 41: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

List Spark Rooms

Presentation ID

Request GET /rooms

ResponseHTTP 200 OK

{json data}

API Consumer API Provider

Page 42: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 42DEVNET-1056

1. Login to Spark Developer Docshttps://developer.ciscospark.com

Page 43: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 43DEVNET-1056

2. Click on Documentationhttps://developer.ciscospark.com

Page 44: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

3. Click on Rooms and then click on List Roomshttps://developer.ciscospark.com

Page 45: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

4. Turn on Test Modehttps://developer.ciscospark.com

Page 46: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Method URL

Response

Page 47: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 47DEVNET-1056

5. Click on runhttps://developer.ciscospark.com

Page 48: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Method URL

Response

Page 49: DevNet 1056 WIT Spark API and Chat Bot Workshop
Page 50: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Demo: Create a room

Page 51: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

For a long time.. Humans were the only users

1. User asks for data or takes action by interacting with UI

2. Software displays results in User Interface (UI)

Page 52: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Create a Spark roomLet’s create a new Spark room

1. Ask 2 people next to you for the email addresses they used for Spark

2. Click on the “+” and enter in their email addresses

3. Then type them a message

DEVNET-1056

Page 53: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

But what about when the user is another software system….

1. Software asks for data or takes action by interacting with API

2. Software returns results via API

My Software System

Your Software System

Page 54: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Create a New Room

Presentation ID

Request POST /rooms

ResponseHTTP 200 OK

{json data}

API Consumer API Provider

Page 55: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

MethodURL

Response

Page 56: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Did it work? Go to the Spark app and see!https://web.ciscospark.com

Page 57: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Add people to your room

Page 58: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Page 59: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Try to add yourself to your room What happened?

Add your neighbor to your roomWhat happened

Challenge: List memberships for room

Page 60: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 60DEVNET-1056

Cisco Spark for DevelopersSpark API calls in Python

Page 61: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Using Python to Make Requests

• A benefit of REST is that you can invoke Spark from any language

• Code it yourself

• Or generate code from Postman

• OAuth 2 to inject user API token

Do It Yourself … with Postman code assistants

DEVNET-1056

Page 62: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Using Python to Make Requests

1. Generate a python skeleton from Postman, 2. Run from the command line

Do It Yourself … with Postman code assistants

DEVNET-1056

Page 63: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Using Postman to make API request

63DEVNET-1056

Page 64: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

http://getpostman.com• Want to code along? Install POSTMAN now• Free tool to forge API requests, examine responses

DEVNET-1056

Page 65: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Same API Call in

POSTMAN

Page 66: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

method

url

requestheaders

status code

response headers

content-type

responsebody

query parameters

Page 67: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Find your Spark Developer TokenLogin to developer.ciscospark.com

Copy Developer Token

Developer Token

Page 68: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

JSON syntax• square brackets for lists

• curly braces for objects

• name/value pairs for properties, separated by commas

• pick an online editor

• http://www.jsonlint.com

DEVNET-1056

Page 69: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Q & A

DEVNET-1056 69

Page 70: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 70DEVNET-1056

Build a Spark Bot

Page 71: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

• 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!

Agenda (Build a Spark Bot)

DEVNET-1056 71

Page 72: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

• 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

What You Will Need:

DEVNET-1056

Page 73: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Objective

DEVNET-1056

Page 74: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 74DEVNET-1056

What are Chat Bots?

Page 75: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Clippy!

DEVNET-1056

Page 76: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Page 77: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Page 78: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Page 79: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 79DEVNET-1056

Page 80: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 80DEVNET-1056

What are the Benefits?

Page 81: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 81DEVNET-1056

Page 82: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 82

Page 83: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 83

Page 84: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 84DEVNET-1056

Integrations vs Bots

Page 85: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

An integration acts as YOU and can see and do

the things you can do.

DEVNET-1056 85

Page 86: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 86

Page 87: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 87

Page 88: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

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

that mention it.

DEVNET-1056 88

Page 89: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 89DEVNET-1056

Getting Started with a Collaboration API

Page 90: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Have 2 things open in your browser:

1. web.ciscospark.com

2. Developer.ciscospark.com

Page 91: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Creating a Chat Bot

91DEVNET-1056

Page 92: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

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

DEVNET-1056 92

Page 93: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Select ”Create a Bot”

DEVNET-1056 93

Page 94: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Add a Bot Image

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

DEVNET-1056 94

Page 95: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 95

Page 96: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Copy API Access Token

DEVNET-1056 96

Page 97: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Copy API Access Token

DEVNET-1056 97

Page 98: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 98DEVNET-1056

Deploy a bot on Cloud9

Page 99: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

c9.io/signup

DEVNET-1056 99

Page 100: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 100

Page 101: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

A closer look at the Github URL:

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

DEVNET-1056 101

Page 102: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Page 103: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

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

DEVNET-1056 103

Page 104: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

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

Terminal

• Create two variables:NAME VALUE

DEBUG sparkbotSPARK_TOKEN yourtokenkeyhere

DEVNET-1056 104

Page 105: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Page 106: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Make Your Application Public to Share

DEVNET-1056 106

Page 107: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Create Webhook events

107DEVNET-1056

Page 108: DevNet 1056 WIT Spark API and Chat Bot Workshop

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 108

Page 109: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Create Cisco Spark Webhooks

Page 110: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

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

DEVNET-1056 110

Page 111: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

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!

DEVNET-1056 111

Page 112: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Test your Cisco Spark Bot

112DEVNET-1056

Page 113: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Test Bots Response – type /hello

DEVNET-1056 113

Page 114: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Mention your bot in Group rooms

Page 115: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Type /hello to test Group chat with bot

DEVNET-1056 115

Page 116: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

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.

DEVNET-1056 116

Page 117: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Complete Your Online Session Evaluation

Don’t forget: Cisco Live sessions will be available for viewing on-demand after the event at CiscoLive.com/Online

• Please complete your Online Session Evaluations after each session

• Complete 4 Session Evaluations & the Overall Conference Evaluation (available from Thursday) to receive your Cisco Live T-shirt

• All surveys can be completed via the Cisco Live Mobile App or the Communication Stations

117DEVNET-1056

Page 118: DevNet 1056 WIT Spark API and Chat Bot Workshop

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

Continue Your Education• Demos in the Cisco campus

• Walk-in Self-Paced Labs

• Lunch & Learn

• Meet the Engineer 1:1 meetings

• Related sessions

DEVNET-1056

Page 119: DevNet 1056 WIT Spark API and Chat Bot Workshop

Thank You

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 119

Page 120: DevNet 1056 WIT Spark API and Chat Bot Workshop