Automations
Add to Segment
Add the current contact to a segment as a step in your automation.
The add to segment step adds the current contact to a specified segment when the automation reaches it. See Using automations for the surrounding workflow.
Common use cases:
- Cohorts — add contacts to a cohort segment after a specific event.
- Lifecycle — segment contacts as they progress through onboarding.
- Engagement — group contacts who completed a specific action.
How it works
In the dashboard, add an Add to segment step and select the segment from the dropdown. Over the API, the add_to_segment step accepts a single segment_id field.
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.automations.create({
"name": "Tag VIP users",
"domain": "yourdomain.com",
"steps": [
{
"key": "start",
"type": "trigger",
"config": { "event_name": "purchase.completed" }
},
{
"key": "vip_users",
"type": "add_to_segment",
"config": { "segment_id": "83a1e324-26dc-47eb-9b28-ba8b6d1fe808" }
}
],
"connections": [
{ "from": "start", "to": "vip_users", "type": "default" }
]
});
console.log({ data, error });Configuration
config.segment_idstringrequiredThe ID of the segment to add the contact to.
{
"key": "add_to_vip",
"type": "add_to_segment",
"config": {
"segment_id": "83a1e324-26dc-47eb-9b28-ba8b6d1fe808"
}
}