<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Santiago T on Medium]]></title>
        <description><![CDATA[Stories by Santiago T on Medium]]></description>
        <link>https://medium.com/@santroc.adm?source=rss-8836f202aa76------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Santiago T on Medium</title>
            <link>https://medium.com/@santroc.adm?source=rss-8836f202aa76------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:52:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@santroc.adm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Salesforce Flows: Using the Transform Element to avoid nested loops]]></title>
            <link>https://medium.com/@santroc.adm/salesforce-flows-using-the-transform-element-to-avoid-nested-loops-850f9a0acca9?source=rss-8836f202aa76------2</link>
            <guid isPermaLink="false">https://medium.com/p/850f9a0acca9</guid>
            <category><![CDATA[salesforce-admin]]></category>
            <category><![CDATA[salesforce-automation]]></category>
            <category><![CDATA[salesforce]]></category>
            <dc:creator><![CDATA[Santiago T]]></dc:creator>
            <pubDate>Mon, 24 Feb 2025 23:00:34 GMT</pubDate>
            <atom:updated>2025-02-24T23:00:34.615Z</atom:updated>
            <content:encoded><![CDATA[<p>Having recently worked on a particular business case we were presented with the opportunity to use the Transform element for the first time resulting in a simplified more scalable automation</p><p><strong>Business Case:</strong> Replicate the Service Appointment Broadcasting functionality where one can select through a Screen the users (Service Resources) that receive a set of Appointment requests who can then decide to pick them up. Due to how we use the data model and project constraints, using the standard functionality was not an option.</p><p>This is way the model is set up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yduc9jjV-gbghc_4" /><figcaption>Service Appointment Broadcasting Data Model</figcaption></figure><blockquote><em>Schedule Broadcast’s Service Appointment field is custom, you will understand why if you keep reading 🙂</em></blockquote><p><strong>From now on</strong>*: Schedule Broadcast (SB), Schedule Broadcast Appointment (SBA) and Schedule Broadcast Appointment Resource (SBAR), users and service resources will be used interchangeably.</p><p>We need to know two things: the Service Appointments to be broadcasted and the users it will be broadcasted to, so for the following case: Broadcasting <strong>two</strong> Service Appointments to <strong>four</strong> service resources we would end up with: 1 SB record, 1 SBA record and 4 SBAR records per each appointment. Additionally, SBAs need to have the SB and Service Appointment reference at the moment of creation and SBARS need to have their SBA and Service Resource references set as well.</p><p>This required maintaining a strict record creation order: first SBs, then SBAs, and finally SBARs. Each record must reference the higher-level record by creating it first (when record IDs are generated). To avoid DML operations within loops -remember good practices-, which can hit resource limits, this can be achieved using nested loops like this:</p><p><strong>Flow brief overview: </strong>The flow is launched from a custom List View button; the user selects the Appointments to broadcast:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_v_t8TjI-4KCxYWW6dJN9w.png" /><figcaption>This first selection will be stored in the flow as a Service Appointment collection</figcaption></figure><p>Clicking “Broadcast Visits” launches the flow, the broadcaster sees a list of selectable users to broadcast the Appointments to, after selecting and hitting next, Appointments are broadcasted</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HuUXfAMq4OU0FjwIp3BwLw.png" /><figcaption>This classified list of Service Resources will be stored in the flow as a Service Resource collection</figcaption></figure><p><strong>Flow Version 1:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/0*HF0ORzjQgySAdcEO" /><figcaption>Here we have our first level of records (SBs), a simple loop gets the job done.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/0*h0fRhV43FGOrkVUo" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*7iqeteefrZhXa2SSQx72Eg.png" /><figcaption>For this first double loop since the SBs are one per Service Appointment, we are just using the double loop to reference both collections at the same time (A few releases ago the inner pointer would not work!), so this is not so bad</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*2TJMCQ582xSE1kdt" /><figcaption>However, for this second double loop case, the inner Flow will go through the whole Service Resource collection over and over again, which is really inefficient given the list of Service Appointments and Resources can be much longer and we risk running into some flow execution limits. <strong>You can ignore the “Message” assignments.</strong></figcaption></figure><p>So here is when the Transform element plus other tweak come into play:</p><p><strong>Flow Version 2:</strong></p><p>We created a custom Service Appointment lookup field on the SB level to “save” the Service Appointment Reference there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/0*5SPaz7fkok3181Za" /><figcaption>The first loop remains unaltered, only that now each SB gets the Service Appointment referenced</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/0*ZZU2zU3mbXoGqKHa" /><figcaption>With the Service Appointment reference now available, we can get rid of the double loop which improves Flow readability</figcaption></figure><p>Transform element in action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/0*KmrM_Elpp0qx5KL6" /><figcaption>The third loop is where the Transform element comes into play</figcaption></figure><p>Let’s go into detail for this element:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*57U4oOa64jdS4ERj" /><figcaption>Source Data: Collection of Service Resources and Current SBA Record | Target Data SBAR records</figcaption></figure><p>The mapping is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*QF_JlKgdroVhGngfkdvO4A.png" /></figure><blockquote>Above we are basically telling the flow: I have these four service resources, create four SBAR records and relate them all to the current SBA, then repeat until you end the loop. We eliminated the necessity of having a nested loop.</blockquote><p>In this new version we have a simplified flow that is:</p><p>i) More efficient</p><p>ii) Easier to understand and maintain.</p><p>Some final thoughts: One point I often encounter is that while Flow is a powerful tool for creating impressive automations (like this one😜), it also underscores the importance of building holistic solutions. Flow bridges a gap by offering a user interface (UI), but in some cases, this UI can actually become a hindrance, making the logic harder to understand for outsiders — such as colleagues who need to add functionality or take over the project. It’s important to keep the pros and cons in mind. If this were built with code, it might be clearer and “cleaner” (if you know what I mean). However, a developer isn’t always an option.</p><p>I hope this article helps those looking to simplify their automations or learn how to use the Transform element, making it a valuable tool in their arsenal for building the best solutions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=850f9a0acca9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Salesforce Einstein Bots: How to send data to an Einstein Bot before starting a conversation…]]></title>
            <link>https://medium.com/@santroc.adm/salesforce-einstein-bots-how-to-send-data-to-an-einstein-bot-before-starting-a-conversation-4ddbe5fee87c?source=rss-8836f202aa76------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ddbe5fee87c</guid>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[einstein-bots]]></category>
            <dc:creator><![CDATA[Santiago T]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 16:37:18 GMT</pubDate>
            <atom:updated>2023-11-03T13:24:49.883Z</atom:updated>
            <content:encoded><![CDATA[<h3>Salesforce Einstein Bots: How to send data to an Einstein Bot before starting a conversation (Enhanced and Standard)</h3><p>Having recently worked in a Service Cloud project we had the need to send data to a Salesforce Einstein Bot automatically to fulfill a particular business case (More details about it below), with this post I want to share a guide on how this can be achieved with both an Enhanced and an Standard implementation (Standard implementation details are added as an annex at the end), hopefully you will find it useful for your own implementations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*aF_-EtSUO3Wz7knc0fjzVg.jpeg" /></figure><p><strong>Business Case: </strong>The bot needs to start-up on a different dialog depending on the button it is being called from, this inevitably includes a development portion but from a configuration standpoint we can achieve 90% of the goal.</p><p>The methods varies as I mentioned previously, I will start with the Enhanced implementation.</p><ul><li><strong>Assumptions:</strong> You have a chat button already configured and running and it is correctly connected to an Einstein Bot. My set-up has the Embedded deployment added to a VisualForce Page within my Salesforce Org for testing purposes, basically just pasted the code snippet Salesforce generates for you in an empty VisualForce Page.</li></ul><h3><strong>Enhanced Channel implementation</strong></h3><ol><li>Head over to <strong>Set Up &gt; Messaging Settings</strong> and click over your Messaging in-App and Web (MiAW) channel’s name, this will open up the Messaging Settings screen:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DwnvIZI-s7EERPeAw3HjlA.png" /><figcaption>Messaging Settings Screen</figcaption></figure><p>2. Create a new custom parameter to store a value that will later let us define the dialog that needs to be opened, custom parameters are meant to be used along with Pre-chat forms, more on that later. Click the “New” button in the right to create a custom parameter, by default the parameter’s name, API name and channel variable name will be the same, <strong>it is recommended to leave them as is, define a maximum length, </strong>an example of how mine looks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OBJM45bS3q5a_aBunr1gLQ.png" /><figcaption>Custom paramete section</figcaption></figure><p>3. Create a new parameter mapping, this will “connect” our parameter to a Flow that will enable us to check the value and modify the behavior of the bot as required<strong>, </strong>click the “New” button, select the custom parameter we created in the previous step and give a name to the Flow variable name, for the sake of simplicity I will use the same name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1yHpYiqZYYFaoXIrLKj8Cw.png" /><figcaption>Mapping of the custom parameter</figcaption></figure><blockquote><em>This flow variable works the same way as the well known “recordId” variable does, in order to use it go to the Omni-Flow you have defined for your channel and create a new variable available for input with the exact same name, with this every time a conversation enters through web chat and if a value is sent to the custom parameter it will be captured by the Flow</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZW6vALeaa_WdMecpc8J5w.png" /><figcaption>Creating flow variables for our custom parameters</figcaption></figure><blockquote>You can then add an “Update record” to your Omni-Flow to store the value of the custom parameter:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*4rL8W-in3sTYaH_3g7eciw.png" /></figure><p><a href="https://help.salesforce.com/s/articleView?id=sf.miaw_map_messaging_2.htm&amp;type=5">Official Salesforce documentation detailing the process briefly explained above</a></p><p>4. Now we need to enable Pre-chat forms for our MiAW button, head over <strong>Setup &gt; Embedded Service Deployments</strong> and click over the more actions menu &gt; View:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*sLVL12yN9Jedt170yZ2LAQ.png" /></figure><p>That will display the following screen</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TqkcSN1bgRbnyVm7JJx3SA.png" /><figcaption>MiAW Web Deployment Settings page</figcaption></figure><p>5. Click on <strong>Edit Pre-Chat &gt; Check “Activate the pre-chat feature” checkbox</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*fQDkNHEHtI30Wzbbzn063g.png" /></figure><p>6. Scroll down to the “Hidden Pre-Chat Fields” and move the parameter we created in <strong>Step 2</strong>, save the configuration by clicking on the Save button in the bottom right corner:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y3gTmFRORTPXC8IO2T45Vw.png" /><figcaption>Adding our custom parameters as hidden fields</figcaption></figure><p>This will take you back to the Embedded Deployment’s settings screen, over the top right corner click “Publish”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*Z5qUnjjQaFaBJsBXK6GB1A.png" /></figure><blockquote><em>Bear in mind that this will send an email to all Salesforce users when the site is ready as MiAW uses an Experience Cloud site, to circumvent users receiving this email you can go to </em><strong><em>Set up &gt; Deliverability &gt; Access Level: No access</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*jCEXnPLuxqP8x49oLhSKLQ.png" /><figcaption>Disable emailing for all users</figcaption></figure><p>You can then go back to the embedded mesagging settings page and keep updating until the “Published on” date is updated, at that point you can re-enable Deliverability Access level back to normal, publishing usually takes a few minutes.</p><p>7. We now need to create a field to save the value that will be fed to the bot, go to <strong>Object Manager &gt; Messaging Session</strong> and create a new field, use the same Name we have used before, it is also important that the Field type = String (Text) and the field length matches the one defined in Step 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqQVUfAmDeYkYLytZOISGg.png" /><figcaption>Field created to store custom parameter value</figcaption></figure><p>8. Now we will create a Flow to read the value in the “openingDialog” field and feed the value back to the bot, head over <strong>Set Up &gt; Flow &gt; New Flow</strong> and create a new Auto-launched flow.</p><p>9. Create two variables, “recordId “(Don’t forget to make it available for input), and an additional variable, marked available for output, this is what we will return to the Bot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*MypU-CIQ3l-92Fe_4FRwWA.png" /></figure><p>10. Create a Get Records on the Messaging Session object with the following configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*wqTCsRCEgmw4fnBi7DmXrQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*uV3M_a1134GGklwhYak43Q.png" /></figure><p>Save and activate the Flow.</p><p>11. Now we go into the Einstein Bot, Welcome Dialog, as it is the first dialog that is executed, here we will use the Flow to determine which dialog to open next, Add a new Flow Component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*ehq9tQamBpYaCnng2RAJbg.png" /></figure><p>Next, select the Flow we created in the previous step, map the “Routable Id” variable to the “recordId” the Flow expects to receive and create a new text type variable to store the value the Flow returns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*LQEawdoCaXv8TFfVLrv_gw.png" /></figure><p>Now we can use “dialog” in rules to launch the specific dialog we want -or execute any other action we might need-:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*9AW84Nxlav3ZdEGKueTW2A.png" /><figcaption>Right after the Flow is executed I defined a rule that will redirect to a particular dialog, if the paremeter sends something different to “Dialog1” the Bot will follow the usual welcome path</figcaption></figure><p>Before we are able to test everything there is still one last addition to our configuration, we need to add a couple of additional lines to the Code Snippet Salesforce automatically generates for us to deploy the Chat into a web page. Add it just above “<strong>embeddedservice_bootstrap.init(…)</strong>”:</p><pre>window.addEventListener(&quot;onEmbeddedMessagingReady&quot;, () =&gt; {<br>    console.log(&quot;Received the onEmbeddedMessagingReady event…&quot;);<br>    embeddedservice_bootstrap.prechatAPI.setHiddenPrechatFields({&quot;Name of Pre-Chat Field&quot; : &quot;Value we want to send&quot;, &quot;Name of Pre-Chat Field 2&quot; : &quot;Value we want to send 2&quot;});<br>});</pre><blockquote>You can also send variables as values not just plain values, but that enters in web development territory, not in the scope of this guide.</blockquote><p>It would look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*WPSh6FQJgPRepWIMIwrEAA.png" /></figure><p><a href="https://developer.salesforce.com/docs/service/messaging-web/guide/introduction.html">Official Salesforce documentation for APIs that can be used with MiAW channels</a></p><p><strong>Results:</strong></p><p>Behavior if I send “Nada” (“Nothing”):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*I4Rcys6PE18JhRy3NOqX0A.png" /><figcaption>Bot follows default path defined</figcaption></figure><p>Behavior if I send “Dialog1” as value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*oLpWhUQcgcfEJSa9ew3Lug.png" /><figcaption>Bot redirects on start-up to a different dialog</figcaption></figure><h3>Common issues I ran while testing:</h3><ol><li>I did all the steps above and even though I am sending a value through the web page it is not being stored in the <strong>Messaging Session:</strong> Check if the value you are sending exceeds the field’s length.</li></ol><h3><strong>Annex: Standard Web Channel Implementation</strong></h3><p>Implementing a similar behavior in standard Web Chat implementations can be achieved albeit with a few differences.</p><ol><li>Custom field needs to be created in the “Chat Transcript” object instead of the Messaging Session object:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-Z7sVJaJoYQosaiV7Y2CQ.png" /><figcaption>“test” field created in Chat Transcript Object</figcaption></figure><p>2. API used for standard web chat is different, <a href="https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_prechat_details.htm">click here to review it</a></p><p>Basically I added to my standard web deployment snippet the following line:</p><pre>embedded_svc.settings.extraPrechatFormDetails = [{&quot;label&quot;:&quot;Test&quot;, &quot;value&quot;:&quot;Dialog1&quot;, &quot;transcriptFields&quot;: [&quot;test__c&quot;]}];</pre><p>Add it right above the “<strong>embedded_svc.init()” </strong>section of the snippet</p><p>And that is it! Standard implementation is pretty straight-forward, as we are already declaring the field’s API name within the code itself, so when we launch our chat and the conversation is finalized, the field will automatically populate with the value that was sent:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*rpzHRrz9Ix7_70ll1yjCug.png" /><figcaption>Value passed through web page is saved directly to the Chat Transcript instance</figcaption></figure><p>Update log:</p><p>03/11: Minor spelling corrections</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ddbe5fee87c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>