Triggered sends allow you to automatically send personalized and timely messages to your subscribers. They are sent to an individual subscriber in response to a subscriber action. Common use cases include sending welcome emails to new subscribers, service case notifications or post-purchase thank you notes to clients. They can be personalized just as any other email sent from Salesforce Marketing Cloud and triggered in various ways, among others, using AMPscript. You can read more about Triggered Sends in Salesforce Marketing Cloud here: Triggered Emails.
Create a Triggered Email Message Interaction
In order to create a Triggered Email Message Interaction, we need all the elements that we would use for a user-initiated email: an email, a sender profile and a list for managing subscriber statuses. Once you have all of the above ready, you can create a Triggered Send:
- Go to Email Studio > Interactions > Triggered Sends
- Click on Create
- Provide a name, select your sender profile, email and list used for subscriber management
- Save your Triggered Send
- Check the checkbox on the list of your Triggered Sends and click on “Start/Restart”
Now copy the “External Key” of the Triggered Send you just created, you will need to insert it into the script in the next step.
Trigger the email using AMPscript
In order to trigger the email, we will use the InvokeCreate function, which invokes the Create method on an API object. The following script uses the CreateObject function to create the TriggeredSend and TriggeredSendDefinition objects as
@tsDef, and to create a new Subscriber record as
@ts_sub. We will specify the attributes of the Triggered Send object and the Subscriber object using the SetObjectProperty function. The AddObjectArrayItem function is used to add the object attributes, and everything is then passed into the InvokeCreate function. The InvokeCreate function returns a status code and a status message, by which exception handling can be built using the RaiseError function.
In the above script, replace
ExternalKey with the External Key of the Triggered Send you created earlier and replace
firstname.lastname@example.org with your email address. You are now ready to run this script on a CloudPage by publishing it. Upon success, you should be able to see the following values:
Triggered Send status code: OK
Triggered Send status message: Created TriggeredSend
Triggered Send error code: 0
The above script is simplified, as it uses the email address of a subscriber as the subscriber key. If you would like to pass the subscriber key separately, you will need to add one more variable
@ts_subkey and change the SetObjectProperty for the Subscriber record:
To see how this script works in action, visit the CloudPage that I created and submit your email address here.
The delivery speed for Triggered Send emails is usually quicker than for user-initiated emails, so if the email doesn’t make it into your inbox in a couple of minutes, check your spam folder.
Here are additional resources to learn more about Triggered Sends: