My experience with Salesforce Marketing Cloud development has mainly been a solo journey. Although I have had teammates who excelled in Marketing Cloud Administration or data segmentation, and a fantastic partner in crime for email development, I have never had a workplace mentor for the underbelly of Marketing Cloud.
Over the years, I have relied on the SFMC community and a lot of trial and error to help me solve complex client requests. At the end of this blog, I will share links to the resources that have aided me with my development so far, and continue to provide valuable assistance. However, with the introduction of AI tools in the development process, I now have a new set of colleagues to assist me.
What can AI do for a developer?
Developers can now leverage AI tools for code analysis and optimization, testing and debugging, and virtual assistants. These tools can significantly enhance efficiency and productivity, reduce errors and bugs, improve accuracy and precision, and save time.
My AI Tools
ChatGPT ($20/mo for Pro version)
By now, everyone has heard of ChatGPT, an AI-powered chatbot that can assist with almost any task, whether you need help or not. For example, did I really need a poem about the Marketing Cloud Account Engagement Business Unit Exam in the style of The Love Song of J. Alfred Prufrock? Probably not.
However, as a developer, what I really appreciate about ChatGPT is the ability to bounce coding ideas off of someone (even if they are not a real someone).
Use Case 1: Helping me write tedious SQL code
I love SQL, but I don't enjoy writing it. Writing SQL in Marketing Cloud is especially mind-numbing for a couple of reasons: 1) If you use Automation Studio, you have to create a data extension for the results beforehand; and 2) If you use Query Studio, you can't use *. This means that whenever I want to query data views, I have to list out all of the fields that I want returned.
Although I've stored repeatable code in Quip, I've found that asking ChatGPT to write it for me is much more efficient. For example:
And then I can add to the request (even with typos!):
Those of you who are intimately familiar with Marketing Cloud Data Views might notice an error in the first result. The query should call SMTPBounceReason instead of SMTPReason. Rest assured, the robots are not ready to take over.
Another perk of asking ChatGPT to write mundane SQL queries for me? I usually get up and refill my coffee while it’s working, meaning that I am doing something much more pleasurable during the time that I could be copying and pasting over Data View fields.
Use Case 2: helping me write complicated SQL Queries
ChatGPT can also assist with more complicated queries. When I'm wrestling with a more complex query, I like to start with the basics and then let ChatGPT work its magic to build on it. For example, the following initial request:
Eventually becomes this:
SELECT
rr.JobID,
rr.SubscriberKey,
rr.EventDate,
rr.LinkName,
rr.URL,
rr.EmailName,
rr.Status,
rr.CampaignId,
rr.CampaignMemberId,
rr.FirstName,
rr.LastName,
rr.Email,
rr.QueryAdded
FROM (
SELECT
c.JobID,
c.SubscriberKey,
c.EventDate,
c.LinkName,
c.URL,
j.EmailName,
cm.Status,
ese.CampaignId,
ese.CampaignMemberId,
ese.FirstName,
ese.LastName,
ese.Email,
ese.QueryAdded,
ROW_NUMBER() OVER (PARTITION BY c.SubscriberKey, c.JobID
ORDER BY c.EventDate DESC) AS RowNumber
FROM
_Click c
JOIN
_Job j
ON
c.JobID = j.JobID
JOIN
[Not Responded EOJ] nr
ON
c.SubscriberKey = nr.LeadOrContactId
JOIN
[CampaignMember_Salesforce] cm
ON
c.SubscriberKey = cm.LeadOrContactId
JOIN
[Employment Survey Entry] ese
ON
c.SubscriberKey = ese.LeadOrContactId
WHERE
(j.EmailName LIKE '1st Touch'
OR j.EmailName LIKE '2nd_Touch'
OR j.EmailName LIKE '3rd Touch')
AND
c.EventDate > ese.QueryAdded
AND
ese.QueryAdded >= '2023-03-09T13:56:22.000'
AND
c.URL LIKE '%CloudPagesURL%'
) rr
WHERE rr.RowNumber = 1
While both of these examples use SQL, I apply the same process for AMPScript, SSJS, and client-side JavaScript.
Use Case 3: Code analysis and optimization tools
Sometimes, even when I have working code, I wonder if I can improve it. In these situations, AI helps me become a better developer by both writing better code and teaching me better coding practices. For instance, I have always relied on the CASE statement in SQL to handle null fields, but ChatGPT taught me the beauty of using COALESCE:
SELECT x.SubKey, x.Email, x.FirstName, x.Account, x.LastName
FROM (
SELECT DISTINCT
COALESCE(c.Id, r.Email) AS SubKey,
r.Email,
r.FirstName,
COALESCE(r.Account, 'unknown') AS Account,
COALESCE(r.LastName, 'unknown') AS LastName,
ROW_NUMBER() OVER(PARTITION BY r.Email ORDER BY c.CreatedDate) AS rowNum
FROM [Survey Email Import] r
LEFT JOIN [All Contacts and Leads] c
ON c.Email = r.Email
) x
WHERE x.rowNum = 1
Use Case 4: Debugging
If your code isn't working, instead of counting braces or searching for a missing semicolon, you can simply drop the code into ChatGPT:
Use Case 5: Virtual Assistant
Although I am technically a Marketing Cloud Architect, my passion lies in development. This is why I am now using ChatGPT to write User Stories when I am architecting a project.
Note that at the time of writing, ChatGPT 4 has a limit of 25 messages every 3 hours. Due to this limitation, I usually use v3.5 for code and save v4 requests for things like user stories and acceptance criteria.
GitHub Copilot ($10/month)
GitHub Copilot is an AI-powered code completion tool developed by GitHub and OpenAI. It suggests code snippets and functions as you type, based on the context of your code, using machine learning. Copilot offers suggestions for any of the Marketing Cloud coding languages, and I was pleasantly surprised to see it handle AMPScript.
Use Case 1: Reducing Mundane Tasks
Can you spot the recurring theme here? For me, AI is all about reducing the time I spend on mundane tasks that I don't enjoy. One of my all-time favorite features of Copilot is its ability to declare AMPScript variables used in the code right below it. While it's not always necessary to declare these variables (unless you're working with a loop, in which case, it's pretty crucial), it's considered a best practice. Unfortunately, I often neglect this practice because I'm too lazy to ensure that all the variables are declared.
In the image below, the light grey, italicized text shows GitHub Copilot suggesting the variables that I need to declare.
It's important to note that in this example, if @formData is declared, the incoming string will be lost. Therefore, blindly accepting all suggestions is a recipe for disaster.
In the following example, GitHub CoPilot makes assumptions about the next block of code I want to write and starts building it automatically. All I have to do is hit the "tab" key to accept the suggestion.
GitHub CoPilot can assist with any Marketing Cloud language you want to use. However, it does not rely on natural language processing to understand your intentions. Therefore, I typically begin with ChatGPT before moving on to GitHub CoPilot.
Challenges of Using AI Tools
While AI tools can be helpful, it's important to recognize that they are not perfect. It still takes a skilled developer to ensure accurate results. Simply asking for a SQL query, dumping it into Marketing Cloud, and moving on is not a good idea. Testing queries for expected results is key, as is testing any code generated by these AI tools.
Landing the plane
The future of software development will likely see an even greater role for AI tools. As machine learning algorithms become more advanced, developers will be able to rely on these tools for even more complex tasks, such as code generation and problem solving. However, it's important to remember that these tools are meant to assist developers, not replace them. Skilled developers will always be necessary to ensure that AI-generated code is effective and accurate. As AI tools continue to evolve, they will likely become an even more integral part of the software development process, allowing developers to work more efficiently and effectively.
Human Resources
AMPScript Guide - there are humans behind this website, so it counts! When I started my job, our cofounder dropped the physical book on my desk and suggested I start learning it. The online version is an essential reference.
Mateusz Dabrowski - this is like AMPScript Guide on steroids.
sfmarketing.cloud - I have copied so much code over from this resource. There are many solutions I have come up with that probably never would have happened without Zuzanna. It's also a great resource for coming up with new ideas that you might want to implement.
Sprignaturemoves - Similar to Zuzanna, I have poached several solutions from this resource. Most importantly, Adam got me about 75% of the way through my Geolocation solution, which is one of my favorite.
ampscript.xyz - Ivan saved me on a reCAPTCHA solution, and many of his other posts have sent me in the right direction.
Gortonington.com - Much like the above, Greg's resource has provided starting points for many of my solutions, and inspiration for more.
Cameron Robert - Cam puts out a ton of content, all in a pleasant Australian Accent. Most importantly, one of his more obscure videos taught me how to make a really cool Slack App that checks a subscriber status in Marketing Cloud.
mc.Chat - Not to be confused with GPTChat. I have sent Eliot's video on subdomains to countless clients. Bonus: it's also delivered in an Australian accent.
Communities
Join the following Slack Communities:
Comments