Skip to content

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.

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.",
},
},
],
};
TriggerFires when
booking.createdA new booking is created
booking.confirmedA booking is confirmed
booking.cancelledA booking is cancelled
booking.rescheduledA booking is rescheduled
booking.completedAn appointment is marked complete
booking.no_showA customer no-shows
booking.reminderReminder time is reached
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 match

equals, not_equals, contains, not_contains, greater_than, less_than, is_empty, is_not_empty

TypeDescription
send_emailSend an email via EmailAdapter
send_smsSend an SMS via SmsAdapter
fire_webhookPOST to a URL
update_statusChange booking status
sync_calendarCreate/update calendar event

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.

import { validateWorkflow, WorkflowValidationError } from "@thebookingkit/core";
validateWorkflow(workflow);
// Throws WorkflowValidationError if trigger, conditions, or actions are invalid
import { matchWorkflows } from "@thebookingkit/core";
const matching = matchWorkflows(allWorkflows, "booking.confirmed", context);
// Returns workflows whose trigger matches and all conditions pass