Loading...
Skip to main content

Segment

One of the most common use cases for automations is hooking up notifications to segment events.

Segment Automation Trigger Example

In this example, we'll imagine an e-commerce site that sends out an email when a user successfully checks out, or a reminder to finish checking out when they visit the page, but do not finish their purchase.

For this, we'll need two automations. One for the reminder condition, the other for the checkout success condition. We'll start with the reminder condition.

  1. Create a new automation
  2. Select the Segment trigger and choose correct track event. In our case, that is "Checkout Page Visited". Note: The track event dropdown is populated with events Courier has already received from Segment.
Segment Trigger
Segment Trigger
  1. The reminder should be sent out a couple of hours after the checkout page was visited, so add a delay node with the desired delay time
  2. Connect the delay node to a new send node and select the desired template. We set the userId to refs.data.userId, which is the userId sent to us by segment.
UserId Referenced
  1. If the user successfully checks out, we won't want to send this notification. We'll add a cancellation token so we can cancel this run in from our next automation. Navigate to the settings tab and set cancellation to refs.data.userId. This way we can cancel any instance of this automation associated with the same user the notification would otherwise be sent to.
  2. Click publish to finalize the template
Cancel Automation
Cancel Automation

The next automation will cancel the reminder automation from above, and send an invoice on successful checkout.

  1. Create a new automation.
  2. Add a Segment trigger node with a track event set to "Checkout Complete"
New Automation
New Automation
  1. Add a cancel automation node and set the token to the user id. This will prevent the reminder to finish checking out from sending.
  2. Send the Checkout Complete notification
Checkout Complete Automation
Checkout Complete Automation