Workflow Automation
The workflow engine lets you automate actions in response to booking events — send custom emails, fire webhooks, update booking status, or sync calendars based on configurable triggers and conditions.
Workflow structure
Section titled “Workflow structure”import type { WorkflowDefinition } from "@thebookingkit/core";
const workflow: WorkflowDefinition = { name: "Send follow-up after completion", trigger: "booking.completed", conditions: [ { field: "event.title", operator: "contains", value: "Consultation", }, ], actions: [ { type: "send_email", config: { to: "{{customer.email}}", subject: "Thank you for your consultation, {{customer.name}}!", body: "We hope your session on {{booking.date}} was helpful.", }, }, ],};Triggers
Section titled “Triggers”| Trigger | Fires when |
|---|---|
booking.created | A new booking is created |
booking.confirmed | A booking is confirmed |
booking.cancelled | A booking is cancelled |
booking.rescheduled | A booking is rescheduled |
booking.completed | An appointment is marked complete |
booking.no_show | A customer no-shows |
booking.reminder | Reminder time is reached |
Conditions
Section titled “Conditions”import { evaluateConditions } from "@thebookingkit/core";
const conditions: WorkflowCondition[] = [ { field: "booking.priceCents", operator: "greater_than", value: 0 }, { field: "event.title", operator: "contains", value: "Premium" },];
const match = evaluateConditions(conditions, context);// Returns true if ALL conditions matchOperators
Section titled “Operators”equals, not_equals, contains, not_contains, greater_than, less_than, is_empty, is_not_empty
Actions
Section titled “Actions”| Type | Description |
|---|---|
send_email | Send an email via EmailAdapter |
send_sms | Send an SMS via SmsAdapter |
fire_webhook | POST to a URL |
update_status | Change booking status |
sync_calendar | Create/update calendar event |
Template variables
Section titled “Template variables”All text fields support template variables:
import { resolveTemplateVariables, TEMPLATE_VARIABLES } from "@thebookingkit/core";
const resolved = resolveTemplateVariables( "Hello {{customer.name}}, your {{event.title}} is on {{booking.date}}", context);Available variables: {{customer.name}}, {{customer.email}}, {{booking.date}}, {{booking.time}}, {{event.title}}, {{event.duration}}, {{provider.name}}, {{booking.status}}, and more.
Validation
Section titled “Validation”import { validateWorkflow, WorkflowValidationError } from "@thebookingkit/core";
validateWorkflow(workflow);// Throws WorkflowValidationError if trigger, conditions, or actions are invalidMatching workflows
Section titled “Matching workflows”import { matchWorkflows } from "@thebookingkit/core";
const matching = matchWorkflows(allWorkflows, "booking.confirmed", context);// Returns workflows whose trigger matches and all conditions pass