.do

Examples

Real-world CLI.do usage patterns and workflows

Real-world examples showing how to use CLI.do for common business automation tasks.

E-commerce Order Processing

Create and process orders with integrated payments and notifications:

do $.Order.create({
  customerId: 'cus_123',
  items: [{ productId: 'prod_456', quantity: 2, price: 99.99 }],
  total: 199.98
}).then(order => {
  # Send confirmation email
  api.sendgrid.sendEmail({
    to: order.customer.email,
    template: 'order-confirmation',
    data: { orderId: order.id }
  })

  # Notify Slack
  api.slack.postMessage({
    channel: '#sales',
    text: \`New order: $\${order.total}\`
  })

  # Process payment
  api.stripe.charges.create({
    amount: order.total * 100,
    customer: order.customerId
  })

  # Start fulfillment
  wf.run('orderFulfillment', { orderId: order.id })
})

Lead Enrichment Pipeline

Enrich new leads with external data and AI insights:

do db.Leads
  .filter({ createdAt: '>now-24h' })
  .forEach(lead => {
    # Enrich with Clearbit
    const enriched = api.clearbit.enrich({ email: lead.email })

    # Update lead
    lead.update({
      company: enriched.company,
      title: enriched.title,
      linkedin: enriched.linkedin
    })

    # Generate AI insights
    const insights = ai.generate({
      prompt: \`Analyze this lead: \${JSON.stringify(enriched)}\`,
      model: 'gpt-5'
    })

    # Notify sales team
    api.slack.postMessage({
      channel: '#sales',
      text: \`New qualified lead: \${lead.name} - \${insights}\`
    })
  })

Autonomous Task Generation

Generate business opportunities from O*NET occupation tasks:

do db.Occupations.forEach(occupation => {
  occupation.tasks.forEach(task => {
    # Generate lean canvas using AI
    const canvas = ai.generate({
      prompt: \`Create a lean canvas for: \${task.description}\`,
      model: 'claude-sonnet-4.5',
      schema: $.LeanCanvas
    })

    # Save as new business opportunity
    $.Business.create({
      name: task.name,
      description: task.description,
      leanCanvas: canvas,
      sourceOccupation: occupation.id,
      sourceTask: task.id
    })
  })
})

Multi-API Data Sync

Sync customer data across multiple platforms:

do db.Customers.filter({ synced: false }).forEach(customer => {
  # Create in Stripe
  const stripeCustomer = api.stripe.customers.create({
    email: customer.email,
    name: customer.name
  })

  # Add to SendGrid list
  api.sendgrid.contacts.add({
    email: customer.email,
    lists: ['newsletter']
  })

  # Create in CRM
  api.hubspot.contacts.create({
    email: customer.email,
    firstname: customer.firstName,
    lastname: customer.lastName
  })

  # Update record
  customer.update({
    synced: true,
    stripeId: stripeCustomer.id
  })
})

Daily Report Generation

Generate and distribute daily reports:

do every('0 9 * * *', async () => {
  # Generate metrics
  const metrics = {
    orders: await db.count($.Order, { createdAt: '>today' }),
    revenue: await db.sum($.Order, 'total', { createdAt: '>today' }),
    newCustomers: await db.count($.Customer, { createdAt: '>today' })
  }

  # Generate report with AI
  const report = await ai.generate({
    prompt: \`Create a daily business report: \${JSON.stringify(metrics)}\`,
    model: 'gpt-5'
  })

  # Send to team
  await api.slack.postMessage({
    channel: '#daily-reports',
    text: report
  })

  await api.sendgrid.sendEmail({
    to: '[email protected]',
    subject: 'Daily Report',
    html: report
  })
})

Batch Data Processing

Process large datasets efficiently:

# Process users in batches
do db.list($.User, { limit: 100 }).forEach(async user => {
  # Calculate user score
  const orders = await db.list($.Order, {
    where: { customerId: user.id }
  })

  const score = orders.reduce((sum, order) => sum + order.total, 0)

  # Update user segment
  const segment = score > 10000 ? 'VIP' :
                  score > 5000 ? 'Regular' :
                  'New'

  await user.update({ segment, lifetimeValue: score })

  # Send personalized email
  await api.sendgrid.sendEmail({
    to: user.email,
    template: \`segment-\${segment.toLowerCase()}\`,
    data: { score, segment }
  })
})

Webhook Event Processing

Process incoming webhook events:

do on($.Webhook.stripe.charge.succeeded, async (event) => {
  # Find order
  const order = await db.get($.Order, event.metadata.orderId)

  # Update status
  await order.update({ paymentStatus: 'paid' })

  # Send receipt
  await api.sendgrid.sendEmail({
    to: order.customer.email,
    template: 'receipt',
    data: { order, charge: event.data }
  })

  # Notify fulfillment
  await send($.Order.readyToShip, { orderId: order.id })
})

Content Generation Pipeline

Generate content at scale with AI:

do db.Products.filter({ description: null }).forEach(async product => {
  # Generate description
  const description = await ai.generate({
    prompt: \`Write a compelling product description for: \${product.name}\`,
    model: 'gpt-5'
  })

  # Generate marketing copy
  const marketing = await ai.generate({
    prompt: \`Write social media posts for: \${product.name}\`,
    model: 'claude-sonnet-4.5'
  })

  # Update product
  await product.update({
    description,
    marketingCopy: marketing
  })

  # Generate product image
  const image = await ai.images.generate({
    prompt: description,
    model: 'dall-e-3'
  })

  await product.update({ imageUrl: image.url })
})

Industry Analysis

Analyze industries using O*NET and NAICS data:

do db.Industries
  .filter({ growth: '>5%' })
  .forEach(async industry => {
    # Get related occupations
    const occupations = await db.Occupations.filter({
      naicsCode: industry.code
    })

    # Analyze with AI
    const analysis = await ai.generate({
      prompt: \`Analyze industry trends and opportunities: \${JSON.stringify({
        industry,
        occupationCount: occupations.length,
        topOccupations: occupations.slice(0, 10)
      })}\`,
      model: 'gpt-5',
      schema: $.IndustryAnalysis
    })

    # Create report
    await $.Report.create({
      type: 'industry-analysis',
      industry: industry.id,
      content: analysis,
      generatedAt: new Date()
    })

    # Share insights
    await api.slack.postMessage({
      channel: '#market-research',
      text: \`New industry analysis: \${industry.name}\`,
      attachments: [{ text: analysis.summary }]
    })
  })

Customer Onboarding Workflow

Automate new customer onboarding:

do on($.Customer.created, async (customer) => {
  # Send welcome email
  await api.sendgrid.sendEmail({
    to: customer.email,
    template: 'welcome',
    data: { name: customer.name }
  })

  # Create onboarding tasks
  const tasks = [
    'Complete profile',
    'Connect integrations',
    'Invite team members',
    'Schedule demo call'
  ]

  for (const task of tasks) {
    await $.Task.create({
      customerId: customer.id,
      title: task,
      status: 'pending'
    })
  }

  # Schedule follow-up
  await every(\`\${Date.now() + 86400000}\`, async () => {
    const completedTasks = await db.count($.Task, {
      customerId: customer.id,
      status: 'completed'
    })

    if (completedTasks < 2) {
      await api.sendgrid.sendEmail({
        to: customer.email,
        template: 'onboarding-reminder'
      })
    }
  })

  # Notify team
  await api.slack.postMessage({
    channel: '#new-customers',
    text: \`New customer: \${customer.name} (\${customer.email})\`
  })
})

A/B Test Analysis

Analyze experiment results and make decisions:

do db.Experiments.filter({ status: 'running' }).forEach(async experiment => {
  # Get variant metrics
  const variants = await Promise.all(
    experiment.variants.map(async variant => {
      const conversions = await db.count($.Conversion, {
        experimentId: experiment.id,
        variant: variant.id
      })

      const impressions = await db.count($.Impression, {
        experimentId: experiment.id,
        variant: variant.id
      })

      return {
        ...variant,
        conversions,
        impressions,
        conversionRate: conversions / impressions
      }
    })
  )

  # Find winner
  const winner = variants.reduce((a, b) =>
    a.conversionRate > b.conversionRate ? a : b
  )

  # Check statistical significance
  const analysis = await ai.generate({
    prompt: \`Analyze A/B test results: \${JSON.stringify(variants)}\`,
    model: 'gpt-5',
    schema: $.ABTestAnalysis
  })

  if (analysis.isSignificant && analysis.confidence > 0.95) {
    # Declare winner
    await experiment.update({
      status: 'completed',
      winner: winner.id
    })

    # Notify team
    await api.slack.postMessage({
      channel: '#growth',
      text: \`Experiment "\${experiment.name}" complete! Winner: \${winner.name} (+\${(winner.conversionRate * 100).toFixed(2)}%)\`
    })
  }
})

Next Steps