KEMBAR78
DevNet 1056 WIT Spark API and Chat Bot Workshop | PPTX
Intro to Spark
an introduction to REST APIs and
Creating Spark Bots
Adrienne Moherek and Tessa Mero
DEVNET-1056
• 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)
• 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)
Who Are We?
© 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
What is an API?
© 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”
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
For a long time.. Humans were the only users
© 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)
© 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
Why APIs?
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Why are API’s so important?
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
API Growth from 2000 to 2016
0
5000
10000
15000
20000
25000
30000
35000
2000 2005 2007 2009 2011 2013 2015 2016
API's
API's
Source: 2016 data from nordicapis.com. 2005-2015 data from
rubenverborgh.github.io and 2000-2004 data from blog.cutter.com
The API is the User Interface for
software systems
APIs are sets of requirements that
govern how one application can talk
to another.
© 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.
© 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.
© 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
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicPresentation ID
-- Programmable Web
APIs are often referred to as “an engine of
innovation.”
Web Pages, Requests, Response &
REST APIs
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
View a Web Page
22Presentation ID
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
View a Web Page
23Presentation ID
Request
GET /index.htm HTTP/1.1
Response
HTTP 200 OK
<html>
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Good
• 200 OK
• 201 Created
• 204 No Content
Common HTTP Status Codes
Bad
• 400 Bad Request
• 403 Forbidden
• 404 Not Found
• 500 Internal Server
Error
• 550 Permission Denied
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
REST APIs use Request and Response to
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Get Data using an API
26Presentation ID
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Get Data using an API
27Presentation ID
Request
GET /rooms
Response
HTTP 200 OK
{json data}
API Consumer API Provider
© 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
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 29DEVNET-1056
Methods
© 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
Setup with Spark
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Let’s get your computer setup
1. Create an account with Spark - https://web.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)
32DEVNET-1056
Cisco Spark for Developers
Tour of Cisco Spark APIs
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Cisco Spark
Secure & Open
Complete & Simple
Spark for Developers
User Integrations, APIs/SDKs, etc.
Spark Hybrid Services
Cloud + Prem
Partner Services
Interconnect
Message Meeting Call
DEVNET-1056 34
© 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
/Teams
/People
/Webhooks
DEVNET-1056 35
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
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 36
Demo: List Rooms
© 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)
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
View your Spark rooms
If this is your first time using Spark, you will only see 1 Spark room
1. What is the name of the room?
39DEVNET-1056
© 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
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
List Spark Rooms
41Presentation ID
Request
GET /rooms
Response
HTTP 200 OK
{json data}
API Consumer API Provider
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 42DEVNET-1056
1. Login to Spark Developer Docs
https://developer.ciscospark.com
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 43DEVNET-1056
2. Click on Documentation
https://developer.ciscospark.com
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 44DEVNET-1056
3. Click on Rooms and then click on List Rooms
https://developer.ciscospark.com
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 45DEVNET-1056
4. Turn on Test Mode
https://developer.ciscospark.com
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Method URL
Response
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public 47DEVNET-1056
5. Click on run
https://developer.ciscospark.com
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Method URL
Response
Demo: Create a room
© 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)
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Create a Spark room
Let’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
52DEVNET-1056
© 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
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Create a New Room
54Presentation ID
Request
POST /rooms
Response
HTTP 200 OK
{json data}
API Consumer API Provider
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Method
URL
Response
© 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
Add people to your room
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
© 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 room
What happened
Challenge: List memberships for room
Cisco Spark for Developers
Spark API calls in Python
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
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 61
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
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 62
Using Postman to make API request
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
http://getpostman.com
• Want to code along? Install POSTMAN now
• Free tool to forge API requests, examine responses
DEVNET-1056 64
© 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
method
url
request
headers
status code
response headers
content-type
response
body
query parameters
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Find your Spark Developer Token
Login to developer.ciscospark.com
Copy Developer Token
Developer Token
© 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
• pick an online editor
• http://www.jsonlint.com
DEVNET-1056 68
Q & A
Build a Spark Bot
• 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)
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
• 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 72
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Objective
DEVNET-1056 73
What are Chat Bots?
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Clippy!
DEVNET-1056 75
© 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
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 79
What are the Benefits?
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 81
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 82
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 83
Integrations vs Bots
© 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
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 86
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 87
© 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
Getting Started with a Collaboration
API
© 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
Creating a Chat Bot
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Click on “My Apps” and Add New (+)
DEVNET-1056 92
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Select ”Create a Bot”
DEVNET-1056 93
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Add a Bot Image
http://bit.ly/SparkBot-512x512
DEVNET-1056 94
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 95
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Copy API Access Token
DEVNET-1056 96
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Copy API Access Token
DEVNET-1056 97
Deploy a bot on Cloud9
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
c9.io/signup
DEVNET-1056 99
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 100
© 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
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
© 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
© 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 sparkbot
SPARK_TOKEN yourtokenkeyhere
DEVNET-1056 104
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Make Your Application Public to Share
DEVNET-1056 106
Create Webhook events
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 108
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Create Cisco Spark Webhooks
© 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
© 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
Test your Cisco Spark Bot
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
Test Bots Response – type /hello
DEVNET-1056 113
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
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 115
© 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
© 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
DEVNET-1056 117
© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public
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 118
Thank You
DevNet 1056 WIT Spark API and Chat Bot Workshop

DevNet 1056 WIT Spark API and Chat Bot Workshop

  • 2.
    Intro to Spark anintroduction to REST APIs and Creating Spark Bots Adrienne Moherek and Tessa Mero DEVNET-1056
  • 3.
    • REST APIBasics: • 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)
  • 4.
    • What areChat 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)
  • 5.
  • 6.
    © 2017 Ciscoand/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
  • 7.
  • 8.
    © 2017 Ciscoand/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”
  • 9.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public For a long time.. Humans were the only users
  • 10.
    © 2017 Ciscoand/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)
  • 11.
    © 2017 Ciscoand/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
  • 12.
  • 13.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Why are API’s so important?
  • 14.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public API Growth from 2000 to 2016 0 5000 10000 15000 20000 25000 30000 35000 2000 2005 2007 2009 2011 2013 2015 2016 API's API's Source: 2016 data from nordicapis.com. 2005-2015 data from rubenverborgh.github.io and 2000-2004 data from blog.cutter.com
  • 15.
    The API isthe User Interface for software systems
  • 16.
    APIs are setsof requirements that govern how one application can talk to another.
  • 17.
    © 2017 Ciscoand/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.
  • 18.
    © 2017 Ciscoand/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.
  • 19.
    © 2017 Ciscoand/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
  • 20.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicPresentation ID -- Programmable Web APIs are often referred to as “an engine of innovation.”
  • 21.
    Web Pages, Requests,Response & REST APIs
  • 22.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public View a Web Page 22Presentation ID
  • 23.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public View a Web Page 23Presentation ID Request GET /index.htm HTTP/1.1 Response HTTP 200 OK <html>
  • 24.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Good • 200 OK • 201 Created • 204 No Content Common HTTP Status Codes Bad • 400 Bad Request • 403 Forbidden • 404 Not Found • 500 Internal Server Error • 550 Permission Denied
  • 25.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public REST APIs use Request and Response to
  • 26.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Get Data using an API 26Presentation ID
  • 27.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Get Data using an API 27Presentation ID Request GET /rooms Response HTTP 200 OK {json data} API Consumer API Provider
  • 28.
    © 2017 Ciscoand/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
  • 29.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 29DEVNET-1056 Methods
  • 30.
    © 2017 Ciscoand/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
  • 31.
  • 32.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Let’s get your computer setup 1. Create an account with Spark - https://web.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) 32DEVNET-1056
  • 33.
    Cisco Spark forDevelopers Tour of Cisco Spark APIs
  • 34.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Cisco Spark Secure & Open Complete & Simple Spark for Developers User Integrations, APIs/SDKs, etc. Spark Hybrid Services Cloud + Prem Partner Services Interconnect Message Meeting Call DEVNET-1056 34
  • 35.
    © 2017 Ciscoand/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 /Teams /People /Webhooks DEVNET-1056 35
  • 36.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 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 36
  • 37.
  • 38.
    © 2017 Ciscoand/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)
  • 39.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public View your Spark rooms If this is your first time using Spark, you will only see 1 Spark room 1. What is the name of the room? 39DEVNET-1056
  • 40.
    © 2017 Ciscoand/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
  • 41.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public List Spark Rooms 41Presentation ID Request GET /rooms Response HTTP 200 OK {json data} API Consumer API Provider
  • 42.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 42DEVNET-1056 1. Login to Spark Developer Docs https://developer.ciscospark.com
  • 43.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 43DEVNET-1056 2. Click on Documentation https://developer.ciscospark.com
  • 44.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 44DEVNET-1056 3. Click on Rooms and then click on List Rooms https://developer.ciscospark.com
  • 45.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 45DEVNET-1056 4. Turn on Test Mode https://developer.ciscospark.com
  • 46.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Method URL Response
  • 47.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 47DEVNET-1056 5. Click on run https://developer.ciscospark.com
  • 48.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Method URL Response
  • 50.
  • 51.
    © 2017 Ciscoand/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)
  • 52.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Create a Spark room Let’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 52DEVNET-1056
  • 53.
    © 2017 Ciscoand/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
  • 54.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Create a New Room 54Presentation ID Request POST /rooms Response HTTP 200 OK {json data} API Consumer API Provider
  • 55.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Method URL Response
  • 56.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 56DEVNET-1056 Did it work? Go to the Spark app and see! https://web.ciscospark.com
  • 57.
    Add people toyour room
  • 58.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public
  • 59.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Try to add yourself to your room  What happened? Add your neighbor to your room What happened Challenge: List memberships for room
  • 60.
    Cisco Spark forDevelopers Spark API calls in Python
  • 61.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 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 61
  • 62.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 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 62
  • 63.
    Using Postman tomake API request
  • 64.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public http://getpostman.com • Want to code along? Install POSTMAN now • Free tool to forge API requests, examine responses DEVNET-1056 64
  • 65.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Same API Call in POSTMAN
  • 66.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public method url request headers status code response headers content-type response body query parameters
  • 67.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Find your Spark Developer Token Login to developer.ciscospark.com Copy Developer Token Developer Token
  • 68.
    © 2017 Ciscoand/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 • pick an online editor • http://www.jsonlint.com DEVNET-1056 68
  • 69.
  • 70.
  • 71.
    • What areChat 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)
  • 72.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public • 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 72
  • 73.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Objective DEVNET-1056 73
  • 74.
  • 75.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Clippy! DEVNET-1056 75
  • 76.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public
  • 77.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public
  • 78.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public
  • 79.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 79
  • 80.
    What are theBenefits?
  • 81.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 81
  • 82.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 82
  • 83.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 83
  • 84.
  • 85.
    © 2017 Ciscoand/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
  • 86.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 86
  • 87.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 87
  • 88.
    © 2017 Ciscoand/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
  • 89.
    Getting Started witha Collaboration API
  • 90.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Have 2 things open in your browser: 1. web.ciscospark.com 2. Developer.ciscospark.com
  • 91.
  • 92.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Click on “My Apps” and Add New (+) DEVNET-1056 92
  • 93.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Select ”Create a Bot” DEVNET-1056 93
  • 94.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Add a Bot Image http://bit.ly/SparkBot-512x512 DEVNET-1056 94
  • 95.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 95
  • 96.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Copy API Access Token DEVNET-1056 96
  • 97.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Copy API Access Token DEVNET-1056 97
  • 98.
    Deploy a boton Cloud9
  • 99.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public c9.io/signup DEVNET-1056 99
  • 100.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 100
  • 101.
    © 2017 Ciscoand/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
  • 102.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public
  • 103.
    © 2017 Ciscoand/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
  • 104.
    © 2017 Ciscoand/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 sparkbot SPARK_TOKEN yourtokenkeyhere DEVNET-1056 104
  • 105.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public
  • 106.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Make Your Application Public to Share DEVNET-1056 106
  • 107.
  • 108.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco PublicDEVNET-1056 108
  • 109.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Create Cisco Spark Webhooks
  • 110.
    © 2017 Ciscoand/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
  • 111.
    © 2017 Ciscoand/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
  • 112.
    Test your CiscoSpark Bot
  • 113.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Test Bots Response – type /hello DEVNET-1056 113
  • 114.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Mention your bot in Group rooms
  • 115.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public Type /hello to test Group chat with bot DEVNET-1056 115
  • 116.
    © 2017 Ciscoand/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
  • 117.
    © 2017 Ciscoand/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 DEVNET-1056 117
  • 118.
    © 2017 Ciscoand/or its affiliates. All rights reserved. Cisco Public 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 118
  • 119.

Editor's Notes

  • #6 Tessa Mero Adrienne Moherek
  • #7 What is DevNet? DevNet is Cisco’s developer program created about 3 years ago. Our purpose is to provide developers with the tools, the resources, and the code they need to build innovative, network-enabled solutions. We go to programming events and all types of conferences to show you how to use some of Cisco’s APIs. We absolutely love getting attention on @CiscoDevNet. A wonderful colleague of mine is amazing at her social media work on all of our DevNet accounts. She gets excited when you tweet at her. Even more excited if you ask for stickers!
  • #10 From progammable web…. For decades, most computer software--programs that provide data like contact information or functionality like image editing--has been conceived and written with one type of user in mind: a human. No matter what chain of events is taking place under the hood of software, a human user is traditionally at the end of that chain. That end user invariably consumes that data and/or functionality through a user interface (UI)—one that’s designed to make the act of consumption as easy and even enjoyable as possible.  But what if that same data and/or functionality could be just as easily consumed by another piece of software? In this case, the UI concerns are very different. After all: Software doesn’t have eyes, emotions or intuition, so it doesn’t need an enjoyable, intuitive graphical user interface. However, as with a UI tailored to humans, software needs an interface that makes it easy to consume data and/or functionality. Enter, application programming interfaces, or APIs.  An API is geared for consumption by software, which is why APIs are often explained in the mainstream media as a technology that allows applications (software programs) to talk to one another. In this context, the terms “application,” “software,” “machines” and “computers” are virtually interchangeable. For example, APIs are often discussed as being machine-readable interfaces (versus human-readable). 
  • #11 From progammable web…. For decades, most computer software--programs that provide data like contact information or functionality like image editing--has been conceived and written with one type of user in mind: a human. No matter what chain of events is taking place under the hood of software, a human user is traditionally at the end of that chain. That end user invariably consumes that data and/or functionality through a user interface (UI)—one that’s designed to make the act of consumption as easy and even enjoyable as possible.  But what if that same data and/or functionality could be just as easily consumed by another piece of software? In this case, the UI concerns are very different. After all: Software doesn’t have eyes, emotions or intuition, so it doesn’t need an enjoyable, intuitive graphical user interface. However, as with a UI tailored to humans, software needs an interface that makes it easy to consume data and/or functionality. Enter, application programming interfaces, or APIs.  An API is geared for consumption by software, which is why APIs are often explained in the mainstream media as a technology that allows applications (software programs) to talk to one another. In this context, the terms “application,” “software,” “machines” and “computers” are virtually interchangeable. For example, APIs are often discussed as being machine-readable interfaces (versus human-readable). 
  • #12 But what about when the user is another software system? The software returns results via the API and the Software asks for data or takes action by interacting with the API.
  • #14 Why are API’s so important? Most companies today have several different software they need to use, including sales, accounting, CRM, a project management system, etc. To have the software all work together is becoming a more important thing for both synergy and financial reasons and is making tasks much easier for work processes. They can also create their own tool to enhance their software, making their customers happier. QUESTION: What is your favorite app?
  • #15 As you can see that the amount of API’s out has exponentially increased over time. In 2016, there has been more than 50 million API requests made and 30,000 available API’s out there. From 2015 to 2016, it has doubled in growth from 15,000 to 30,000 and only exponentially increasing.
  • #18 Imagine what life might be like without such a standard. For example, with no plug, matching socket or standard particulars (often called specifications), we might have to hard-wire appliances into the walls of buildings. This would involve gathering the required tools, unsheathing all the wires and splicing the wires together. Of course, we would also need to know something about the wires coming out of the wall. Moving an appliance from one location to another would be a major undertaking in disconnection and reconnection. Note: Just give an example of what it’s like to have one tool and not the other , when it only works with both combined.
  • #20 QUESTION: What other apps use Google Maps? Think about the way Yelp, for instance, displays nearby restaurants on a Google Map in its app APIs do all this by “exposing” some of a program’s internal functions to the outside world in a limited fashion. That makes it possible for applications to share data and take actions on one another’s behalf without requiring developers to share all of their software’s code.  APIs simplify all that by limiting outside program access to a specific set of features—often enough, requests for data of one sort or another. Feel free to think of them as doors, windows or levers if you like. Whatever the metaphor, APIs clearly define exactly how a program will interact with the rest of the software world APIs make possible a sprawling array of Web-service “mashups,” in which developers use mix and match APIs from the likes of Google or Facebook or Twitter to create entirely new apps and services. In many ways, the widespread availability of APIs for major services is what’s made the modern Web experience possible. APIs are often referred to as an engine of innovation.
  • #23 When your browser visits a web server, it comes back with a prepared html from the requested page.
  • #24 So you make a request and you get an http response. QUESTION: Is a 200 OK responses good or bad?
  • #25 Here are some common HTTP status codes that you will get when you request a web page. When you make a request with an API, you also get a response back with a status code. Usually you will be hoping for 200 OK.
  • #26 It’s simple: Your App and Their App requesting data to and from each other.
  • #27 You can have your app ask for a list of “Spark Rooms”. Cisco Spark will prepare a list of rooms and send it back to you.
  • #28 Then your response will come back as 200 OK and you’ll see the list of Spark rooms successfully from the API provider.
  • #30 GET – get POST – create PUT – update DELETE – delete Your app will use one of these methods for each request
  • #31 QUESTION: Who is familiar with HTTP? REST is an easy to use architectural style that uses HTTP. If you are familiar with HTTP then you practically already know REST. It is independent of programming languages. So you can use Python, JavaScript, Java, etc. Use REST APIs to build web apps or mobile apps and even bots.
  • #34 Alright, now that we have skimmed through the major parts of a REST API, let’s do the fun hands on stuff Who here has Spark account already Setup?
  • #35 QUESTION: Who has used Spark? Part of Cisco Collaboration tool , single unified experience With Spark you can call message or meet. The beauty about spark messaging is it is encrypted end to end. Each room has its own certificate. Not to mention all messages are persistent which makes it easier to search and look for information The most important thing, Spark has an API . And this is why we are here
  • #36 Spark API has the capability to interact with people , memberships , rooms , messages, teams and for automation and bot creation webhook. If you would like to learn more about Spark API outside of this session, visit the learning labs in the DevNet Zone We have 3 different Spark Learning Labs that are tailored to take you from pulling basic room/people information all the way to creating a webhook and app integration. Highly recommend to come see us there
  • #37 Here are the different areas you can use “Get, POST, PUT, DELETE” methods. You can work with People, Rooms, Memberships, Messages, Teams, and work with webhooks. Now, let’s work with a few of these! QUESTION: What method is missing in /Messages?
  • #39 From progammable web…. For decades, most computer software--programs that provide data like contact information or functionality like image editing--has been conceived and written with one type of user in mind: a human. No matter what chain of events is taking place under the hood of software, a human user is traditionally at the end of that chain. That end user invariably consumes that data and/or functionality through a user interface (UI)—one that’s designed to make the act of consumption as easy and even enjoyable as possible.  But what if that same data and/or functionality could be just as easily consumed by another piece of software? In this case, the UI concerns are very different. After all: Software doesn’t have eyes, emotions or intuition, so it doesn’t need an enjoyable, intuitive graphical user interface. However, as with a UI tailored to humans, software needs an interface that makes it easy to consume data and/or functionality. Enter, application programming interfaces, or APIs.  An API is geared for consumption by software, which is why APIs are often explained in the mainstream media as a technology that allows applications (software programs) to talk to one another. In this context, the terms “application,” “software,” “machines” and “computers” are virtually interchangeable. For example, APIs are often discussed as being machine-readable interfaces (versus human-readable). 
  • #41 But what about when the user is another software system? The software returns results via the API and the Software asks for data or takes action by interacting with the API.
  • #42 Let’s get a list of Spark rooms that you are in using the Spark developer interactive document.
  • #43 We’re going to login to the documents so that we can retrieve a list of rooms programmatically.
  • #50 Congratulations! You made your first API request.
  • #52 From progammable web…. For decades, most computer software--programs that provide data like contact information or functionality like image editing--has been conceived and written with one type of user in mind: a human. No matter what chain of events is taking place under the hood of software, a human user is traditionally at the end of that chain. That end user invariably consumes that data and/or functionality through a user interface (UI)—one that’s designed to make the act of consumption as easy and even enjoyable as possible.  But what if that same data and/or functionality could be just as easily consumed by another piece of software? In this case, the UI concerns are very different. After all: Software doesn’t have eyes, emotions or intuition, so it doesn’t need an enjoyable, intuitive graphical user interface. However, as with a UI tailored to humans, software needs an interface that makes it easy to consume data and/or functionality. Enter, application programming interfaces, or APIs.  An API is geared for consumption by software, which is why APIs are often explained in the mainstream media as a technology that allows applications (software programs) to talk to one another. In this context, the terms “application,” “software,” “machines” and “computers” are virtually interchangeable. For example, APIs are often discussed as being machine-readable interfaces (versus human-readable). 
  • #54 But what about when the user is another software system? The software returns results via the API and the Software asks for data or takes action by interacting with the API.
  • #62 Note that adding your Spark Token into a Web page is not something you want to do Rather have it dynamically injected
  • #65 We will also be working with Postman. It is a free browser plugin with Chrome and makes it easy to make API requests and examine your responses. You will want to use this tool for other APIs that don’t have an interractive document.
  • #66 You can see we are fetching data of all of the rooms you are a member of.
  • #67 Okay let’s look at how to make an API call in Postman.
  • #68 You will use this token to authenticate your request. This tells the Spark web server who is making the request
  • #69 Okay so let’s look at JSON . JSON is great cause it is universal, regardless of which laguage you chose to write yoru code , i can garantee you will find a json parsing library. If it is not already built into the language iteself. It is very easy to use and simple to read/ easy on the eyes Okay let’s quickly go through the basic structure of a json Start of Square Brackets Each element is an object, in this case it is an Array of objects Then you get key value pair. Another great tool to use is jsonlint.com to check your json , especially if you are doing a POST to an API, you need to make sure your JSON is properly formatted otherwise it will fail
  • #74 This will be the final of what we will see. The Hello World Bot. ToDo: switch out image to one that says Hello Tessa Mero
  • #76 Bot assistance preinstalled in Windows versions from 1997 to 2003.
  • #77 Talk about Siri as a bot
  • #78 Amazon echo as a bot
  • #79 Amazon Alexa integrating with the Tesla Model S. Make commands to make other things do things. Jason Geocke from Cisco doing this integration.
  • #80 Chat bots are becoming more popular and will become the future of technology. * Use Case: Customer service interactions. The bot is an AI to grab information and package it and put it in front of a human to finish the interaction.
  • #82 “I’ve analyzed the Silicon Valley Bot Startup trend and created a handy venn diagram to help explain it” Bots are designed to solve a problem you have in your work flow or business.
  • #83 You can create or use existing plugins to extend your chat bot to do things. Such as the SmartSheet (which is a competitor of google spreadsheets), to send notifications when there is a change in your spreadsheet. It also lists the commands you can make to trigger activities. Mention Spark Innovation Fund?
  • #84 In our company Spark Chats, we have a room with a MemeBot that one of my colleagues created. You type a few words, followed by the name of the meme to trigger it, and the bot will create a meme. (There’s an API for retrieving meme images and overlaying the text).
  • #86 A bot can do things as itself. It has its own account and authentication. If you do an integration, it’s going to complete tasks as YOU.
  • #87 For example, the Out of Office Assistant integration. It lists the requests you can do with it.
  • #88 In the Spark API scope, you can see the different levels of access that your integration can require. You can find all of this in the API documentation. We also have a collection of POSTMAN calls. Just ask us later for more information.
  • #89 In this way, it’s its own entity, which is an authentication on your account.
  • #91 Go to developer.ciscospark.com and click on Sign Up on the far right top corner.
  • #93 Log in at “Spark for Developers” and open the "My Apps" menu.
  • #94 You will access the “New Bot” creation form below. Fill in a name, a unique email identifier, and specify a publicly accessible image URL with a minimal resolution of 512x512 pixels. Feel free to pick this image example for the sake of this lab. (http://bit.ly/SparkBot-512x512) Note that you will not be authorized to pick the email "my-awesome-bot@sparkbot.io" as it is already reserved. Make sure to replace future mentions to the bot email you have chosen.
  • #95 Give people some time to type this URL in or find their own bot picture they want to use
  • #96 Click “Add Bot” to get your Cisco Spark Bot created. Your Bot's access token is displayed. Paste it in a safe place as it won’t show up again, and we will use it in steps 2 and 3 of this lab. Note that a Cisco Spark Bot access token lasts 100 years. If you ever loose or reveal it, you can come back to this Bot details page and regenerate an access token. The previously issued token will be automatically deprecated.
  • #97 Your bot can now be added to any Cisco Spark Room by specifying its email: my-awesome-bot@sparkbot.io in our example. Go to your Cisco Spark client, and create a new room with your Bot as a participant.
  • #98 Go into your Spark app. You can now add your bot to the chat. Even though you can chat with your bot, you won’t see him answer... as we haven’t connected it yet to any custom code logic. We’ll work on this in the next steps.
  • #100 For the sake of this lab, we will clone an existing code sample, and leverage the Cloud9 platform to deploy our own version of a Cisco Spark bot. Sign up at https://c9.io/signup. Create a new private Workspace. Make sure to create it as private so that the access token - we will set later - does not get disclosed. Fill in the "Clone from Git" field with the URL of our code sample: https://github.com/CiscoDevNet/node-sparkbot-samples. Make sure to pick the Node.js template, and click "Create worspace".
  • #101 Fill out the form to create your first workspace. Create your workspace name, description. Set it to private, and enter the Github URL. (Closer look at the URL on the next slide). Now click on “Create Workspace”
  • #103 After a minute, your workspace will be ready to use. Congrats, You now have at hand a fully functional nodejs development environment with your own copy of a Cisco Spark Bot!
  • #104 Go to the shell terminal at the bottom of the IDE, and type “npm install”. The nodejs libraries used by our code sample get downloaded to your Cloud9 workspace. In the File Explorer, look for the “helloworld.js” file in the “examples” directory. Double click the file to make it the current editable source code in your workspace. Now click the "Run" button in the top menu to launch an instance of your code. The Cloud9 console displays an error, as we have not specified the Cisco Spark identity under which our code should run. Now comes time to configure our bot.
  • #105 Click the ENV button at the bottom right of the Cloud9 terminal, and create two variables: DEBUG with "sparkbot*" as a value: this variable activates logs, SPARK_TOKEN with your bot’s token value: paste the token generated in step 1.
  • #106 Finally, click on the wheel to restart your bot, and check your logs look similar to the snapshot below.
  • #107 As we created our Cloud9 workspace as private, we will now need to take an extra step to make our bot accessible from Cisco Spark. Click on the "Share" link in the upper right corner, close to your avatar. As the popup shows up, click the "Public" checkbox facing the "Application" links to share. Click Yes when the pop up appears.
  • #108 In this section, we will create REST Webhooks so that our bot starts receiving traffic from Cisco Spark. 
  • #109 Look for your bot public URL in the Cloud9 terminal. It appears run after the mention "Your code is running at ", and is formatted as: https://replace-with-your-cloud9-project-name.c9users.io/. Open your bot public URL. Note that the snapshot you see leverages the Chrome plugin “JSON viewer” as mentioned in the pre-requisites. If you look attentively to the JSON data above, you will see your bot is running under the Cisco Spark Identity of the Bot Account you created earlier. Moreover, the “listeners” section lists the events your bot can take action on.
  • #110 Open the list of Webhooks supported by Cisco Spark, and look for the event entries needed by your bot: Messages / Created: a new message got posted into a room Memberships / Created: someone joined a room that you are in Click on the Webhooks entry in the API Reference section on the left, and select the “Post” method. This will drive you to the Create a Webhook form. Fill in the fields as shown in the screenshot: Authorization header: change the access token to your bot’s, and do NOT remove the "Bearer " prefix, targetUrl: paste the public URL of your bot on Cloud9, resource and event: make sure to fill in the “messages” and “created” values, as it is only default placeholders you see in the form, last fields “Secret” and “Filter” are optional. Leave them blank.
  • #111 Then click “Run” and check the response in the right panel. As your Cisco Spark API call completes successfully, you will see a green “200/success” displayed, and your Webhook will be assigned a unique identifier (check the “id” field). This webhook is fired every time a new message is added to a Cisco Spark room your bot is a member of. Now, let's create our second Webhook, in order to receive an event every time our bot is added to a room. On the same form, modify the value of the "resource" field: replace “messages” with “memberships”. Click “Run” again, and check your second Webhook got successfully created, with the “200 / success” message. Then click “Run” and check the response in the right panel. As your Cisco Spark API call completes successfully, you will see a green “200/success” displayed, and your Webhook will be assigned a unique identifier (check the “id” field). This webhook is fired every time a new message is added to a Cisco Spark room your bot is a member of.
  • #112 Now, let's create our second Webhook, in order to receive an event every time our bot is added to a room. On the same form, modify the value of the "resource" field: replace “messages” with “memberships”. Click “Run” again, and check your second Webhook got successfully created, with the “200 / success” message.
  • #113 In the previous steps, you deployed a Cisco Spark bot sample on Cloud9, launched a new instance under the identity of the Bot Account you created, and created Webhooks to start receiving events at your bot public URL on Cloud9. Now comes time to chat with your bot.
  • #114 Reach to the Cisco Spark room you created in step 1. Enter /hello. Check your bot's response!
  • #115 As introduced in previous labs, Cisco Spark Bots MUST be mentioned in “Group” rooms in order to be notified. Open the “Create a Room” form. Fill in the form with a title. Do NOT modify the token in the Authorization header, so that the room gets created under your personal Cisco Spark identity. Check the result is a "200/success", and the room type is set to “Group”. As you're the only participant in the room for now, Cisco Spark created a "Group" room to let you add participants later.
  • #116 Now, open your favorite Cisco Spark client, and reach to the newly created room. Invite your bot to the conversation by adding it as a participant, with the email address you created in step 1. Type /hello. You do not get any answer as your bot is not mentioned. Now mention your bot... and what for its answer!
  • #117 What about extending your bot! If you have a fully functional development environment at your disposal, we suggest you start by adding a few breakpoints in your bot main file "helloworld.js", and restart your bot in debug mode. Then, you'll want to add some commands of your own. If you’re looking for some inspiration, take a look at these examples. For the sake of this lab, we leveraged a nodejs bot framework that hides most of the complexity of listening to messages and taking action as commands are fired. Note that several other nodejs Bot frameworks exist for Cisco Spark, from basic to advanced and in various languages. As an example, Nick Marus’s flint framework is a nodejs bot framework that embeds interesting features such as automated creation of the Webhooks required by your bot... certainly worth a try...