Skip to main content
Businesses usually build segments and triggers themselves in the embed. This guide is for when you want to set them up from your code instead, for example to give every new business a ready-made automation. The example texts gym members who haven’t checked in for 30 days, limited to members on the gold plan.

1. Sync the data the filter needs

The segment can only filter on data Pocketflows has, so sync each member’s plan and last check-in time in their metadata, along with a phone number:
Send dates as ISO 8601 strings, and sync again whenever a member checks in, so last_check_in_at stays current.

2. Create the segment

Create a segment whose filter describes the members you want, written in the filter syntax. 30 days is 2,592,000 seconds:
The response includes the segment’s id, which starts with seg_.

3. Create the trigger

Create a trigger that runs when a customer joins the segment, with the steps to run for them:
To listen for an event you track instead, pass project_defined_event with the event’s ID in place of internal_event_definition. See Send messages when something happens in your product. The trigger sends from the business’s default phone number and email address. To choose others, pass the ID of one in phone_number or email_address.

Steps

Steps run in order for each customer: For example, to send a reminder email a week after the text, but only to members who still haven’t checked in:

4. Activate the trigger

A new trigger is a draft, with status set to draft, and does nothing until you activate it:
Its status becomes active. To stop it later, call POST /triggers/:id/deactivate.

How the trigger fires

  • Only new members are messaged. Customers who are already in the segment when you activate the trigger don’t receive anything. The trigger fires for customers who join afterwards.
  • Time passing counts. Because the filter compares against Date.now(), a member joins the segment on the day they pass 30 days without a check-in, even if nothing about them changed.
  • It isn’t instant. Pocketflows checks segment membership about every 15 minutes, so a customer is messaged up to about 25 minutes after they join.
  • It can fire again. When a member checks in, they leave the segment. If they lapse again later, they rejoin and the trigger runs again.