Strategy Crafter Tutorial 1 — Happy Birthday

Alex Edelstein
8 min readMay 18, 2018

--

return Home Not an official Salesforce product.

After installing Strategy Crafter, you will probably have no strategies in your org. Let’s build a simple one.

In this scenario you’re building a strategy to make recommendations to service center agents. You’d like to recommend that they wish a contact a Happy Birthday if the day is correct.

1. Create a New Strategy

Go to the menu and select New Strategy, and create a strategy called BirthdayStrategy. You should see this:

2. Define a Proposition.

Go to App Launcher and select proposition. (Don’t see Proposition there? Check out section 2 of this page.)

Fill out the proposition with the text that you want your agents to see:

warning: The Name field has to have no spaces or funky characters.

note: The proposition shown here has two custom fields. We encourage you to add custom fields to your propositions. They’re a great way to create powerful decisioning strategies.

Ok, what do we do with the required Action Reference? Well for now, the only action that you can reference from a proposition is the flow that you want to run when a recommendation created from this proposition is accepted (i.e. clicked on). So let’s pause and go create our simple one-screen flow.

3. Create and Activate a Flow

Every Proposition needs to reference an Active Flow. If you’re unfamiliar with Flows, you’ll find the main Flow setup in Setup → Flows in Salesforce. You may want to try out this introduction to Flows.

Your initial flow doesn’t have to do much, so let’s create a New Flow and drag a Screen onto the canvas:

Click on the Screen to configure it. We’ll drag a single Display Text field over to the canvas:

Configure it to say “Please wish the customer a happy birthday.”

Save the flow. You’ll need to give names to the display text field, the Screen, and the Flow itself. Close the flow.

Activate the flow here:

Pay close attention to the Unique Name field.

Use the Unique Name of the flow as your Action Reference value in your Proposition:

3. Adding Custom Fields to your Proposition

We want to filter our Proposition by Category (even though we only have 1 in our demo tutorial here, so we need to add a Category field to the Proposition. If you’re not familiar with this, you may find this Trailhead useful. From the Setup menu, navigate to your Proposition object and go to its Fields section to create a Category custom field. You might want to also create a Ranking field while you’re there.

4. Build Your Proposition

We’ve finished setting up our proposition with a couple of values for the flow and the custom fields:

5. Load Your Proposition Into Your Strategy

One of the fundamental concepts of strategies is that you start by loading propositions into them and end by receiving the “winning” subset.

To load our propositions, we’ll add a second node. right-click on the root node and select Add Child Node (or select New Node from the menu). We’ll configure this node to load all propositions that have a Category of Personal. Of course, there’s only one proposition defined, so we could just as easily have loaded all propositions with Name equal to ‘HappyBirthdayWish’.

warning: for expressions, you need to use single quotes with your string values.

Click Save. You’ll notice that the Strategy Crafter starts saving your changed metadata in the background. That is not the normal way Salesforce works, and it may take getting used to. If you have users making use of this strategy, they’ll immediately be impacted by every change you make. (It would make sense to provide a mode for draft creation and deployment support. This is the place where we remind you that this is just intended as a short-term utility until Salesforce delivers a full-featured Strategy Builder).

6. Install the NBA Component

Let’s test out our strategy, even though it doesn’t yet attempt to determine whether a birthday recommendation is appropriate or not.

The NBA Component is a lightning component. It can be used in classic mode using Lightning Out and Visualforce, but in this tutorial we’ll assume you’re in Lightning mode.

We’ll add our component to the Case page.

  1. Go to any Case page (not Setup or Object Manager) and select Edit Page from the cog menu.
  2. Drag the “Einstein Recommendations” component from the palette to an appropriate location.

Warning: the Einstein Recommendations component must currently be placed on Record Pages. That’s the page type where you’re looking at a specific single record like a case or account. On other types of pages,like Home Pages, you won’t see the component in the palette of App Builder.

Warning: it’s easy to confuse the Einstein Recommendations component used by Next Best Action with the older “Recommendations” component that may be present:

The component attempts to immediately “go live” and request some propositions, but since you haven’t had a chance yet to specify a Strategy Name, it shows an Invalid Component error.

3. Enter “BirthdayStrategy” for the StrategyName. If everything is working properly, you will immediately see your proposition show up here in design mode!

4. Click Save and then Activate your page. Since you are probably doing this on a Sandbox, you probably want to click Assign as Org Default. Doing so will likely cause all users of the org to immediately see the Case Layout you’ve just created. If you’re working on an org with live production users, then you probably don’t want to change the org default, and instead use Record Types and other tools so you can view this new Case Layout while everyone else continues to work with the old Layout for the time being.

5. Click ‘Back’ and you should be back in your Case page, with your Next Best Action recomendation.

That’s a good start, but we need to enhance our nascent strategy so that this recommendation only shows up on people’s birthdays. So let’s go back to the Strategy Crafter.

6. Right click on the root node and add a Gate node. Give it the name “OnlyIfItsYourBirthday” and click on the plus button to create a gate filter.

Each gate filter corresponds to a particular child branch. We want to select our sole branch that contains our HappyBirthday LoadBirthdayProps node. But when we go to try and select it, the list box is empty:

Why is that? Well, it’s because we need to insert this Gate node between the root node and the Load Propositions node, and we haven’t been able to do that yet.

Click Save and the strategy will be updated. Your Gate node is in a dubious state, and one could argue that the crafter shouldn’t allow it to be saved like that. But we need a way to let you manipulate it into place. Here’s where things stand after you save:

Time to use another powerful Crafter feature. click on LoadBirthdayProps and drag it to the OnlyIfItsYourBirthday gate node. That will immediately reposition things.

Now click again on the gate node. Because you have a child branch available, you can properly configure your gate filter:

By default, the gate filter is open. But we want to block anything that doesn’t match the birthday and month. So click on the configuration button (which now says “true”) and then click on Formula Mode.

The Expression Builder UI is pretty basic. To create our filter, we’re going to need to tap into the power of Salesforce formulas. So click the Formula button.

Gate nodes pass through all the propositions of a specified child branch if the condition of the Branch gate is met. The formula we’ll use is:

MONTH($Record.Contact.Birthdate) == MONTH(TODAY()) && DAY($Record.Contact.Birthdate) == DAY(TODAY())

$Record is an important global variable that represents the recordId of whatever page is hosting the NBA component that generated this request. In our case, it’s going to be the recordId of the case in question. You can see that we can use dot notation to traverse to the Case’s associated Contact, and from there to the Contact’s Birthdate field.

warning: Remember that custom fields use the __c syntax, lookup relationships use __r, and external objects use __o

The rest of the formula is straightforward use of Salesforce formulas.

To test out the impact of this, we’ll need to change the birthdate of the Case’s Contact. Do so, and you’ll see that unless the day and month of the Contact’s birthdate match the current day and month, this proposition will not be visible as a recommendation.

7. Know Where to Find Error Messages

Once you start building your own strategies, sooner or later you’re going to get the “Something went wrong” message shown below and to the left:

This image demonstrates where to find the actual admin-targeted error message: in your browser’s built-in debug tools. Access by right mouse clicking on your web page and selecting ‘Inspect’ (for Chrome. other browsers are similar in function). Then click on the Console tab and look for something like the error message shown above and to the right.

For more information, and to save yourself headaches, make sure to read the Testing and Troubleshooting section of the pilot documentation.

You’ve finished the first tutorial.

Move on to Tutorial 2.

--

--