I noticed that after logging an error and skipping a triggered send to a specific subscriber, the number of errors in the triggered send interaction increments too. I wanted to document it and ended up with an AI generated content as an exercise. I prompted ChatGPT and Microsoft Bing Chat to write this post…
The Prompt I Asked
I haven’t done any training yet but here is what I asked:
You will write a short blog post, using Markdown, about the RaiseError() AMPscript function used to skip a send if a subscriber’s custom parameter is equal to a forbidden value. The heading is: “RaiseError() in Triggered Sends” followed by 3-4 paragraphs with a code example:
SET @myParameter = AttributeValue(‘myParameter’)
IF @myParameter== ‘Forbidden Value’ THEN
SET @errorMessage = ‘This is a forbidden value. Skip the send.’
InsertDE(‘RaiseError_LogDE’, ‘EmailAddress’, emailaddr,’EmailName’, emailname_, ‘ErrorMessage’, @errorMessage, ‘SubscriberKey’, _subscriberkey)
RaiseError(@errorMessage, true, 1)
ENDIF
Polishing the AI Output
I am not comparing the tools for sake of the exercise, therefore I cleaned up the final output slightly and shortened it already. I added the references which Bing Chat included in its answer. The results are satisfying especially how the provided code snippet is explained. I am concerned about using the source documents and for example whether AI can log in to the subscription based, paid content, such as the AMPScript Guide, using my cached credentials to read it and use in its answer(?).
Content Generated by ChatGPT
The function RaiseError()
serves a dual purpose: it both logs the issue for future reference and prevents the email from being sent.
Consider a scenario where the custom parameter @myParameter
is retrieved using AttributeValue('myParameter')
. If this parameter matches the value 'Forbidden Value'
, it triggers the error handling mechanism:
SET @myParameter = AttributeValue('myParameter')
IF @myParameter == 'Forbidden Value' THEN
SET @errorMessage = 'This is a forbidden value. Skip the send.'
InsertDE(
'RaiseError_LogDE',
'EmailAddress', emailaddr,
'EmailName', emailname_,
'ErrorMessage', @errorMessage,
'SubscriberKey', _subscriberkey
)
RaiseError(@errorMessage, true, 1)
ENDIF
In this snippet, the conditional statement checks if @myParameter
matches the forbidden value. If it does, an error message (@errorMessage
) is set to indicate the issue. The InsertDE()
function logs this error into a designated Data Extension (RaiseError_LogDE
) for future reference. It captures critical details such as the subscriber’s email address, the email name, the specific error message, and the subscriber key.
The RaiseError()
function itself halts the sent, preventing the email from being delivered.
Content Generated by Microsoft Bing Chat
The RaiseError()
function is an AMPscript function that enables the suppression or cancellation of an email send. It is useful for exception handling in your code, if an unexpected result occurs.
The RaiseError()
function can be used to skip a sent if a subscriber’s custom parameter is equal to a forbidden value. Here’s an example of how to use the RaiseError()
function to skip a sent if a subscriber’s custom parameter is equal to a forbidden value:
SET @myParameter = AttributeValue('myParameter')
IF @myParameter== 'Forbidden Value' THEN
SET @errorMessage = 'This is a forbidden value. Skip the send.'
InsertDE('RaiseError_LogDE', 'EmailAddress', emailaddr,'EmailName', emailname_, 'ErrorMessage', @errorMessage, 'SubscriberKey', _subscriberkey)
RaiseError(@errorMessage, true, 1)
ENDIF
In the above example, the RaiseError()
function is used to skip the send if the subscriber’s custom parameter @myParameter
is equal to the forbidden value 'Forbidden Value'
. The function logs the error message 'This is a forbidden value. Skip the send.'
in the RaiseError_LogDE
data extension and skips the sent for the current subscriber.
Please note that the RaiseError()
function still counts as an email send, even if an email was not sent to a subscriber. Therefore, it should only be used for exception handling, not for segmenting or excluding numerous subscribers.