Start tracking your progress
Trailhead Home
Trailhead Home

Create an Orchestration

Learning Objectives

After completing this unit, you’ll be able to:
  • Describe how orchestrations work.
  • Summarize what an orchestration is.
  • Create a simple orchestration.
  • Create a rule to trigger an action based on an event.

What Is an Orchestration?

In Salesforce IoT orchestrations, the actions and interactions triggered by events don’t have to follow a specific, linear path. You can think of each point along the path as a state, where you can tailor the customer experience to what is occurring with the device at that moment in time. Customers and devices can move back and forth between these states. How? Salesforce IoT is a state machine: a nonlinear workflow engine that consists of states that reflect strategic groupings of objects or people. You define rules that trigger actions or outputs for each state. Incoming, real-time event data, combined with historical customer and contextual data, determines the state a product, or set of products, is in at any point in time. A product can transition from state to state as data flows in. An object or person is in only one of the defined states at any given time, and you can take any number of personalized actions on an object or person while they’re in that state.

One thing that makes the Salesforce IoT orchestration engine super awesome is that it lets admins and business analysts use clicks, not code, in days, not months, to turn a business or customer problem into a set of defined rules that use state-based logic to create associated customer actions. This trusted, low-code technology lets any Trailblazer rapidly experiment, launch, test, and refine their IoT strategy.

Create an Orchestration

In Salesforce IoT, you create an orchestration and associate it with a context. This is how the orchestration knows what data on which to execute.

To continue with our Flying Fridge use case, let’s create an orchestration that uses the platform event, Asset object field customizations, and context we already created. When deployed, the orchestration creates a service case for a refrigerator that has an internal temperature of over 50 degrees.

Create a case automatically when a fridge gets too warm? Sounds pretty cool.

Let’s start by creating an orchestration for our Flying Fridge use case.
  1. From Setup, enter IoT in the Quick Find box, then select Orchestrations.
  2. Click New Orchestration.
  3. For Name, enter Flying Fridge Maintenance.
  4. For Context, select Flying Fridge Context.
  5. Click Create.

You now have a blank orchestration that looks like this.

Flying Fridge Maintenance orchestration with no rules

Create States and Rules

Now we’re ready to create the orchestration states and rules. States reflect strategic groupings of objects or people. Rules are the logic that tells an orchestration what to do. Rules are made up of events, conditions, actions, and, optionally, transitions. You use the same expression syntax used in Salesforce formula fields to create your rules.

For our use case, we create a rule that tells the orchestration to move a refrigerator from the Default state to a High Temperature state if the fridge sends a temperature event of more than the maximum high temperature specified for the asset. When the fridge enters the High Temperature state, a service case is automatically created.

Let’s start by creating the states. The Default state already exists for each new orchestration. You can change the name by double-clicking Default, but for our purposes we leave it as is.

Let’s create the High Temperature state.

  1. In your Flying Fridge Maintenance orchestration, under the Default state, click + Add State .
  2. Underneath the Default state, double-click New State 2, and enter High Temperature.

Your orchestration looks like this.

Orchestration with two states: Default and High Temperature

Now, let’s add the rule to the Default state that moves any refrigerator that sends a temperature event of more than the maximum high temperature specified for the asset (50 degrees) from the Default state to the High Temperature state.



Note: In Salesforce IoT, when an event first comes in, every device starts in the Default state. The rules specified in the Default state determine when and under what conditions the device moves to another state.

  1. In the Flying Fridge Maintenance orchestration you created, in the Default state under When, click the dropdown arrow, and select “Flying_Fridge_Event__e”.
  2. In the Condition field, enter Flying_Fridge_Event__e.temperature__c >Asset.Max_High_Temp__c .
  3. Under Transition, select High Temperature.

And now let’s add the rule to the High Temperature state that automatically creates a service case when the asset enters the High Temperature state.

  1. In the High Temperature state, under When, select State Entered.
  2. Under Actions, click Add an action, and select Salesforce Record.
  3. In New Salesforce Output Action, under Object, select Case.
  4. For Action Type, select Create.
  5. Click Next.
  6. Click Add Field.
  7. For Field, select Subject.
  8. For Value, enter "Created by Salesforce IoT". Make sure to include the quotation marks.
  9. Select Make each executed action’s response event available to the orchestration.
  10. For Response Name, enter caseResponse.
  11. For Action Name, enter Create Case.

    Your screen should look like this.

    New Salesforce Output Action: Create a Case dialog box

  12. Click Finish.
  13. In your orchestration, click Save.

    You should get a green confirmation banner. If you have any errors, go back through the steps and recreate the rules.

Your orchestration looks like this.

Orchestration with completed rules for both the Default and High Temperature states

Our orchestration is ready to activate and test. Let’s put our Flying Fridge Maintenance orchestration into action.