đ Integrating Connections in a Sitecore Personalize Decision Model
In this post, we’ll explore how to leverage a connection (created in our previous blog) within a Sitecore Personalize Decision Model to fetch or post data using a programmable node and a Data System element.
The goal is to build a simple canvas where:
-
A programmable node outputs Client Credential JSON.
-
This output is consumed by a Data System element, which then uses the selected connection to call an API.
đŻ Objective
Create a Sitecore Personalize Decision Model with:
-
A programmable node that returns JSON (Client ID & Client Secret).
-
A Data System element that uses the output of the programmable node as input and calls the external API using a predefined connection.
đ ️ Step-by-Step Guide
✅ Step 1: Access Decisioning in Sitecore Personalize
-
Navigate to your Sitecore Personalize environment (Production or Non-Production).
-
Click on the “Decisioning” menu from the top ribbon (see screenshot below for reference).
✅ Step 2: Create a New Decision Model
-
Click the “Create” button.
-
Choose a variant name (e.g.,
demov1). -
Proceed with the default steps to create the variant.
The creation flow is straightforward – just follow the prompts.
✅ Step 3: Open the Variant Canvas
-
Click on the newly created variant.
-
Select the “Canvas” view to start designing your logic flow.
✅ Step 4: Configure the Canvas Logic
We’ll keep the canvas simple for clarity:
đš Node 1: Programmable Element (GetClientCredential)
-
Drag and drop a Programmable element onto the canvas.
-
Rename it (e.g.,
GetClientCredential). -
Use the following JavaScript code:
đ§ Important: Make sure the return type is set to "Map" in the settings.
Returning JSON without selecting “Map” will throw an error.
This node will output a JSON object with two keys: clientId and clientSecret.
đš Node 2: Data System Element (XM Cloud Auth v1)
-
Drag and drop a Data System element.
-
Name it appropriately (e.g.,
XM Cloud Auth v1). -
When prompted, select the connection you created earlier (refer to this guide).
đ Connect the Nodes
-
Set the output of
GetClientCredentialas the input for thisData Systemelement. -
Click Edit on the Data System element to open its configuration panel.
đ§Š Map the Input Fields
-
You will see fields that require the
clientIdandclientSecret. -
Populate them using the output keys from the programmable node:
Ensure you use the exact output key names returned by the programmable element.
▶️ Testing the Canvas
-
Once your setup is complete, run the canvas.
-
Observe each node executing in sequence.
-
If configured correctly:
-
The
GetClientCredentialnode will return JSON. -
The
XM Cloud Auth v1node will use this data and make an API call via the connection.
-
✅ If successful, you should receive an Access Token or a success response — confirming the connection is working as expected.
đ Final Thoughts
This demo walks through a minimal working setup to illustrate how Programmable nodes and Data System elements can work together with external connections in Sitecore Personalize.
Such a setup is extremely useful for:
-
Authentication flows (OAuth 2.0).
-
Fetching dynamic content from APIs.
-
Interacting with external systems in real-time.
Comments
Post a Comment