Create your first flow
Now that pgflow is installed, let’s create a simple hello world flow that demonstrates the core concepts.
Our flow will:
- Take a person’s first name and last name as input
- Format a full name
- Create a personalized greeting
Creating a Simple Greeting Flow
Section titled “Creating a Simple Greeting Flow”-
Set up your project structure
Section titled “Set up your project structure”First, create a directory for your flow:
mkdir -p supabase/functions/_flowsDirectorysupabase
Directoryfunctions
Directory_flows
- greet_user.ts
-
Create the flow definition
Section titled “Create the flow definition”Create a file called
supabase/functions/_flows/greet_user.tswith this content:supabase/functions/_flows/greet_user.ts import { Flow } from 'npm:@pgflow/dsl';type Input = {first_name: string;last_name: string;};export default new Flow<Input>({slug: 'greet_user',}).step({ slug: 'full_name' },(input) => `${input.run.first_name} ${input.run.last_name}`).step({ slug: 'greeting', dependsOn: ['full_name'] },(input) => `Hello, ${input.full_name}!`);