Checks certain things are in place before sending a transactional message.

assert( mixed expression [, string failuremessage] )

Assert that expressionis true. If expressionevaluates to falsenull0, or "", terminates execution of the Zephyr script.

Terminating execution via a failed assert()will have the following consequences:

  • Within transactional messages, will prevent the message from sending
  • Within triggers, will prevent any further execution of the trigger
  • Within hosted pages or preview, will cause an error preventing rendering the page
  • Within campaigns, will prevent the campaign from being sent to a specific user

Essentially, assert()can be used as a safety check to make sure that certain things are in place before a user is sent a message. For example, if you have an abandoned shopping cart email that should never be sent to someone without items in their cart, you can put the following in the Setup section (under the Advanced tab in the template editor):

{assert(profile.purchase_incomplete, "User has nothing in shopping cart")}

If you have a template that always requires that certain variables be passed, you could assert against those variables being non-null:

{assert(friend_requests > 0, "User has no friend requests")}

Or if you want your campaign to send only if there are more than 5 pieces of content in the data feed.

{assert(length(content) > 5, "Not enough content")}