.do
Fundamentals

Autonomous Operations

Building self-operating businesses with AI-driven logic

Autonomous operations enable businesses to run themselves through AI-driven decision-making and automated workflows.

What Makes a Business Autonomous?

An autonomous business operates with minimal human intervention by:

  1. Understanding Context - Semantic data enables AI comprehension
  2. Making Decisions - AI chooses optimal actions
  3. Executing Actions - Workflows run automatically
  4. Learning & Adapting - Performance improves over time
  5. Escalating Appropriately - Humans intervene only when needed
graph TB subgraph Autonomous["Autonomous Business Operations"] D[Data & Context<br/>Semantic entities & relationships] AI[AI Decision Engine<br/>Analysis & recommendations] A[Automated Actions<br/>Workflows & integrations] M[Monitoring & Learning<br/>Performance tracking] H[Human Oversight<br/>Strategic decisions only] D --> AI AI --> A A --> M M --> D M -.->|Escalate exceptions| H H -.->|Adjust strategy| AI end

AI Decision Engine

The core of autonomous operations is AI-powered decision-making:

Basic AI Decisions

import { ai } from 'sdk.do'

// AI decides pricing
const pricing = await ai.decide('product-pricing', {
  product,
  market: 'competitive',
  demand: salesMetrics,
  costs: costBreakdown
})

// AI decides inventory levels
const inventory = await ai.decide('inventory-management', {
  product,
  salesHistory,
  seasonality,
  leadTime: supplier.leadTime
})

// AI decides shipping method
const shipping = await ai.decide('shipping-method', {
  order,
  destination,
  urgency,
  cost Constraints
})

Decision Strategies

Different strategies for different contexts:

// Conservative: Minimize risk
const decision = await ai.decide('inventory-reorder', {
  product,
  strategy: 'conservative',
  riskTolerance: 'low',
})

// Aggressive: Maximize growth
const decision = await ai.decide('pricing-optimization', {
  product,
  strategy: 'aggressive',
  goal: 'market-share',
})

// Balanced: Optimize trade-offs
const decision = await ai.decide('resource-allocation', {
  budget,
  strategy: 'balanced',
  objectives: ['growth', 'profitability', 'sustainability'],
})

Complete Autonomous Examples

1. Autonomous E-Commerce Store

A store that manages itself:

import $, { db, on, send, ai } from 'sdk.do'

// Product lifecycle management
on($.Product.created, async (product) => {
  // AI generates product content
  const content = await ai.generate('product-marketing', {
    product,
    tone: 'engaging',
    includes: ['description', 'benefits', 'use-cases'],
  })

  await db.update($.Product, product.$id, {
    description: content.description,
    additionalProperty: content.features,
  })

  // AI suggests initial pricing
  const pricing = await ai.decide('initial-pricing', {
    product,
    category: product.category,
    competitors: await findCompetitors(product),
  })

  await db.update($.Product, product.$id, {
    offers: [
      {
        $type: 'Offer',
        price: pricing.recommendedPrice,
        priceCurrency: 'USD',
      },
    ],
  })
})

// Dynamic pricing automation
setInterval(async () => {
  const products = await db.list($.Product, {
    where: { isActive: true },
  })

  for (const product of products) {
    const decision = await ai.decide('dynamic-pricing', {
      product,
      demand: await db.analyze('product-demand', {
        product,
        timeRange: '7d',
      }),
      competition: await analyzeCompetition(product),
      inventory: product.inventory,
      targetMargin: 0.4,
    })

    if (decision.shouldUpdate) {
      await db.update($.Product, product.$id, {
        offers: [
          {
            $type: 'Offer',
            price: decision.recommendedPrice,
            priceCurrency: 'USD',
            priceValidUntil: decision.validUntil,
          },
        ],
      })

      // Log decision for audit
      await db.create($.PriceChange, {
        product: product.$id,
        oldPrice: product.offers[0].price,
        newPrice: decision.recommendedPrice,
        reason: decision.reasoning,
        confidence: decision.confidence,
        timestamp: new Date(),
      })
    }
  }
}, 3600000) // Hourly

// Autonomous inventory management
on($.Product.lowStock, async (product) => {
  // AI analyzes if reorder is needed
  const decision = await ai.decide('inventory-reorder', {
    product,
    currentStock: product.inventory,
    reorderPoint: product.reorderPoint,
    salesVelocity: await db.analyze('sales-velocity', {
      product,
      timeRange: '30d',
    }),
    seasonality: await db.analyze('seasonal-trends', {
      product,
      category: product.category,
    }),
    supplier: await db.related(product, $.suppliedBy, $.Organization),
  })

  if (decision.shouldReorder) {
    // Create purchase order automatically
    const po = await $.PurchaseOrder.create({
      $type: 'Order',
      seller: decision.supplier,
      orderedItem: [
        {
          orderItem: product,
          orderQuantity: decision.recommendedQuantity,
        },
      ],
      expectedDelivery: decision.estimatedDelivery,
    })

    await send($.PurchaseOrder.created, po)

    // If urgent, escalate to human
    if (decision.urgency === 'high') {
      await send($.Notification.send, {
        to: $.Role.InventoryManager,
        priority: 'high',
        message: `Urgent reorder created for ${product.name}`,
        action: { review: po.$id },
      })
    }
  }
})

// Intelligent customer service
on($.SupportTicket.created, async (ticket) => {
  // AI analyzes ticket
  const analysis = await ai.analyze('support-ticket', {
    ticket,
    customer: ticket.customer,
    history: await db.related(ticket.customer, $.submitted, $.SupportTicket),
  })

  if (analysis.canAutoResolve) {
    // AI resolves automatically
    const resolution = await ai.generate('ticket-response', {
      ticket,
      tone: 'helpful',
      style: 'professional',
    })

    await send($.Email.send, {
      to: ticket.customer.email,
      subject: `Re: ${ticket.subject}`,
      body: resolution,
    })

    await db.update($.SupportTicket, ticket.$id, {
      status: 'resolved',
      resolution,
      resolvedBy: 'AI',
      resolvedAt: new Date(),
    })
  } else {
    // Route to human agent
    const agent = await ai.decide('agent-routing', {
      ticket,
      analysis,
      agents: await db.list($.Person, {
        where: { role: 'support-agent', status: 'available' },
      }),
    })

    await send($.SupportTicket.assigned, {
      ticket,
      agent: agent.selected,
    })
  }
})

2. Autonomous SaaS Business

Self-managing subscription service:

// Intelligent onboarding
on($.Person.registered, async (person) => {
  // AI personalizes onboarding
  const onboarding = await ai.generate('onboarding-plan', {
    user: person,
    product: await db.get($.Service, 'main-product'),
    persona: await ai.analyze('user-persona', { person }),
  })

  // Create personalized tasks
  for (const task of onboarding.tasks) {
    await $.Action.create({
      $type: 'Action',
      name: task.name,
      description: task.description,
      agent: person,
      actionStatus: 'PotentialActionStatus',
      expectedDuration: task.duration,
    })
  }

  // Schedule follow-ups
  for (const followUp of onboarding.followUps) {
    await send($.Email.schedule, {
      to: person.email,
      template: followUp.template,
      sendAt: followUp.timing,
      data: { person, progress: followUp.checkpoints },
    })
  }
})

// Proactive churn prevention
setInterval(async () => {
  const subscriptions = await db.list($.Service, {
    where: { status: 'active' },
  })

  for (const sub of subscriptions) {
    // AI predicts churn risk
    const risk = await ai.analyze('churn-risk', {
      subscription: sub,
      customer: sub.customer,
      usage: await db.analyze('usage-metrics', {
        customer: sub.customer,
        timeRange: '30d',
      }),
      engagement: await db.analyze('engagement-score', {
        customer: sub.customer,
      }),
      support: await db.related(sub.customer, $.submitted, $.SupportTicket),
    })

    if (risk.score > 0.7) {
      // AI determines intervention
      const intervention = await ai.decide('churn-prevention', {
        customer: sub.customer,
        risk,
        subscription: sub,
      })

      if (intervention.action === 'offer-discount') {
        await send($.Offer.send, {
          customer: sub.customer,
          offer: intervention.offer,
          message: intervention.message,
          validUntil: intervention.expires,
        })
      } else if (intervention.action === 'schedule-call') {
        await send($.Meeting.schedule, {
          customer: sub.customer,
          type: 'success-call',
          agent: intervention.assignedAgent,
        })
      }

      // Escalate high-value customers
      if (sub.customer.lifetimeValue > 10000 && risk.score > 0.8) {
        await send($.Notification.send, {
          to: $.Role.CustomerSuccess,
          priority: 'urgent',
          message: `High-value customer at risk: ${sub.customer.name}`,
          data: { customer: sub.customer, risk, intervention },
        })
      }
    }
  }
}, 86400000) // Daily

// Autonomous feature adoption
on($.Feature.released, async (feature) => {
  // Find ideal customers for feature
  const targets = await ai.recommend({
    type: $.Person,
    for: feature,
    strategy: 'ideal-users',
    limit: 100,
  })

  for (const customer of targets) {
    // AI creates personalized introduction
    const intro = await ai.generate('feature-announcement', {
      feature,
      customer,
      personalization: await ai.analyze('customer-needs', { customer }),
    })

    await send($.Email.send, {
      to: customer.email,
      subject: intro.subject,
      body: intro.content,
      cta: {
        text: 'Try It Now',
        link: intro.ctaLink,
      },
    })

    // Track engagement
    await db.create($.FeatureAnnouncement, {
      feature,
      customer,
      sentAt: new Date(),
      personalization: intro.strategy,
    })
  }
})

// Intelligent usage-based pricing
on($.Usage.recorded, async (usage) => {
  const customer = usage.customer
  const subscription = await db.related(customer, $.subscribes, $.Service)

  // AI optimizes plan recommendation
  const recommendation = await ai.decide('plan-optimization', {
    customer,
    currentPlan: subscription.plan,
    usage: await db.analyze('usage-patterns', {
      customer,
      timeRange: '90d',
    }),
    value: await db.analyze('customer-value', { customer }),
  })

  if (recommendation.shouldChange) {
    await send($.Notification.send, {
      to: customer,
      type: 'plan-recommendation',
      message: recommendation.message,
      savings: recommendation.savings,
      newPlan: recommendation.recommendedPlan,
    })
  }
})

3. Autonomous Marketplace

Platform that manages itself:

// Intelligent matching
on($.Request.created, async (request) => {
  // AI finds best matches
  const matches = await ai.recommend({
    type: $.Offer,
    for: request,
    strategy: 'best-fit',
    factors: ['quality', 'price', 'availability', 'reputation'],
    limit: 5,
  })

  // Notify sellers
  for (const match of matches) {
    await send($.Notification.send, {
      to: match.seller,
      type: 'new-opportunity',
      request,
      fitScore: match.score,
      reasoning: match.explanation,
    })
  }

  // Auto-match if confidence is high
  if (matches[0].score > 0.95) {
    await send($.Match.create, {
      request,
      offer: matches[0],
      confidence: matches[0].score,
      auto: true,
    })
  }
})

// Dynamic pricing for marketplace
on($.Offer.created, async (offer) => {
  // AI suggests optimal price
  const pricing = await ai.decide('marketplace-pricing', {
    offer,
    seller: offer.seller,
    category: offer.category,
    competition: await db.list($.Offer, {
      where: {
        category: offer.category,
        availability: $.InStock,
      },
    }),
    demand: await db.analyze('category-demand', {
      category: offer.category,
    }),
  })

  if (Math.abs(pricing.recommendedPrice - offer.price) / offer.price > 0.1) {
    // Significant difference, notify seller
    await send($.Notification.send, {
      to: offer.seller,
      type: 'pricing-suggestion',
      currentPrice: offer.price,
      suggestedPrice: pricing.recommendedPrice,
      reasoning: pricing.explanation,
      potentialImpact: pricing.projectedSales,
    })
  }
})

// Quality control automation
on($.Transaction.completed, async (transaction) => {
  // AI analyzes transaction quality
  const quality = await ai.analyze('transaction-quality', {
    transaction,
    buyer: transaction.buyer,
    seller: transaction.seller,
    communications: await db.related(transaction, $.includes, $.Message),
    timeline: transaction.timeline,
  })

  if (quality.score < 0.6) {
    // Potential issue, monitor closely
    await send($.Transaction.flagged, {
      transaction,
      reason: quality.concerns,
      severity: quality.severity,
    })

    if (quality.severity === 'high') {
      // Escalate immediately
      await send($.Notification.send, {
        to: $.Role.TrustAndSafety,
        priority: 'urgent',
        transaction,
        concerns: quality.concerns,
      })
    }
  }

  // Update reputation scores
  await db.increment(transaction.seller, $.reputation.score, quality.sellerRating)
  await db.increment(transaction.buyer, $.reputation.score, quality.buyerRating)
})

Levels of Autonomy

Progressive levels of autonomous operation:

Level 1: Assisted

Human makes decisions, AI provides insights:

// AI assists human decision
const insight = await ai.analyze('inventory-status', { product })

// Human decides based on insight
if (shouldReorder) {
  await createPurchaseOrder(product)
}

Level 2: Guided

AI recommends, human approves:

// AI recommends action
const recommendation = await ai.decide('inventory-reorder', { product })

// Wait for human approval
await send($.Approval.request, {
  to: $.Role.InventoryManager,
  recommendation,
  action: $.PurchaseOrder.create,
})

Level 3: Conditional

AI acts autonomously within constraints:

// AI acts if conditions met
const decision = await ai.decide('inventory-reorder', { product })

if (decision.shouldReorder && decision.confidence > 0.8) {
  // Autonomous action
  await $.PurchaseOrder.create({
    product,
    quantity: decision.quantity,
  })
} else {
  // Escalate if unsure
  await send($.Approval.request, { decision })
}

Level 4: Fully Autonomous

AI operates independently, humans monitor:

// AI acts autonomously
on($.Product.lowStock, async (product) => {
  const decision = await ai.decide('inventory-reorder', { product })

  // Always act on AI decision
  const po = await $.PurchaseOrder.create({
    product,
    quantity: decision.quantity,
  })

  // Log for audit trail
  await db.create($.Decision, {
    type: 'inventory-reorder',
    input: { product },
    output: decision,
    action: po,
    timestamp: new Date(),
  })
})

Monitoring & Learning

Autonomous systems must track and improve:

// Track decision outcomes
on($.Decision.made, async (decision) => {
  await db.create($.DecisionLog, {
    decision,
    context: decision.context,
    recommendation: decision.recommendation,
    timestamp: new Date(),
  })
})

// Measure outcomes
on($.Outcome.observed, async (outcome) => {
  const decision = await db.related(outcome, $.resultOf, $.Decision)

  await db.update($.DecisionLog, decision.$id, {
    outcome: outcome.result,
    accuracy: outcome.accuracy,
    impact: outcome.impact,
  })

  // AI learns from outcome
  await ai.learn({
    decision: decision.type,
    context: decision.context,
    recommendation: decision.recommendation,
    outcome: outcome.result,
    success: outcome.accuracy > 0.7,
  })
})

// Performance dashboard
const performance = await db.analyze('ai-decision-performance', {
  decisionType: 'inventory-reorder',
  timeRange: '30d',
})

console.log({
  totalDecisions: performance.count,
  accuracy: performance.accuracy,
  impact: performance.averageImpact,
  improvements: performance.learningRate,
})

Best Practices

1. Start Small

Begin with low-risk autonomous decisions:

// Low risk: Email timing
const timing = await ai.decide('email-timing', { customer })

// Medium risk: Pricing adjustments
const pricing = await ai.decide('price-optimization', { product })

// High risk: Inventory commitments
const inventory = await ai.decide('inventory-reorder', { product })

2. Set Confidence Thresholds

Only act when AI is confident:

const decision = await ai.decide('critical-action', context)

if (decision.confidence > 0.9) {
  // High confidence, act autonomously
  await executeAction(decision)
} else if (decision.confidence > 0.7) {
  // Medium confidence, notify human
  await send($.Approval.request, { decision })
} else {
  // Low confidence, require human decision
  await send($.ManualReview.required, { context, decision })
}

3. Implement Circuit Breakers

Prevent runaway automation:

// Track error rates
const errors = await db.count($.Error, {
  where: {
    type: 'inventory-reorder',
    timestamp: { $gte: subHours(new Date(), 1) },
  },
})

if (errors > 10) {
  // Too many errors, pause automation
  await send($.Automation.pause, {
    system: 'inventory-management',
    reason: 'error-threshold-exceeded',
  })

  await send($.Notification.send, {
    to: $.Role.SystemAdmin,
    priority: 'urgent',
    message: 'Inventory automation paused due to errors',
  })
}

4. Audit Everything

Log all autonomous decisions:

async function makeDecision(type: string, context: any) {
  const decision = await ai.decide(type, context)

  // Log decision
  await db.create($.DecisionLog, {
    type,
    context,
    decision,
    confidence: decision.confidence,
    timestamp: new Date(),
    executed: false,
  })

  // Execute if confident
  if (decision.confidence > 0.8) {
    await executeAction(decision)

    // Mark as executed
    await db.update($.DecisionLog, decision.$id, {
      executed: true,
      executedAt: new Date(),
    })
  }

  return decision
}

Summary

Autonomous operations transform businesses by:

  • Reducing manual work - AI handles routine decisions
  • Improving consistency - Decisions based on data, not intuition
  • Scaling effortlessly - Operations scale without adding staff
  • Learning continuously - Performance improves over time
  • Enabling focus - Humans work on strategy, not tactics

Start small, measure results, and gradually increase autonomy as confidence grows.


Next: Workflow Patterns →