In modern software development, business logic is often the ghost in the machine—scattered across microservices, buried in frontend components, and duplicated in serverless functions. This decentralization leads to inconsistency, makes auditing a nightmare, and slows innovation to a crawl. What if you could capture every business action, from a user follow to a complex financial transaction, as a single, auditable piece of code?
This is the promise of "Actions as Code," a paradigm that transforms your operations into composable, executable services. With Verbs.do, you can define, manage, and automate any business action, building powerful agentic workflows that bring clarity and control to your entire system.
In this guide, we'll walk you through building your first agentic workflow. We'll start with simple, isolated actions and compose them into an automated process that runs itself, all while maintaining a perfect audit trail.
An agentic workflow is a process where discrete actions can intelligently trigger other actions, creating a self-orchestrating system. Think of it as setting up rules for a team of autonomous agents. When a specific event occurs, an agent knows exactly what to do next, without needing manual intervention.
For example:
Instead of hard-coding this branching logic into a monolithic service, an agentic system defines each step—Purchase, RequestReview, GrantPoints—as a standalone "Verb." These Verbs become a universal language for action within your business, executable from anywhere and composable into endlessly complex workflows.
Let's build a simple workflow for a product review system. Our goal is to automatically ask a customer for a review a few days after their purchase. First, we need to define the core actions as Verbs.
Everything starts with a purchase. A "Purchase" is an action performed by a User (the subject) on a Product (the object). We can define this using the Verb constructor from verbs.do.
import { Verb } from 'verbs.do';
const purchase = new Verb({
name: 'Purchase',
subject: { type: 'User', description: 'The user making the purchase.' },
object: { type: 'Product', description: 'The product being purchased.' },
effects: [
{ type: 'createRecord', collection: 'orders', data: { userId: 'subject.id', productId: 'object.id' } },
{ type: 'decrement', field: 'product.stock', by: 1 }
]
});
Here’s what this code does:
Next, we need an action for the system to ask for a review. Here, the System is the subject acting upon the User.
const requestReview = new Verb({
name: 'RequestReview',
subject: { type: 'System', description: 'The automated system.' },
object: { type: 'User', description: 'The user being asked for a review.' },
properties: {
product: { type: 'Product', description: 'The product to be reviewed.' }
},
effects: [
{
type: 'notify',
user: 'object.id',
message: 'Thanks for buying `{properties.product.name}`! Please leave a review.'
}
]
});
This Verb is designed to send a notification to a user about a specific product. The properties field allows us to pass in extra context, like the product they bought.
With our building blocks in place, we can now create the agentic workflow. We'll modify our Purchase Verb to automatically trigger the RequestReview Verb. This is where the magic of "Business-as-Code" happens.
We simply add a new trigger effect to our Purchase Verb.
const purchase = new Verb({
name: 'Purchase',
subject: { type: 'User', description: 'The user making the purchase.' },
object: { type: 'Product', description: 'The product being purchased.' },
effects: [
{ type: 'createRecord', collection: 'orders', data: { userId: 'subject.id', productId: 'object.id' } },
{ type: 'decrement', field: 'product.stock', by: 1 },
{
type: 'trigger',
verb: 'RequestReview',
delay: '3 days', // Automate with a delay!
with: {
subject: 'system',
object: 'subject.id', // The user who made the purchase
properties: { product: 'object.id' } // The product that was purchased
}
}
]
});
With this one addition, our workflow is complete. The trigger effect instructs the Verbs.do engine to:
Now, any time the Purchase Verb is executed, the review request is automatically scheduled.
// A user buys a product from your frontend, backend, or mobile app
await purchase.execute({ subjectId: 'user-123', objectId: 'product-abc' });
// In 3 days, Verbs.do will automatically execute the equivalent of:
// await requestReview.execute({ subject: 'system', objectId: 'user-123', properties: { productId: 'product-abc' }});
You’ve just defined a sophisticated, automated business process in a few declarative lines of code. Because every step is a Verb, your system now has a perfectly clear and auditable log of all interactions:
This centralized log is invaluable for debugging, analytics, and understanding exactly how your business operates. You no longer have to dig through logs from five different services to piece together a user's journey.
By defining business actions as code, you unlock a new level of clarity, consistency, and automation. What we've built today is just the beginning. You can compose these Verbs into increasingly sophisticated workflows, creating intelligent systems that can react to user behavior, manage internal processes, and drive your business forward.
Ready to transform your business operations into powerful, executable code?
Visit Verbs.do to get started and define your first action today.