Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bjornpagen/segflow
An open-source, self-hosted, full-code alternative to Customer.io. Write your user engagement logic in pure TypeScript and SQL (Drizzle ORM).
https://github.com/bjornpagen/segflow
campaigns email-marketing
Last synced: 8 days ago
JSON representation
An open-source, self-hosted, full-code alternative to Customer.io. Write your user engagement logic in pure TypeScript and SQL (Drizzle ORM).
- Host: GitHub
- URL: https://github.com/bjornpagen/segflow
- Owner: bjornpagen
- License: 0bsd
- Created: 2024-11-13T20:31:01.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-11-18T01:13:58.000Z (about 1 month ago)
- Last Synced: 2024-12-11T08:04:59.812Z (11 days ago)
- Topics: campaigns, email-marketing
- Language: TypeScript
- Homepage: https://segflow.io
- Size: 135 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Segflow: Zero to Hero Guide
## What is Segflow?
Segflow lets you write marketing automation flows in pure code. Instead of clicking through complex UIs, you can:
- Define user segments with SQL queries
- Write campaign logic in TypeScript
- Create email templates in React
- Deploy everything with GitThink "Infrastructure as Code", but for marketing automation. See the example in `examples/segflow.config.ts` for a complete example.
## Key Concepts
### Segments = SQL Queries
Define user groups with the full power of SQL:
```typescript
segments: {
'big-spenders': {
evaluator: (db) => db
.select({ id: schema.users.id })
.from(schema.users)
.innerJoin(schema.events, eq(schema.events.userId, schema.users.id))
.where(eq(schema.events.name, 'purchase'))
.groupBy(schema.users.id)
.having(sql`sum(${schema.events.attributes}->'$.amount') > 1000`)
}
}
```### Campaigns = Generator Functions
Write complex flows with regular TypeScript:
```typescript
campaigns: {
'onboarding': {
segments: ['new-users'],
behavior: 'static',
flow: function* (ctx, rt) {
yield rt.sendEmail('welcome');
yield rt.wait({ days: 1 });
if (!ctx.user.profileCompleted) {
yield rt.sendEmail('complete-profile-reminder');
yield rt.wait({ days: 3 });
}
yield rt.wait({ days: 3 });
yield rt.sendEmail('feature-highlights');
}
}
}
```### Templates = React Components
Design emails with familiar tools:
```tsx
templates: {
'welcome': {
subject: (user) => `Welcome ${user.name}!`,
component: ({ user }) => (