26
Control Your World Using the Salesforce1 Platform (IoT) Chris Ferraro Chief IT Architect @chrisf_59

Control your world using the Salesforce1 Platform (IoT)

Embed Size (px)

DESCRIPTION

It's easy to control your office lights, heat, and much more using the Salesforce1 Platform. Our Chief IT Architect at Internet Creations, Chris Ferraro, shows you how to fire a workflow rule based on the temperature, control lights from your mobile phone, and a whole lot more using great DIY technologies like the Arduino and Raspberry Pi.

Citation preview

Page 1: Control your world using the Salesforce1 Platform (IoT)

Control Your World Using the Salesforce1 Platform (IoT)

Chris FerraroChief IT Architect@chrisf_59

Page 2: Control your world using the Salesforce1 Platform (IoT)

Safe HarborSafe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

Page 3: Control your world using the Salesforce1 Platform (IoT)

Place Customer or 

Partner logo in white area of 

slide, centered horizontally

Chris FerraroChief IT Architect

Page 4: Control your world using the Salesforce1 Platform (IoT)

About Internet Creationshttp://www.internetcreations.com

• Salesforce Consulting & AppExchange Apps• Member of the Cloud Collective: AppExchange Category Leaders• #1 Rated App for Agent Productivity

Internet Creations Labs

We balance work with the passion for learning. Technical staff are encouraged to spend up to 20% of their time on developing and pursuing their own creative ideas.

Page 5: Control your world using the Salesforce1 Platform (IoT)

Agenda

- The Internet of Things & Salesforce1- Platform APIs- Project: Controlling Christmas Lights using HTTP Class- Project: Flash lights upon new P1 Case using workflow & IFTTT (Live Demo)- Project: Temperature Monitoring using REST API (Live Demo)- Questions & Comments

Page 6: Control your world using the Salesforce1 Platform (IoT)

Internet of Things

• Interconnected things using low cost (usually) networkable devices

• Connect smart devices/physical objects/sensors

• Connecting devices to the Internet allows automation of anything from anywhere

Page 7: Control your world using the Salesforce1 Platform (IoT)

Salesforce1

Salesforce1 Platform(Force.com, Heroku, and ExactTarget Fuel)

Salesforce1 Mobile App

Page 8: Control your world using the Salesforce1 Platform (IoT)

Platform API: Salesforce Web Services

Did you know?

Common Uses

• Integrate external systems

• Load records with Dataloader

• Connect with IoT devices

60% of Salesforcetransactions are API calls

Page 9: Control your world using the Salesforce1 Platform (IoT)

Platform API: Salesforce Web Services

• Outbound– HTTP Class– WSDL2Apex– Outbound messaging– Streaming API

• Inbound– SOAP API– REST API– Custom web services

Page 10: Control your world using the Salesforce1 Platform (IoT)

Platform API: Salesforce Web Services

Type

• HTTP Classes 

• WSDL2Apex 

Advantages

• Highly customizable, request and response can be formatted in any way.

• Auto-generates Apex code to interact with a SOAP based web service 

Uses

• Callouts to simple or complex external systems. Custom parsing logic for all types of responses including XML, JSON, and Custom formats.

• Integration with external systems

Outbound

Page 11: Control your world using the Salesforce1 Platform (IoT)

Platform API: Salesforce Web Services

Type

• Outbound Messaging 

• Streaming API 

Advantages

• Triggered by workflow, automatic retries guarantee delivery 

• No need to poll for data, application is notified of changes 

Uses

• Integration with middleware applications

• Use in lieu of polling for record changes 

Outbound (continued)

Page 12: Control your world using the Salesforce1 Platform (IoT)

Platform API: Salesforce Web Services

Type

• SOAP API

• REST API

• Custom Web Services

Advantages

• Structured access to Salesforce data

• Simplified access to Salesforce data

• Implement custom logic

Uses

• External applications that interact with SF data

• Mobile applications, external web sites that pull data

• Exposing complex custom business logic to external apps

Inbound

Page 13: Control your world using the Salesforce1 Platform (IoT)

HTTP Class for Callouts• IoT devices frequently have a REST or JSON based API– REST– JSON-RPC

• Invoke callouts to devices using the HTTP class

• Use @future or the Queueable interface to invoke callouts from a trigger– Queueable is new in Winter 15 and allows events to be chained.  This can be helpful if you need to contact multiple devices and the actions are dependent.

• Need to control the local network and open firewall ports inbound from SF

Page 14: Control your world using the Salesforce1 Platform (IoT)

Project: Controlling Christmas Lights (HTTP Class)

Page 15: Control your world using the Salesforce1 Platform (IoT)

Project: Controlling Christmas Lights (HTTP Class)

• Configure endpoint under Remote Site Settings

                      Arduino Yun                                      Sainsmart relay board

Page 16: Control your world using the Salesforce1 Platform (IoT)

Project: Controlling Christmas Lights (HTTP Class)

Page 17: Control your world using the Salesforce1 Platform (IoT)

Project: Controlling Christmas Lights (HTTP Class)public class ChristmasLights {

  @Future(callout=true)  public static void doCallout(string action){       string URL = 'http://123.81.144.87:8800/arduino/' + action + '/go';         Http h = new Http();

HttpRequest req = new HttpRequest();  req.setTimeout(30000);

req.setEndpoint(url);req.setMethod('GET');

HttpResponse res = h.send(req);   }}

Page 18: Control your world using the Salesforce1 Platform (IoT)

Project: Flashing Lights (Workflow & IFTTT)

• No need to write code• Salesforce workflow sends email alert to IFTTT

   IFTTT Rule                                        Belkin Wemo Switch                   Light

Page 19: Control your world using the Salesforce1 Platform (IoT)

Project: Flashing Lights (Workflow & IFTTT)

Page 20: Control your world using the Salesforce1 Platform (IoT)

Inbound data to Salesforce

• REST API or Custom Web Service– Create a Connected App– Login to get a session token for use in API calls

• Custom Web Service exposed on a force.com site– Not particularly secure.  Anyone could execute the web service!

Page 21: Control your world using the Salesforce1 Platform (IoT)

Tessel(A microcontroller that runs Javascript)

Project: Temperature Monitoring (REST API)

Temperature probe

Page 22: Control your world using the Salesforce1 Platform (IoT)

‘grant_type=password&client_id=3M1234Z_r.QzrS7gqVEDhgIEgmfljZJ_I8eqZpdwZgzaZhMVU1vAv43VT37PimUNPUgHY5oABV3sH7AT0oYGx&client_secret=123456789090124&[email protected]&password=Basdfgavz!DPAB4MDJVLKxjdhTLKeAaGv7’

• grant_type=password• client_id= Consumer key from Connect App• client_secret = Consumer Secret from Connect App• username= Salesforce username• password= Password + Security Token

API returns JSON by default which is parsed to get the session token and instance URL:

...res.on('data', function(d) {var parsed = JSON.parse(d);var instanceURL = parsed.instance_url;var token = parsed.access_token;}

Project: Temperature Monitoring (REST API)OAuth Authentication – Username & Password

Page 23: Control your world using the Salesforce1 Platform (IoT)

var options = { port: 443,method: 'POST',hostname: instanceURL,path: '/services/data/v31.0/sobjects/Inbound_Data__c/',headers: {Host: 'na10.salesforce.com','Accept': '*/*',"User-Agent": "tessel",'Content-Type': 'application/json','Authorization': ‘Bearer ‘ + token}

var temperature = getTemperature();var requestBody = ‘{ “Temperature__c" : ‘ + temperature + ‘ }’;

var req = https.request(options, callbackFunction);req.write(requestBody);req.end();

Project: Temperature Monitoring (REST API)REST API Call

Page 25: Control your world using the Salesforce1 Platform (IoT)

Questions? Comments?

Page 26: Control your world using the Salesforce1 Platform (IoT)