The capabilities of AI has long been a topic of conversation in the tech space. This has been true for such a long time now, so much so in fact that I remember reading articles about the rise of Artificial Intelligence in the world of work several years before I joined the Salesforce ecosystem back in 2016. Much of the conversation in this area has focused around the talking point of how long will it be before AI replaces human workers and essentially takes over their jobs. While there is a significant part of me that thinks that it will be a very long time before AI replaces the need for humans to carry out work and maintain said AI (if it ever happens), that is not the focus of this post here today. Rather, the focus of today’s post is to talk about how ChatGPT fairs providing instructions to Salesforce Administrators on how to build out Flows based on the requirements they have for their declarative automation.
ChatGPT is an AI Assistant created by the team at OpenAI. How ChatGPT works is that you provide it with a text string and the tool will generate an automated response based on the text string you submit. Most of the time you will be submitting a question to it, or in the case of today’s post, you’ll provide it with instructions that you would like ChatGPT to provide you with a solution for. In this post, I’ll go over two scenarios that I posed to ChatGPT and asked for it to generate instructions for creating Flows on. The idea behind this post is to review the responses given by ChatGPT and to see how accurate they are based on current Flow standards.
But before we dive in, let me explain how I landed on the two use cases that I ended up posing to ChatGPT.
Polling the Trailblazer Community
Before deciding on the use cases that would be posed to ChatGPT for this post, I first polled the Trailblazer Community via LinkedIn and Twitter. I ran the same poll across both platforms in the hope of getting a little more traction on them. The poll ran for 1 day and had a total of 35 votes across both social media platforms. I also offered the option to take an option posted in response to the posts that I shared with the poll, offering to use the option posted if it got more votes than the options included in the poll. I got a couple of other options included, those being to send a Slack Message and to post a Chatter message. Unfortunately neither of these additional options beat out the poll options, so this post will cover the two options that received the most votes overall.
The four options that I offered in the polling was:
- Update Opportunity Close Date (2 votes in all, tallying up to 6% of the votes)
- Calculate Roll-Up Value (18 votes in all, tallying up to 51% of the votes)
- Show Message on Login Attempt (7 votes in all, tallying up to 20% of the votes)
- Send Custom Notifications (8 votes in all, tallying up to 23% of the votes)
As you will see from the list, the scenarios we’ll be seeing in this post today cover the calculation of roll-up values, and the sending of custom notifications in Salesforce via a Flow. We’ll cover each of the scenarios now, we’ll do this by explaining the use case, seeing the response from ChatGPT, evaluating the resource and finally highlighting how I would build this in Flow. After we’ve done this for both scenarios, I’ll offer a closing summary before wrapping up the post. If you’ve experimented with ChatGPT I’d love to hear from you. So please do feel free to post your experiences and thoughts in the comments below or on Social Media.
So without further ado, let’s get into our two scenarios and evaluate how ChatGPT performed.
Calculate Rollup Values via a Flow
The first scenario we’ll cover is the one where we ask ChatGPT to calculate two sets of rollup values. These rollup values are tied to the Account and Contact objects and they will count the number of open cases for an Account record and the same for each Contact record owned by that Account record. In this scenario we have requested that both calculations be done in the same Flow.
As stated, we’ll first look at what ChatGPT recommended in order to build out the Flow according to the requirements offered. I’ll then provide a bit of an evaluation on it’s response before moving on to show how I would build this Flow out myself from scratch.
What Did ChatGPT Recommend?
I offered ChatGPT a requirement asking it to calculate the total of Open Case records listed against an Account, and to then subsequently calculate how many of those Open Cases were associated with which Account Contact. This was done to see how ChatGPT would perform in generating instructions on how to build a Flow that would calculate the number of existing records on both a child and grandchild level. As it pertains to this example, an example would be if an Account record with 5 Contacts had 10 Open Cases associated with it, and each of those Contacts were linked to 2 of those 10 Cases, then we should see 10 Open Cases against the Roll-Up on the Account record and 2 against the Roll-Up on each of the Contact records related to the Account.
In practice this would be a relatively simple Flow to build. There are a couple of options to do this though, we’ll talk about that later. But for now, let’s take a look at what ChatGPT recommended that we do in order to build this out in Flow Builder.
To your left, you should see the screenshot of the request made to ChatGPT, along with its response on how to build this out in Flow.
Please note that the screenshot may appear in a different location when viewing this post on a different device such as a mobile or a tablet.
In all, ChatGPT recommended we use 9 steps. We would create the Flow, add some lookups using Record Lookups and Fast Lookups, we’d then Loop around the records before doing a couple of Record Updates, finally we’d test the Flow in order to ensure it’s working properly.
If you’re relatively new to Flow Builder you might be reading this and wondering what exactly are Record and Fast Lookups? Well, this is where the issues with ChatGPT come into play. One thing you should know about the tool is that it’s training data goes up to 2021. This means that any suggestions it offers are only as up-to-date as sometime in 2021. So if you’re going to ask it to explain how to create HTTP Callouts via Flow you may find yourself getting a little stuck. In this case, what ChatGPT is recommending is at least 4 years out of date.
The reason I say that this recommendation is 4 years out of date is because the recommendation to use Record Lookups and Fast Lookups is harkening back to the days of Cloud Flow Designer. For those who might not know, Cloud Flow Designer was what was replaced by Flow Builder in the Spring ’19 seasonal release. Before Cloud Flow Designer was Visual Flow if I’ve gotten my history of Flow right (honestly, I didn’t start using Flow until 2020, so apologies if my timeline is a little on the foggy side). So the information in ChatGPT dates to early 2019 at the absolute latest. There’s not much more I can really say on this side of things as it would be difficult to cover where this Flow is wrong in-depth due to the differences between Cloud Flow Designer and Flow Builder.
So for now, let’s move on to talk about how I would build this Flow out if I was to build this from scratch myself.
How I Would Build This Flow Out
When it comes to building out Roll-Up Summaries in Flow there are two particular areas to consider. Those areas being how should the Flow calculate the Roll-Up, and does that method account for the deletion of a child record tied to the roll-up summary. With these two points in mind, there are two main models for building out a Roll-Up Summary in Flow. The first is the Record-Triggered model, here you would need two Flows, one that runs on create/update and the second which would run on delete, both Flows would be tied to the child record, the create/update would ideally reset the roll-up summary and recalcuate all of the child records via a Get Request and an Equals Count Assignment, the delete Flow would also run on the child but would simply subtract 1 from the current value on the parent record. The second option is for it to be a Schedule-Triggered Flow, this option would you see you run the Flow on scheduled intervals and would include both calculations in a single Flow and ultimately updating the parent. Both approaches have pros and cons associated with them. For example, the schedule-triggered approach will not give you a close to real-time update of the Roll-Up Summary field/s. This may not be a huge thing to you, as if this was documented well so that your users were aware it wouldn’t be too much of an issue in my view, the Flow could always be debugged without rollback mode being switched on, this would result in the record update you desire (but this of course would have to be done manually). When it comes to the Record-Triggered approach, the main issue with this is that you would require a minimum of two Flows to make it work, this would result in more Flows against the object. Again, this may not be the biggest issue to you, but it should be a consideration.
Getting back to this Flow, the requirement specifically asks for the calculations to be handled in one piece of automation. This would mean that the Record-Triggered approach isn’t the best approach to be used for creating a solution here. So for this use case, we’ll opt for the Schedule-Triggered Flow approach. In order to make this Flow the most performative we’ll trigger this Flow from the Contact object, this is because Cases technically have two different parents, one being the Account and the other being the Contact. We could argue that Cases are the grandchild of the Account record, but that wouldn’t be technically true. So this Flow will need to find all the Open Cases associated with the Contact record that triggers the Flow, and then do the same for the Account record. Because of the methadology being used we won’t need to do a reset of the Roll-Up’s, just an Equals Count.
So let’s showcase this Flow as I would anticipate building it based on this requirement.
I would necessarily go through each element here. However, the basic structure is as follows:
- Configure the Start Element.
- Get all of the Open Cases for the Contact.
- Determine if the Contact has an Account.
- If so, get the Accounts Open Cases.
- Assign the count result to a variable.
- Update the Account record with the count.
- Set the Open Case Count for the Contact.
- Update the Contact with the count.
You won’t necessarily need to include the decision element in this Flow. However, I do think it is good practice to do so to prevent any potential errors that may come up if the Contact isn’t linked to an Account record. Ideally all Contacts should be linked to an Account record, but sometimes a user may forget to link a Contact to an Account, so this approach just adds in an extra safeguard to cover your bases. In some ways it’s a bit redundant to do this, but as I say I think it’s good practice to avoid any issues that problematic data may cause your automation. All that being said, this is a fairly simple Flow that should run quickly in most cases. For the purposes of this post I chose to only have this Flow run once and for it run in the middle of the day. Normally I would encourage Admins to have their Scheduled-Triggered Flows run out of hours to prevent any issues that may impact users while the Flow is running. I would also recommend that you document when your scheduled Flows are due to run, this could be done in something like a word document or even a calendar system. All you would need to include in my opinion is the name of the Flow that runs, the name of the object it is running on and when the Flow will be expected to run on. I actually prefer the idea of calendarisation myself, I will look to cover that in a future blog post to go over my tips on how to make this work well.
In order to validate that this Flow would work as expected, I created a report that lists all of the Accounts and Contacts with an Open Case listed against it. As you can see from the image on the right, there are three Contacts with Open Cases in this Dev Org, with two of those Contacts being tied to the same Account. Thankfully with the way reporting works, it has only counted the number of Open Cases linked to each related Record Id.
So that’s the first scenario covered. As you can see, ChatGPT didn’t do the best job with providing instructions on how to build out this solution in Flow Builder. Now, let’s move on to the second scenario and see if that performed any better. Let’s go.
Send Custom Notification/s via Flow
The second scenario I asked ChatGPT to provide instructions on how to build a solution for in Flow Builder was one that would send a Custom Notification to the Owner of a Campaign record, advising them to complete any outstanding tasks before the Campaign comes to an end. The Flow in question should send the notification out 7 days before the Campaign was due to end.
Like in the previous example, ChatGPT’s response left a little to be desired. This time however the response did go down the lines of using Flow Builder (despite including an instance of using Cloud Flow Designer verbiage). That being said, the instructions from ChatGPT here weren’t great either, there were several problems in my view from what it offered. Let’s go over those issues now.
What Did ChatGPT Recommend?
Below is the response that I received from ChatGPT when I asked it to provide instructions on how to build a Flow out that would meet the terms of this requirement. As we look at what ChatGPT recommended, we have to be mindful of the request being made.
As I’ve already noted, there were several issues that this recommendation from ChatGPT had. Despite actually offering a solution that would use Flow Builder here, it didn’t really do a great job of detailing how you would actually build a Flow to meet the requirements set out for this.
Here’s a brief list of the issues here:
- No Flow Type is mentioned at all.
- You should need to create any variables.
- You don’t need a Get for the Campaign.
- There is no Notification element.
- Decisions do not include a Before operator.
- Nothing about testing is mentioned.
I’m honestly not sure what the notification element that ChatGPT is mentioning is, maybe it was also something from the days of Cloud Flow Designer or Visual Flow, it certainly isn’t from Flow Builder. The Decision element also doesn’t match what can be done in Flow Builder. It does make me wonder where this tool is getting it’s information from, what it seemingly collected to generate this response is either very outdate, or just simply wrong. Due to my lack of knowledge on Cloud Flow Designer and Visual Flow, I can’t honestly say which. What I can say is that this isn’t based on Flow Builder as it is today or since 2020.
Once again, what ChatGPT recommended isn’t really all that good. This is not something I would follow even remotely. Honestly, I was hoping that if I gave ChatGPT two use cases for Flow that it would do a better job of providing an accurate response on what I would need to do in order to build a solution out in Flow. Obviously, I’m a little disappointed here.
Now that we’ve seen the bad response from ChatGPT here. Let’s move on to talk about how I would build this Flow out.
How I Would Build This Flow Out
This Flow, like the first Flow could be built in a variety of ways (this is commonly the case with Flow). Like with the first Flow, we could also build this out using either a Schedule-Triggered or Record-Triggered Flow. Technically we could also build this out in a Screen Flow as well, but that would require manual work. This use case is much more suited for a Triggered approach such as is the case with Record or Schedule-Triggered Flows. For me personally, this type of use case is best suited to be linked to what is called a Scheduled Path in a Record-Triggered Flow. A Scheduled Path is much the same as a Time-Dependent Action in Workflow Rules or a Scheduled Action in Process Builder. For this use case, I would look to use a Record-Triggered Flow that would fire on the creation of a Campaign record, with the notification being sent in a Scheduled Path that runs 7 Days before the End Date happens.
Like in the other use case, I won’t go over every element here. Rather I will talk about the overall process for this type of Flow and go over that.
In this Flow you really only need three steps:
- Get the values of the Custom Notification record.
- Add the Campaign Owner to a Text Collection.
- Configure the Send Custom Notification Action.
You will need to think about the notification body and title that you add to the action. For me, when I work with Custom Notifications in Flow, I create the notification body in Flow via a Text Template resource, and the Title via a Formula resource. I think this is the easiest thing to do in this use case.
In my testing, I created a Campaign record and checked to see when the notification would fire via the list view found in Time-Based Workflows. This can be found in Setup in Salesforce. The notification was scheduled to fire at midnight on 9 February. However, due to the time it fired immediately.
We can see the notification successfully fired via the image to your right. In it I have my title, and my notification body. This was sent to myself as I was the Owner of the Campaign record. However, had this been owned by a different user, the Notification would have been sent to them instead. So we can see that everything worked as expected in this case.
My Over Thoughts on ChatGPT From My Experimentation
So after seeing the results of ChatGPT for the use cases I offered it, what do I think of the tool overall? Well, I can’t say that it is something that I would recommend using for formulating instructions on how to build Flows based on requirements. This is largely due to the fact that the training data for ChatGPT is over a year out of date, and how it accesses seemingly all of it’s training data. This means that in many cases you may get responses like I did, where it uses information it can find on Cloud Flow Designer and Visual Flow, or event mix that together with Flow Builder. I think that Admins who use ChatGPT to generate instructions for how to build a particular Flow will need good knowledge of Flow in order to avoid being confused by the guidance it will potentially offer. ChatGPT is not something I would recommend Admins who are new to Flow to use in order to generate instructions for building.
I do think though that it does offer some promise. Unfortunately I don’t have screenshots to share of it, but I was able to get ChatGPT around 85% of the way when it comes to building these solutions out in Flow Builder. So with a little gentle steering, you can get ChatGPT there. Again though, that would require a level of knowledge of Flow that would allow you to correct any mistakes that ChatGPT would make in generating instructions for you. ChatGPT can be trained, but in order to do that you need to be able to spot the mistakes it makes and know how to resolve them. So in summary, I think ChatGPT provides an interesting look into how an AI Assistant could help you build out your automation in Flow, but it will need a lot of hand-holding to get it across the line.
But what about you? Have you experimented with ChatGPT and asked it to build out Flow solutions for you? If so, how did you get on? Did you find the results to be more accurate than I did? If so, how did you do it? How much correction did the tool need?
I’d love to hear your thoughts on your experiences with ChatGPT. Let me know your thoughts in the comments or on Social Media.
We have three resources to link to this awesome post … all of these resources look at ChatGPT and Salesforce. These resources cover topics such as how can ChatGPT be used alongside Salesforce, and what the launch of ChatGPT means for the ecosystem.
What Does ChatGPT AI Mean for the Salesforce Ecosystem?
In this Salesforce Ben post, Ian Gotts (Founder & CEO of Elements.cloud) covers what the launch of ChatGPT means for the Salesforce ecosystem as a whole. Ian speaks on the pros and cons of the tool and how it will affect roles such as Salesforce Admins.
What’s the Buzz Around ChatGPT for Salesforce?
This brief post shared on LinkedIn by ForceTalks highlights a little on why so many in the Trailblazer Community are buzzing about ChatGPT. It also provides some examples of ChatGPT in action to create things such as LWCs, Apex Classes and Formulas.