You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contents/docs/workflows/best-practices.mdx
+43-29Lines changed: 43 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,23 @@ sidebar: Docs
4
4
showTitle: true
5
5
---
6
6
7
+
## Boundaries
8
+
### Define clear triggers and avoid overlapping workflows
7
9
8
-
## 1. Define clear triggers and avoid overlapping workflows
9
-
10
-
Use a single well-defined trigger per workflow (e.g. “user sign-up”, “purchase completed”, or a webhook), so the logic is clear. PostHog defines that every workflow starts with a trigger and ends with an exit.
10
+
Use a single well-defined trigger per workflow (e.g. “user sign-up”, “purchase completed”, or a webhook), so the logic is clear. PostHog defines that every workflow starts with a trigger and end with an exit.
11
11
12
12
Avoid multiple workflows that respond to the same event and perform overlapping actions as this can cause duplicate messages or conflicting side-effects.
13
13
14
14
If you really need multiple workflows on the same event, consider whether a single workflow with [audience splits](/docs/workflows/workflow-builder#audience-splits)/branching logic would serve better.
15
15
16
-
## 2. Limit complexity and keep logic as simple as possible
16
+
### Minimize deduplication and side-effects
17
+
18
+
Don’t duplicate workflows that do essentially the same thing under slightly different triggers, which increases the risk of duplicate messages, conflicting updates, or unexpected user experience.
19
+
20
+
Avoid side-effects where possible. For example, don’t rely too heavily on property updates or event triggers inside a workflow, treat automations as eventual side-effects, not core business logic.
21
+
22
+
## Logic, branching, and timing
23
+
### Limit complexity and keep logic as simple as possible
17
24
18
25
Use minimal branching and splits. Complex branching can make workflows hard to reason about.
19
26
@@ -26,37 +33,40 @@ Use minimal branching and splits. Complex branching can make workflows hard to r
26
33
27
34
If you find yourself duplicating logic across multiple workflows, consider refactoring: either unify into one workflow or extract repeated logic into reusable sub-workflows (if supported), or design event properties in a way that triggers workflows cleanly.
28
35
29
-
##3. Use delays and conditions responsibly
36
+
###Use delays and conditions responsibly
30
37
31
38
Use delay steps (e.g. “wait 2 days”) or conditional logic only when necessary. Overuse can lead to unpredictable states, e.g. if user attributes change during the delay, or if event data evolves.
32
39
33
40
Keep records/logs where possible, especially for later debugging (e.g. knowing that a user was “waiting in step N of workflow X”).
34
41
35
-
##4. Ensure messaging channels are properly configured and tested
42
+
### Design for fallback and safe defaults
36
43
37
-
Before sending emails or other messages, [set up and verify your channels](/docs/workflows/configure-channels). For email: configure "from" name, from-address, and DNS (SPF/DKIM) to avoid spam/folder issues.
38
-
39
-
Use templating and personalization carefully (e.g. with placeholders like `{{ person.name }}`), but also verify that placeholders resolve and avoid sending messages with unresolved variables.
40
-
41
-
If sending to external channels (e.g. Slack, SMS, webhooks), treat them as equally important as email: ensure you have fallback or error handling logic (e.g. when a webhook endpoint fails).
44
+
For actions that send messages or update user data: ensure that if some data is missing (e.g. user email, user property) the workflow safely skips or uses defaults rather than failing or sending bad messages.
42
45
43
-
## 5. Plan for maintainability: naming, versioning, cleanup
Give workflows descriptive names like `welcome_email_on_signup`, `drip_7_day_followup`, etc. Avoid ambiguous names like `workflow1`. Version your workflows when you make significant logic changes, or at least document changes in a changelog, so you know which version ran when.
53
+
## Testing setups and delivery
46
54
47
-
When a workflow becomes obsolete (e.g. onboarding process changed, or a campaign ended), archive or delete it to avoid accidental triggering and reduce maintenance burden.
55
+
### Ensure messaging channels are properly configured and tested
48
56
49
-
## 6. Minimize duplication and side-effects
57
+
Before sending emails or other messages, [set up and verify your channels](/docs/workflows/configure-channels). For email: configure "from" name, from-address, and DNS (SPF/DKIM) to avoid spam/folder issues.
50
58
51
-
Don’t duplicate workflows that do essentially the same thing under slightly different triggers, which increases the risk of duplicate messages, conflicting updates, or unexpected user experience.
59
+
Use templating and personalization carefully (e.g. with placeholders like `{{ person.name }}`), but also verify that placeholders resolve and avoid sending messages with unresolved variables.
52
60
53
-
Avoid side-effects where possible. For example, don’t rely too heavily on property updates or event triggers inside a workflow, treat automations as eventual side-effects, not core business logic.
61
+
If sending to external channels (e.g. Slack, SMS, webhooks), treat them as equally important as email: ensure you have fallback or error handling logic (e.g. when a webhook endpoint fails).
54
62
55
-
##7. Test workflows in a safe environment or subset first (staging/small user group)
63
+
###Test workflows in a safe environment or subset first (staging/small user group)
56
64
57
65
Before a full rollout: test with internal users or a small percentage of real users. Monitor delivery (for emails/messages), event logs, user property updates, or other side-effects. Watch for unintended behavior: e.g. multiple emails, loops (if your workflow triggers events that retrigger the same workflow), or delays stacking up.
58
66
59
-
## 8. Monitor and log
67
+
## Observability and limits
68
+
69
+
### Monitor and log
60
70
61
71
Ensure that failures (e.g. email bounce, webhook error) are captured and surfaced. When facing a problem, check the “[Troubleshooting & FAQs](/docs/workflows/troubleshooting)” section for Workflows.
62
72
@@ -70,23 +80,27 @@ Periodically review metrics: how many messages sent, how many workflows triggere
70
80
classes="rounded"
71
81
/>
72
82
73
-
##9. Be mindful of costs and rate limits
83
+
###Be mindful of costs and rate limits
74
84
75
85
PostHog plans to price Workflows based on the number of real-time destinations and monthly messages after beta. Design workflows to minimize unnecessary messages. For example, avoid sending multiple messages to the same user around the same event, and use batching or deduplication logic where possible.
76
86
77
87
Clean up unused/outdated workflows to reduce unnecessary triggers and costs.
78
88
79
-
## 10. Document workflows: what they do, why they exist, who owns them
89
+
## Maintainability
90
+
91
+
### Plan for maintainability: naming, versioning, cleanup
92
+
93
+
Give workflows descriptive names like `welcome_email_on_signup`, `drip_7_day_followup`, etc. Avoid ambiguous names like `workflow1`. Version your workflows when you make significant logic changes, or at least document changes in a changelog, so you know which version ran when.
94
+
95
+
When a workflow becomes obsolete (e.g. onboarding process changed, or a campaign ended), archive or delete it to avoid accidental triggering and reduce maintenance burden.
96
+
97
+
### Document workflows: what they do, why they exist, who owns them
80
98
81
99
For each workflow, maintain a short description: what triggers it, what it does, expected behavior, and owner/maintainer. Document assumptions (e.g. “this workflow only runs for paid users”, “email template X must exist”, “delay step must be at least 24h”). Onboard new team members with a “workflow map,” a high-level overview of all active workflows and their purposes.
82
100
83
-
## 11. Design for fallback and safe defaults
84
101
85
-
For actions that send messages or update user data: ensure that if some data is missing (e.g. user email, user property) the workflow safely skips or uses defaults rather than failing or sending bad messages.
0 commit comments