mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 00:03:23 +00:00
Make workflow documentation more concise
- Simplified workflow section to focus on key advantage - Removed verbose comparison table and features list - Kept essential usage example with processImmediately option - More readable and focused on the main differentiator
This commit is contained in:
44
README.md
44
README.md
@@ -466,66 +466,32 @@ The task can also be triggered from the Payload admin panel with a user-friendly
|
|||||||
|
|
||||||
### Workflow Integration
|
### Workflow Integration
|
||||||
|
|
||||||
The plugin also provides a workflow for sending emails with advanced features:
|
For advanced features, use the workflow instead:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { sendEmailWorkflow } from '@xtr-dev/payload-mailing'
|
import { sendEmailWorkflow } from '@xtr-dev/payload-mailing'
|
||||||
|
|
||||||
export default buildConfig({
|
export default buildConfig({
|
||||||
// ... your config
|
|
||||||
jobs: {
|
jobs: {
|
||||||
workflows: [
|
workflows: [sendEmailWorkflow]
|
||||||
sendEmailWorkflow,
|
|
||||||
// ... your other workflows
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Workflow Features
|
**Key advantage**: Optional `processImmediately` option to send emails instantly instead of queuing.
|
||||||
|
|
||||||
- **Immediate Processing**: Option to send emails immediately instead of queuing
|
|
||||||
- **Admin UI**: Rich form interface with conditional fields
|
|
||||||
- **Status Tracking**: Track workflow execution progress
|
|
||||||
- **Template or Direct**: Support for both template-based and direct HTML emails
|
|
||||||
|
|
||||||
### Using the Workflow
|
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Queue a workflow with immediate processing
|
|
||||||
await payload.workflows.queue({
|
await payload.workflows.queue({
|
||||||
workflow: 'send-email',
|
workflow: 'send-email',
|
||||||
input: {
|
input: {
|
||||||
processImmediately: true, // Send immediately
|
processImmediately: true, // Send immediately (default: false)
|
||||||
templateSlug: 'welcome-email',
|
templateSlug: 'welcome-email',
|
||||||
to: ['user@example.com'],
|
to: ['user@example.com'],
|
||||||
variables: { name: 'John Doe' }
|
variables: { name: 'John' }
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Queue normally (processed by background job)
|
|
||||||
await payload.workflows.queue({
|
|
||||||
workflow: 'send-email',
|
|
||||||
input: {
|
|
||||||
processImmediately: false, // Default: false
|
|
||||||
subject: 'Direct Email',
|
|
||||||
html: '<h1>Hello World!</h1>',
|
|
||||||
to: ['user@example.com']
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Workflow vs Task Comparison
|
|
||||||
|
|
||||||
| Feature | Task | Workflow |
|
|
||||||
|---------|------|----------|
|
|
||||||
| Admin UI | Basic form | Rich form with conditions |
|
|
||||||
| Immediate Processing | ❌ | ✅ (optional) |
|
|
||||||
| Status Tracking | Basic | Detailed with progress |
|
|
||||||
| Template Support | ✅ | ✅ |
|
|
||||||
| Direct HTML Support | ✅ | ✅ |
|
|
||||||
| Background Processing | ✅ | ✅ |
|
|
||||||
|
|
||||||
## Job Processing
|
## Job Processing
|
||||||
|
|
||||||
The plugin automatically adds a unified email processing job to PayloadCMS:
|
The plugin automatically adds a unified email processing job to PayloadCMS:
|
||||||
|
|||||||
Reference in New Issue
Block a user