How to use custom events to trigger automations
Overview
In this guide
- Create a custom event in Sendlane
- Create an API call
- Create an automation triggered by the custom event you created
🚦 Before getting started
- Set up a Sendlane custom integration
- Review Sendlane's custom event API documentation
- 1
-
- Navigate to your completed Sendlane custom integration
- Click the events icon
- On the events page, click Create event > Enter a descriptive name > Create
We’ll name our example event
password-reset
.
Create a custom event in Sendlane
- 2
-
Use a JSON snippet like the following to build a password reset request API call:
{ "custom_event": "custom_event_NAME", "token": "custom_event_TOKEN", "email": "jimmykim@sendlane.com", "data": { "password_reset_url": "https://www.yourwebsite.com/reset/1234567890" } }
custom_event
- Your custom event’s name (our example event’s name ispassword-reset
)
token
- Grab the token associated with your custom event by heading to the Sendlane custom integration page > Click Settings > Click Copy > Paste in place ofcustom_event_TOKEN
Test your call to confirm your setup. You're good to go if your call is successful and you see example data on the custom events page If your event does not show data in the example column like the example below, review your custom event and API call setup:
Create an API call
- 3
-
Create an automation and select the custom event trigger from the custom integration tab and add a wait node of as the first step of the automation. For our password reset example, we’ll use 1 minute.
Create an email node and use Twig templating syntax to pull in data from the payload. Sendlane supports a subset of the Twig language. Next, create variables:
Variables
Creating variables allows you to populate data in your email using templating syntax. We’ll need the variable
data
to access data from the payload, which includes a URL to the password reset page.To create variables, add a text box element to your email, then copy and paste the following snippets into the text box. The snippets will not be visible to Contacts who receive your email, they are only visible to you inside the Sendlane email builder.
{% set data = trigger.getcustomeventData() %}
Once these variables are in place, they can be used to populate data!
Populating data in an email
In step 2, we made the API call with the following JSON payload
{ "token": "1234abcd5678edfg", "email": "jimmykim@sendlane.com", "custom_event": "password-reset", "data": { "password_reset_url": "https://www.yourwebsite.com/reset/456789745" } }
Now that we’ve set up our
data
variable, we can access thepassword_reset_url
via templating syntax:{{-data.password_reset_url-}}
Pasting this snippet directly into the email will display a raw password reset link. Use the hyperlink function in the email builder, a button, or a custom HTML block to hyperlink the URL.
In the email below, our
{{-data.password_reset_url-}}
is made into a hyperlink, and our variable scripts disappear when the email is previewed.💡 Add filters to your trigger for even more specific targeting
You can use any data in your custom event payload to create a filter on your trigger. See Understanding automation trigger filters for more details.