Skip links

Mastering IoT with Salesforce: A Step-by-Step Guide for Developers

Jump To Section

Unleash the power of IOT in your business! 

An Introduction to Salesforce IOT

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.

Power of Salesforce IoT: Streamlining Workflow Automation

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:

The Salesforce IOT 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:
  3. Type: Number
  4. Field Label: Level
  5. Field Name: Level
  6. Length: 18
  7. Decimal Places: 0
  8. Add an Asset Id:
  9. Type: Text
  10. Field Label: Asset Id
  11. Field Name: Asset Id
  12. Required: true
  13. Length: 80
  14. 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.

  15. Create a new Context:
  16. Name: Coffee Hopper ContextKey Type: StringSalesforce 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.

  17. Create a new Orchestration:
  18. Name: Coffee Hopper OrchestrationContext: Coffee Hopper ContextCreate 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.

  19. Send event data:
  20. Click the POST method radio buttonUpdate the base url to be /services/data/v41.0/sobjects/Coffee_Hopper__eRequest 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!

Priti Patil

Priti Patil

Latest Reads

Subscribe

Suggested Reading

Ready to Unlock Yours Enterprise's Full Potential?

Adaptive Clinical Trial Designs: Modify trials based on interim results for faster identification of effective drugs.Identify effective drugs faster with data analytics and machine learning algorithms to analyze interim trial results and modify.
Real-World Evidence (RWE) Integration: Supplement trial data with real-world insights for drug effectiveness and safety.Supplement trial data with real-world insights for drug effectiveness and safety.
Biomarker Identification and Validation: Validate biomarkers predicting treatment response for targeted therapies.Utilize bioinformatics and computational biology to validate biomarkers predicting treatment response for targeted therapies.
Collaborative Clinical Research Networks: Establish networks for better patient recruitment and data sharing.Leverage cloud-based platforms and collaborative software to establish networks for better patient recruitment and data sharing.
Master Protocols and Basket Trials: Evaluate multiple drugs in one trial for efficient drug development.Implement electronic data capture systems and digital platforms to efficiently manage and evaluate multiple drugs or drug combinations within a single trial, enabling more streamlined drug development
Remote and Decentralized Trials: Embrace virtual trials for broader patient participation.Embrace telemedicine, virtual monitoring, and digital health tools to conduct remote and decentralized trials, allowing patients to participate from home and reducing the need for frequent in-person visits
Patient-Centric Trials: Design trials with patient needs in mind for better recruitment and retention.Develop patient-centric mobile apps and web portals that provide trial information, virtual support groups, and patient-reported outcome tracking to enhance patient engagement, recruitment, and retention
Regulatory Engagement and Expedited Review Pathways: Engage regulators early for faster approvals.Utilize digital communication tools to engage regulatory agencies early in the drug development process, enabling faster feedback and exploration of expedited review pathways for accelerated approvals
Companion Diagnostics Development: Develop diagnostics for targeted recruitment and personalized treatment.Implement bioinformatics and genomics technologies to develop companion diagnostics that can identify patient subpopulations likely to benefit from the drug, aiding in targeted recruitment and personalized treatment
Data Standardization and Interoperability: Ensure seamless data exchange among research sites.Utilize interoperable electronic health record systems and health data standards to ensure seamless data exchange among different research sites, promoting efficient data aggregation and analysis
Use of AI and Predictive Analytics: Apply AI for drug candidate identification and data analysis.Leverage AI algorithms and predictive analytics to analyze large datasets, identify potential drug candidates, optimize trial designs, and predict treatment outcomes, accelerating the drug development process
R&D Investments: Improve the drug or expand indicationsUtilize computational modelling and simulation techniques to accelerate drug discovery and optimize drug development processes