The Fundamental Futurist

An Introduction to Salesforce IOT

Unleash the power of IOT in your business! 

2018 has shown us the full potential of connected devices. Not only are people connected over the internet, but our gadgets, appliances and phones are all communicating with one another in some way. This opens up the space of IOT for deeper exploration and creates new opportunities in the space for all developers. Consumers have more power and data, and the convenience that smart devices bring is unmatched.

This is the new world of IOT everywhere. The Internet of Things has revolutionized the way that humans interact with technology, making their lives a lot easier. With sensors inside your car providing maintenance and service request updates, you can drive that much more safely. With smart refrigerators ordering groceries that need to be ordered, you’re living a life of convenience. The concept of IOT is expanding and brands are chiming in to create the best possible experiences for their customers.

Salesforce IOT

Salesforce, one of the foremost pioneers in cloud computing, has been excelling in the IoT space for quite some time now. They’re offering secure and scalable solutions that allow organizations to transform their business models with easy-to-use point and click configurations. From a developer’s standpoint, the ease of use has made the technology more accessible and setting up has never been simpler. Let’s take a deep dive into the world of Salesforce IoT.

Salesforce offers two main services under the IOT banner. The first one is a platform called IOT Scale, which is separate from their existing platform force.com. You can have the IOT edition org and set a unique point and click configuration model based on your business needs.

The second offering provided by Salesforce is the IOT explorer. This option is built on the Force.com platform and will be the focal point for this article ahead. It’s available to all developers as a part of their winter 18 release, and developers can get the latest updates from the website itself.

How does it work?

Salesforce gets data input from connected devices in the ecosystem and has predefined rules and logic to trigger an action. This input-output relationship makes it easier for developers to create IOT experiences that scale better.

The Salesforce IOT is a state machine, which operates as a nonlinear workflow engine. It manages the transition of objects and people from one defined state to another. That’s why it’s beneficial to developers who can create workflows that react to different events and contextual data in organic ways. Using this method. you don’t have to predefine a complete set of sequences to cover all possible combinations of events and connected data.

Here is a list of commonly used terms that are important to understand:

Table

The Salesforce IOT Dataflow:

Dataflow

Steps to enable Salesforce IOT for your business

It’s a simple stepwise process to leverage the power of the Salesforce IOT platform for your business. Follow the steps mentioned below to unlock Salesforce’s complete potential.

A. Enable IOT Explorer

You can start by creating a new ‘Winter 18 Developer Edition’ org by quick searching for ‘IOT Explorer’ in setup. You need to switch to lightning experience if you haven’t already, as it works only in lightening experience mode.

  1. Create a new Winter ‘18 Developer Edition org
  2. Create an Account record: Universal Containers.
  3. Create a related Contact record: Dave Stanton.
  4. Add a custom field to the Asset object: (Add a checkbox custom field: Subscription)
  5. Create two Asset records: (Both records should lookup to the account and contact you previously created. One asset should have Subscription checked. The other asset should have Subscription unchecked.

B. Create Platform Events

This step is similar to that of custom object, and you can start creating platform events by quick searching in the setup option. We will use this to store our incoming event data.

  1. Create new deployed platform named Coffee Hopper.
  2. Add a Level custom field:
    1. Type: Number
    2. Field Label: Level
    3. Field Name: Level
    4. Length: 18
    5. Decimal Places: 0
  3. Add an Asset Id:
    1. Type: Text
    2. Field Label: Asset Id
    3. Field Name: Asset Id
    4. Required: true
    5. Length: 80

C. Create Context

‘Context’ is a combination of static data (stored in a custom object) and event data (stored in platform events). You can quick search for ‘Context’ in the setup option and create a new one.

You can add platform event to context and include the key as well. The ‘key’ will be a unique field on the platform event, similar to a Product Id or a number.

E.g. you can have ‘fridge’ details stored under ‘product’, which would be a static data point. This data point will have a product ID, a name, and some static data about the fridge manufacturer, quality, ratings, etc. You will also have a platform event where you can store incoming events. The platform event will have a unique field for product ID in-built. This common field represented on a custom object and a platform event will be the key for developing context.

Remember – Field names need be the same on customer objects and events, but their data type should be the same to develop consistency in the system.

  1. Create a new Context:

Name: Coffee Hopper Context

Key Type: String

Salesforce Object: Asset

Object Key: Asset

     2.   Add a platform event to the context:

Context: Coffee Hopper Context

Platform Event: Coffee Hopper

Key: Asset Id

D. Build an Orchestration

The process of building an orchestration is similar to that of using a process builder, where you can set conditions and rules to trigger actions. An orchestration is when you design the state machine, which subsequently combines the different possible states for a device (e.g. Normal, Warning, Fault, etc.).

E.g. When we want to transition states based on the level of coffee available in a coffee hopper, we can set it to measure against percentage of levels. If the levels fall below 40%, the machine can state that the system is in ‘Warning state’. When it drops below 10%, the device can be made to be in ‘Fault state’. You can quick search for ‘Orchestration’ in the setup.

  1. Create a new Orchestration:

Name: Coffee Hopper Orchestration

Context: Coffee Hopper Context

Create additional states:

      2. Click Add State

3. Again click Add State

4. Rename your states by clicking on the text labels:

Green: Normal

Red: Fault

Purple: Warning

      5. Click the ellipsis for the Warning state:

Click Move state up so that our states and colors are in a more logical sequence

      6. Add transitions to your states:

Normal

When: Coffee_Hopper_e

Condition: Coffee_Hopper__e.Level__c < 40

Transition: Warning

Warning

When: Coffee_Hopper_e

Condition: Coffee_Hopper__e.Level__c < 10

Transition: Fault

Fault

When: Coffee_Hopper_e

Condition: Coffee_Hopper__e.Level__c < 90

Transition: Normal

      7. Click Save

8. Click Activate.

E. Testing your Orchestration

To test the orchestration, you need to send a dummy platform event and check to see if the state transition occurs or not. In simpler terms, you need to see if the output of the system is desirable, given the right input. You can use the workbench rest explorer and send a post request with certain event data.

  1. Send event data:

Click the POST method radio button

Update the base url to be /services/data/v41.0/sobjects/Coffee_Hopper__e

Request Body: { “Asset_Id__c”: “abc123”, “Level__c”: 100 }

2. Click the Execute button

3. Look in the response information to ensure you see success: true

4. Go back to your orchestration browser window.

5. Click on the Traffic tab within the orchestration page.

6. Confirm you have one instance in normal state

F. Overview through Traffic view

Traffic view shows you a pictorial representation of all your states, displaying them in different colours and states. Salesforce automatically shows you the traffic view, and it’s a handy tool when understanding the flow of information.

Keep experimenting with this amazing piece of software and making IOT a reality for your business!

About Author
Priti Baburao Patil
Salesforce Platform Specialist
Priti is a Certified Salesforce Platform Specialist with over 5 years experience in Sales, Service, Community and Marketing Clouds of Salesforce.
She has recently started her own technical blog on challenges and tips around Salesforce: https://sfdcninjablog.wordpress.com/
Outside work, her interests lie on crafts and writing about personal experiences.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: