🔌 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:

  1. A programmable node that returns JSON (Client ID & Client Secret).

  2. 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

  1. Navigate to your Sitecore Personalize environment (Production or Non-Production).

  2. Click on the “Decisioning” menu from the top ribbon (see screenshot below for reference).




✅ Step 2: Create a New Decision Model

  1. Click the “Create” button.

  2. Choose a variant name (e.g., demov1).

  3. Proceed with the default steps to create the variant.

The creation flow is straightforward – just follow the prompts.


✅ Step 3: Open the Variant Canvas

  1. Click on the newly created variant.

  2. 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:

(function () { return { clientId: "please enter your client ID", clientSecret: "please enter your client secret" }; })();



🧠 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 GetClientCredential as the input for this Data System element.

  • Click Edit on the Data System element to open its configuration panel.

🧩 Map the Input Fields
  • You will see fields that require the clientId and clientSecret.

  • Populate them using the output keys from the programmable node:



    ClientCredential.clientId     ClientCredential.clientSecret

Ensure you use the exact output key names returned by the programmable element.



 


▶️ Testing the Canvas

  1. Once your setup is complete, run the canvas.

  2. Observe each node executing in sequence.

  3. If configured correctly:

    • The GetClientCredential node will return JSON.

    • The XM Cloud Auth v1 node 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.


🔁 Related Reading:

Comments

Popular posts from this blog

Solrcloud With Zookeeper -Single server setup

Render Sitecore Experience Forms Using Sitecore XP 10.4 with a Headless Approach (Next.js + JSS SDK)

Next.js with XM Cloud EDGE and GraphQL