PipesGuides
Quickstart
Build your first Pipes workflow in 5 minutes
This guide walks you through creating a simple Pipes workflow that reacts to order events, transforms the data, and sends it to an external fulfillment API.
Prerequisites
- An npayload account with an app and API credentials
- A channel named
orders(or any channel you want to react to)
Step 1: Create the workflow
import NPayload from '@npayload/node';
const npayload = new NPayload({
token: process.env.NPAYLOAD_TOKEN,
});
const workflow = await npayload.pipes.create({
name: 'order-fulfillment',
description: 'Process new orders and send to fulfillment',
trigger: {
type: 'event',
channel: 'orders',
filter: { event: 'order.created' },
},
});Step 2: Add a transform node
Extract the fields your fulfillment service needs:
workflow.addNode({
id: 'extract-fields',
type: 'transform',
expression: {
orderId: '{{ payload.id }}',
items: '{{ payload.lineItems }}',
shippingAddress: '{{ payload.shipping }}',
priority: '{{ payload.expedited ? "rush" : "standard" }}',
},
});Step 3: Add an HTTP action
Send the transformed data to your fulfillment service:
workflow.addNode({
id: 'send-to-fulfillment',
type: 'http',
method: 'POST',
url: 'https://api.fulfillment.com/orders',
headers: {
Authorization: 'Bearer {{ secrets.FULFILLMENT_API_KEY }}',
'Content-Type': 'application/json',
},
body: '{{ nodes["extract-fields"].output }}',
retries: 3,
});Step 4: Activate the workflow
await npayload.pipes.activate(workflow.id);Step 5: Test it
Publish a test message to the orders channel:
await npayload.messages.publish({
channel: 'orders',
payload: {
event: 'order.created',
id: 'ord_test_001',
lineItems: [
{ sku: 'WIDGET-A', quantity: 2 },
{ sku: 'GADGET-B', quantity: 1 },
],
shipping: {
name: 'Jane Doe',
address: '123 Main St',
city: 'Portland',
state: 'OR',
zip: '97201',
},
expedited: false,
},
});Check the execution status:
const executions = await npayload.pipes.executions.list({
workflow: workflow.id,
limit: 1,
});
console.log(executions[0].status); // "completed"
console.log(executions[0].duration); // "142ms"What you built
In 5 minutes, you created a workflow that:
- Triggers on new order events in the
orderschannel - Transforms the payload to match your fulfillment API schema
- Sends the data to an external service with automatic retries
- Checkpoints state at each step for durable execution
Next steps
- Building workflows for more complex workflow patterns
- Using AI nodes to add AI intelligence to your workflows
- Node types for all available node types
Was this page helpful?