Define any business capability as a robust, versioned service. Deploy complex logic as simple APIs and SDKs, turning your operations into scalable, on-demand software.
import { Service, type Context } from '@do/sdk';
// Define the input and output schemas for your service
interface OnboardingInput {
name: string;
email: string;
plan: 'free' | 'pro' | 'enterprise';
}
interface OnboardingOutput {
customerId: string;
welcomeEmailSent: boolean;
status: 'complete' | 'failed';
}
// Create a new Service instance with your business logic
export default new Service({
name: 'customer-onboarding',
description: 'Onboards a new customer, creating an account and sending a welcome email.',
async run(input: OnboardingInput, context: Context): Promise {
console.log(`Starting onboarding for ${input.email} on plan ${input.plan}`);
// Business logic goes here.
// e.g., call user.create, email.send, billing.setup agents
const customerId = `cust_${context.invocationId}`;
return {
customerId,
welcomeEmailSent: true,
status: 'complete',
};
},
});