DEVNET-1056
DEVNET-1056
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 6
What is an API?
Application Programming Interface
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 8
For a long time.. Humans were the only users
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 9
For a long time.. Humans were the only users
2. Software
displays results
in User Interface
(UI)
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 10
But what about when the user is another software
system….
2. Software
returns results
via API
My Software System
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 13
API Growth from 2000 to 2016
35000
API's
30000
25000
20000
15000 API's
10000
5000
0
2000 2005 2007 2009 2011 2013 2015 2016
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 18
APIs help developers create apps that benefit the
end user.
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 19
APIs are often referred to as “an engine of
innovation.”
-- Programmable Web
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 20
Web Pages, Requests, Response &
REST APIs
View a Web Page
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 22
View a Web Page
Request
GET /index.htm HTTP/1.1
Response
HTTP 200 OK
<html>
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 23
Common HTTP Status Codes
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 24
REST APIs use Request and Response to
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 25
Get Data using an API
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 26
Get Data using an API
API Consumer API Provider
Request
GET /rooms
Response
HTTP 200 OK
{json data}
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 27
Example Spark API Flow
3. My App
Compares
members of a
room with team 4. Users
2. Spark returns members sees diff of
member data via users on
API 1. My App asks team and in
Spark for members room
in a room
Cisco Spark
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 28
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 29
What is so great about REST?
Easy to use:
• In mobile apps
• In console apps
• In web apps
Spark REST APIs
• Rooms
• People
• Memberships
• Messages
How does this work?
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 30
Create Spark Account
Let’s get your computer setup
1. Create an account with Spark - https://www.ciscospark.com/
2. Login to the Spark app - https://web.ciscospark.com
OR
Download 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 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 32
Create a Spark Developer Account: developer.ciscospark.com
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 33
http://getpostman.com
• Want to code along? Install POSTMAN now
• Free tool to forge API requests, examine responses
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 34
url query parameters
method
request
headers
status code
response
response headers
body
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
JSON syntax
• square brackets for lists
• curly braces for objects
• name/value pairs for properties,
separated by commas
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 36
Cisco Spark for Developers
Tour of Cisco Spark APIs
Cisco Spark
Complete & Simple
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 38
Spark APIs
Extend Cisco Collaboration Cloud
‘Your App’
now with
Cisco Collab!
GET /People
POST /Memberships
PUT /Rooms
DELETE /Messages
/Teams
/Webhooks
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 39
Cisco Spark API v1
/People /Rooms /Membership /Messages /Teams /Webhooks
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 40
Demo: List Rooms
Find your Spark Developer Token
Login to developer.ciscospark.com
Copy Developer Token
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 42
List Spark Rooms
API Consumer API Provider
Request
GET /rooms
Response
HTTP 200 OK
{json data}
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 43
Response
Method URL
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Same API
Call in
POSTMAN
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Demo: Create a room
Create a New Room
API Consumer API Provider
Request
POST /rooms
Response
HTTP 200 OK
{json data}
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 47
Method
URL
Response
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 48
Add people to your room
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Try to add yourself to your room
What happened?
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 53
Using Python to Make Requests
Do It Yourself … with Postman code assistants
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 54
Q&A
Build a Spark Bot
Agenda (Build a Spark Bot)
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 59
What are Chat Bots?
Clippy!
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 61
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 65
What are the Benefits?
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 67
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 68
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 69
Integrations vs Bots
An integration acts as YOU
and can see and do
the things you can do.
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 71
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 72
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 73
A bot appears as another
member of the room, but
can only see messages
that mention it.
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 74
Getting Started with a Collaboration
API
Have 2 things open in your browser:
1. web.ciscospark.com
2. Developer.ciscospark.com
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 76
Creating a Chat Bot
Click on “My Apps” and Add New (+)
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 78
Select ”Create a Bot”
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 79
Add a Bot Image
http://bit.ly/SparkBot-512x512
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 80
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 81
Copy API Access Token
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 82
Copy API Access Token
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 83
Deploy a bot on Cloud9
c9.io/signup
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 85
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 86
A closer look at the Github URL:
https://github.com/CiscoDevNet/node-sparkbot-
samples.
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 87
© 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.
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 89
Create Variables
• Click the ENV button at the bottom right of the Cloud9
Terminal
DEBUG sparkbot
SPARK_TOKEN yourtokenkeyhere
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 90
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Make Your Application Public to Share
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 92
Create Webhook events
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 94
Create Cisco Spark Webhooks
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
200 Success!
• Click “Run”
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 96
Create Another Webhook
• Receive an event every time our bot is added to a room
• Modify “resource” field: replace “messages” with
“memberships”
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 97
Test your Cisco Spark Bot
Test Bots Response – type /hello
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 99
Mention your bot in Group rooms
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Type /hello to test Group chat with bot
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 101
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 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 102
Complete Your Online Session Evaluation
• 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
Don’t forget: Cisco Live sessions will be available
Communication Stations for viewing on-demand after the event at
CiscoLive.com/Online
DEVNET-1056 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 103
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 © 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 104
Thank You