If you have used Automation Studio to build workflows on autopilot, you are certainly aware of the importance of monitoring. Checking manually the execution status of every automation in your account is tedious and exhausting. Sometimes, you need to be notified in real time so you can fix eventual issues. That is why having email notifications enabled on your automations is necessary.
There are two types of notifications to which you can subscribe on automation settings:
- Error or skipped run: you will receive an email if the automation’s execution fails or is skipped
- Run Completion: you will receive an email once the automation’s run completes.
Keep in mind that at this moment, the only official way of interacting with Automation Studio via API is through SOAP. I’m saying “official” because there are actually some undocumented, but very limited, REST endpoints that can be used to play with Automation Studio. Let me know in the comments if you are interested.
Therefore, if we check the official SOAP documentation, we will see that creating an automation along with activities and email notifications in its settings is pretty easy and straightforward. However, if we look closer, we will find a comment on the notification tag saying: DOES NOT WORK. But we are not going to accept this for an answer, aren’t we?
This is the SOAP request sample from the documentation to create an automation: [see code snippet on Github]
To find the source of the problem, we should get into the tags responsible for adding email notifications to the settings. In this example, they are using a wrong value for the
NotificationType tag in addition to a missing
NotificationType should be either “Complete” OR “Error” and definitely not “-1”. And
ChannelType should be equal to 1.
The correct SOAP request to create an automation along with a “Complete” notification email should look like this: [see code snippet on Github]
For the curious ones, you may be asking how I found the working values. I invite you to go to Automation Studio, open the Chrome Developer Tools (F12) and click on the Network tab.
Open an automation, add your email to the settings and click done. Now go check out the Network tab. There is a REST call to the endpoint below.
Given the fact that we can only interact with Automation Studio using SOAP calls for now, we can understand why the endpoint is beta and not officially documented:
Now let us look at the request payload:
We can see that the values used for
ChannelType are as described above. That was worth a try and it worked: [see code snippet on Github]
I invite you to check the network tab every time you need to interact with Salesforce Marketing Cloud APIs. It can be very interesting and full of undocumented information.
If you know someone that can correct this on the official documentation, please get in touch through the comments or send me a message on LinkedIn.