Recept: návrat neaktivních zákazníků (win-back)
Cíl: zákazník, který nenakoupil 120 dní, dostane připomenutí; když do týdne nenakoupí, druhý e-mail s výhodou. Každý zákazník projde sérií jen jednou.
Graf
[kazdy-den] trigger_repeat every 1 day, filter: poslední objednávka starší než 120 dní A aspoň 1 objednávka, reentry once
→ [email-1] send_email → [tyden] wait 7 days
→ [nakoupil] condition ordered_since_entry
├─ yes → konec
└─ no → [email-2] send_email
[cil] goal: ordered_since_entry (kdo nakoupí, opouští scénář kdekoli)trigger_repeatprojde každý den (odstartAt) kontakty e-shopu, které splnífilter. Filtr je strom pravidel segmentu a podmínek, které nepotřebují běh.reentry: "once": kontakt vstoupí jednou provždy, i když filtr splňuje každý den.- Uzel
goalnemá hrany; před každým krokem se kontroluje, a kdo cíl splní, scénář opouští.
1. Šablony
curl -sS -X POST "https://www.postarna.cz/api/v1/tenants/$TENANT/templates" \
-H "Authorization: Bearer $POSTARNA_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"name": "Win-back 1",
"subject": "Chybíte nám",
"preheader": "Podívejte se, co je u nás nového",
"content": {
"editor": "html",
"design": null,
"html": "<!doctype html><html><body><p>Dobrý den, {{df_salution|default('vážený zákazníku', true)}},</p><p>dlouho jste u nás nenakoupili. Podívejte se na novinky.</p><p><a href=\"https://www.example.cz/novinky\">Novinky</a></p><p style=\"font-size:12px\">{{cl_company}}, {{cl_address}}. <a href=\"{{unsubscribe}}\">Odhlásit odběr</a></p></body></html>"
}
}
JSON{
"id": "306",
"name": "Win-back 1",
"subject": "Chybíte nám",
"preheader": "Podívejte se, co je u nás nového",
"editor": "html",
"createdAt": "2026-10-01T08:00:00.000Z",
"updatedAt": "2026-10-01T08:00:00.000Z",
"tags": [],
"size": 346,
"archived": false,
"archivedAt": null,
"readOnly": false,
"usage": {
"campaigns": 0,
"automations": 0
},
"lastUsedAt": null,
"check": {
"errors": [],
"warnings": [],
"checkedAt": "2026-10-01T08:00:00.000Z"
},
"content": {
"editor": "html",
"html": "<!doctype html><html><body><p>Dobrý den, {{df_salution|default('vážený zákazníku', true)}},</p><p>dlouho jste u nás nenakoupili. Podívejte se na novinky.</p><p><a href=\"https://www.example.cz/novinky\">Novinky</a></p><p style=\"font-size:12px\">{{cl_company}}, {{cl_address}}. <a href=\"{{unsubscribe}}\">Odhlásit odběr</a></p></body></html>",
"design": null,
"version": 1,
"updatedAt": "2026-10-01T08:00:00.000Z"
},
"settings": {
"linkParams": [],
"headers": [],
"unsubscribePageId": null,
"footerId": null
},
"draft": {
"pending": false,
"savedAt": null,
"publishedAt": null
},
"activeUses": {
"automations": 0,
"emails": 0,
"campaigns": 0
},
"publicUrl": "https://links.example.cz/template/11/1e8cfd05-8113-4e6b-9676-ad3dee1e849c"
}curl -sS -X POST "https://www.postarna.cz/api/v1/tenants/$TENANT/templates" \
-H "Authorization: Bearer $POSTARNA_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"name": "Win-back 2",
"subject": "Poslední připomenutí",
"preheader": "Doprava zdarma jen tento týden",
"content": {
"editor": "html",
"design": null,
"html": "<!doctype html><html><body><p>Dobrý den, {{df_salution|default('vážený zákazníku', true)}},</p><p>tento týden pro vás máme dopravu zdarma.</p><p style=\"font-size:12px\">{{cl_company}}, {{cl_address}}. <a href=\"{{unsubscribe}}\">Odhlásit odběr</a></p></body></html>"
}
}
JSON{
"id": "307",
"name": "Win-back 2",
"subject": "Poslední připomenutí",
"preheader": "Doprava zdarma jen tento týden",
"editor": "html",
"createdAt": "2026-10-01T08:00:00.000Z",
"updatedAt": "2026-10-01T08:00:00.000Z",
"tags": [],
"size": 273,
"archived": false,
"archivedAt": null,
"readOnly": false,
"usage": {
"campaigns": 0,
"automations": 0
},
"lastUsedAt": null,
"check": {
"errors": [],
"warnings": [],
"checkedAt": "2026-10-01T08:00:00.000Z"
},
"content": {
"editor": "html",
"html": "<!doctype html><html><body><p>Dobrý den, {{df_salution|default('vážený zákazníku', true)}},</p><p>tento týden pro vás máme dopravu zdarma.</p><p style=\"font-size:12px\">{{cl_company}}, {{cl_address}}. <a href=\"{{unsubscribe}}\">Odhlásit odběr</a></p></body></html>",
"design": null,
"version": 1,
"updatedAt": "2026-10-01T08:00:00.000Z"
},
"settings": {
"linkParams": [],
"headers": [],
"unsubscribePageId": null,
"footerId": null
},
"draft": {
"pending": false,
"savedAt": null,
"publishedAt": null
},
"activeUses": {
"automations": 0,
"emails": 0,
"campaigns": 0
},
"publicUrl": "https://links.example.cz/template/11/8857a9fd-878f-4149-9ad1-55f5c0ae4115"
}2. Automatizace
curl -sS -X POST "https://www.postarna.cz/api/v1/tenants/$TENANT/automations" \
-H "Authorization: Bearer $POSTARNA_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"name": "Win-back po 120 dnech",
"shopId": "21",
"graph": {
"nodes": [
{
"id": "kazdy-den",
"type": "trigger_repeat",
"config": {
"every": {
"value": 1,
"unit": "days"
},
"startAt": "2026-10-02T10:00",
"reentry": "once",
"filter": {
"type": "group",
"match": "all",
"rules": [
{
"type": "last_order",
"operator": "older_than_days",
"value": "120",
"shopId": "21"
},
{
"type": "order_count",
"operator": "gte",
"value": "1",
"shopId": "21"
}
]
}
}
},
{
"id": "email-1",
"type": "send_email",
"config": {
"templateId": "306"
}
},
{
"id": "tyden",
"type": "wait",
"config": {
"mode": "duration",
"value": 7,
"unit": "days"
}
},
{
"id": "nakoupil",
"type": "condition",
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"operator": "yes",
"shopId": "21"
}
]
}
}
},
{
"id": "email-2",
"type": "send_email",
"config": {
"templateId": "307"
}
},
{
"id": "cil",
"type": "goal",
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"operator": "yes",
"shopId": "21"
}
]
}
}
}
],
"edges": [
{
"source": "kazdy-den",
"target": "email-1"
},
{
"source": "email-1",
"target": "tyden"
},
{
"source": "tyden",
"target": "nakoupil"
},
{
"source": "nakoupil",
"target": "email-2",
"branch": "no"
}
]
}
}
JSON{
"id": "85",
"name": "Win-back po 120 dnech",
"shopId": "21",
"status": "draft",
"version": 1,
"activeSince": null,
"firstActivatedAt": null,
"pausedReason": null,
"tags": [],
"createdAt": "2026-10-01T08:00:00.000Z",
"updatedAt": "2026-10-01T08:00:00.000Z",
"stats": {
"entered": 0,
"active": 0,
"sent": 0
},
"description": "",
"graph": {
"nodes": [
{
"id": "kazdy-den",
"type": "trigger_repeat",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"every": {
"unit": "days",
"value": 1
},
"filter": {
"type": "group",
"match": "all",
"rules": [
{
"type": "last_order",
"value": "120",
"shopId": "21",
"operator": "older_than_days"
},
{
"type": "order_count",
"value": "1",
"shopId": "21",
"operator": "gte"
}
]
},
"reentry": "once",
"startAt": "2026-10-02T10:00"
}
},
{
"id": "email-1",
"type": "send_email",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"templateId": "306"
}
},
{
"id": "tyden",
"type": "wait",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"mode": "duration",
"unit": "days",
"value": 7
}
},
{
"id": "nakoupil",
"type": "condition",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"shopId": "21",
"operator": "yes"
}
]
}
}
},
{
"id": "email-2",
"type": "send_email",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"templateId": "307"
}
},
{
"id": "cil",
"type": "goal",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"shopId": "21",
"operator": "yes"
}
]
}
}
}
],
"edges": [
{
"source": "kazdy-den",
"target": "email-1",
"branch": "next"
},
{
"source": "email-1",
"target": "tyden",
"branch": "next"
},
{
"source": "tyden",
"target": "nakoupil",
"branch": "next"
},
{
"source": "nakoupil",
"target": "email-2",
"branch": "no"
}
]
},
"issues": [],
"triggers": {}
}Detail ukazuje graf, jak ho server uložil (s výchozími hodnotami) a issues (prázdné = jde zapnout):
curl -sS -X GET "https://www.postarna.cz/api/v1/tenants/$TENANT/automations/85" \
-H "Authorization: Bearer $POSTARNA_API_KEY"{
"id": "85",
"name": "Win-back po 120 dnech",
"shopId": "21",
"status": "draft",
"version": 1,
"activeSince": null,
"firstActivatedAt": null,
"pausedReason": null,
"tags": [],
"createdAt": "2026-10-01T08:00:00.000Z",
"updatedAt": "2026-10-01T08:00:00.000Z",
"stats": {
"entered": 0,
"active": 0,
"sent": 0
},
"description": "",
"graph": {
"nodes": [
{
"id": "kazdy-den",
"type": "trigger_repeat",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"every": {
"unit": "days",
"value": 1
},
"filter": {
"type": "group",
"match": "all",
"rules": [
{
"type": "last_order",
"value": "120",
"shopId": "21",
"operator": "older_than_days"
},
{
"type": "order_count",
"value": "1",
"shopId": "21",
"operator": "gte"
}
]
},
"reentry": "once",
"startAt": "2026-10-02T10:00"
}
},
{
"id": "email-1",
"type": "send_email",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"templateId": "306"
}
},
{
"id": "tyden",
"type": "wait",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"mode": "duration",
"unit": "days",
"value": 7
}
},
{
"id": "nakoupil",
"type": "condition",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"shopId": "21",
"operator": "yes"
}
]
}
}
},
{
"id": "email-2",
"type": "send_email",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"templateId": "307"
}
},
{
"id": "cil",
"type": "goal",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"shopId": "21",
"operator": "yes"
}
]
}
}
}
],
"edges": [
{
"source": "kazdy-den",
"target": "email-1",
"branch": "next"
},
{
"source": "email-1",
"target": "tyden",
"branch": "next"
},
{
"source": "tyden",
"target": "nakoupil",
"branch": "next"
},
{
"source": "nakoupil",
"target": "email-2",
"branch": "no"
}
]
},
"issues": [],
"triggers": {}
}3. Zapnutí, pozastavení a verze
curl -sS -X POST "https://www.postarna.cz/api/v1/tenants/$TENANT/automations/85/activate" \
-H "Authorization: Bearer $POSTARNA_API_KEY"{
"id": "85",
"name": "Win-back po 120 dnech",
"shopId": "21",
"status": "active",
"version": 1,
"activeSince": "2026-10-01T08:00:00.000Z",
"firstActivatedAt": "2026-10-01T08:00:00.000Z",
"pausedReason": null,
"tags": [],
"createdAt": "2026-10-01T08:00:00.000Z",
"updatedAt": "2026-10-01T08:00:00.000Z",
"stats": {
"entered": 0,
"active": 0,
"sent": 0
},
"description": "",
"graph": {
"nodes": [
{
"id": "kazdy-den",
"type": "trigger_repeat",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"every": {
"unit": "days",
"value": 1
},
"filter": {
"type": "group",
"match": "all",
"rules": [
{
"type": "last_order",
"value": "120",
"shopId": "21",
"operator": "older_than_days"
},
{
"type": "order_count",
"value": "1",
"shopId": "21",
"operator": "gte"
}
]
},
"reentry": "once",
"startAt": "2026-10-02T10:00"
}
},
{
"id": "email-1",
"type": "send_email",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"templateId": "306"
}
},
{
"id": "tyden",
"type": "wait",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"mode": "duration",
"unit": "days",
"value": 7
}
},
{
"id": "nakoupil",
"type": "condition",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"shopId": "21",
"operator": "yes"
}
]
}
}
},
{
"id": "email-2",
"type": "send_email",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"templateId": "307"
}
},
{
"id": "cil",
"type": "goal",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"shopId": "21",
"operator": "yes"
}
]
}
}
}
],
"edges": [
{
"source": "kazdy-den",
"target": "email-1",
"branch": "next"
},
{
"source": "email-1",
"target": "tyden",
"branch": "next"
},
{
"source": "tyden",
"target": "nakoupil",
"branch": "next"
},
{
"source": "nakoupil",
"target": "email-2",
"branch": "no"
}
]
},
"issues": [],
"triggers": {}
}Pozastavení nechá čekající kontakty na místě; po dalším zapnutí pokračují:
curl -sS -X POST "https://www.postarna.cz/api/v1/tenants/$TENANT/automations/85/pause" \
-H "Authorization: Bearer $POSTARNA_API_KEY"{
"id": "85",
"name": "Win-back po 120 dnech",
"shopId": "21",
"status": "paused",
"version": 1,
"activeSince": null,
"firstActivatedAt": "2026-10-01T08:00:00.000Z",
"pausedReason": "manual",
"tags": [],
"createdAt": "2026-10-01T08:00:00.000Z",
"updatedAt": "2026-10-01T08:00:00.000Z",
"stats": {
"entered": 0,
"active": 0,
"sent": 0
},
"description": "",
"graph": {
"nodes": [
{
"id": "kazdy-den",
"type": "trigger_repeat",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"every": {
"unit": "days",
"value": 1
},
"filter": {
"type": "group",
"match": "all",
"rules": [
{
"type": "last_order",
"value": "120",
"shopId": "21",
"operator": "older_than_days"
},
{
"type": "order_count",
"value": "1",
"shopId": "21",
"operator": "gte"
}
]
},
"reentry": "once",
"startAt": "2026-10-02T10:00"
}
},
{
"id": "email-1",
"type": "send_email",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"templateId": "306"
}
},
{
"id": "tyden",
"type": "wait",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"mode": "duration",
"unit": "days",
"value": 7
}
},
{
"id": "nakoupil",
"type": "condition",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"shopId": "21",
"operator": "yes"
}
]
}
}
},
{
"id": "email-2",
"type": "send_email",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"templateId": "307"
}
},
{
"id": "cil",
"type": "goal",
"name": "",
"note": "",
"position": {
"x": 0,
"y": 0
},
"config": {
"definition": {
"type": "group",
"match": "all",
"rules": [
{
"type": "ordered_since_entry",
"shopId": "21",
"operator": "yes"
}
]
}
}
}
],
"edges": [
{
"source": "kazdy-den",
"target": "email-1",
"branch": "next"
},
{
"source": "email-1",
"target": "tyden",
"branch": "next"
},
{
"source": "tyden",
"target": "nakoupil",
"branch": "next"
},
{
"source": "nakoupil",
"target": "email-2",
"branch": "no"
}
]
},
"issues": [],
"triggers": {}
}curl -sS -X GET "https://www.postarna.cz/api/v1/tenants/$TENANT/automations/85/versions" \
-H "Authorization: Bearer $POSTARNA_API_KEY"{
"items": [
{
"version": 1,
"status": "draft",
"savedAt": "2026-10-01T08:00:00.000Z",
"savedBy": "api_key:11",
"nodes": 6,
"current": true
}
]
}Tipy
- Filtr spouštěče počítá dny v časové zóně firmy;
last_order older_than_days 120znamená „má objednávku a poslední je starší než 120 dní“. - Pro neotevírající odběratele (místo zákazníků) použijte pravidlo
fieldlastOpenAtnot_in_last_days"180". - Odměnu v druhém e-mailu dejte jednorázovým kódem (
data.promoCode), viz recept na svátky.