Workflow Scenarios

Real-world integration scenarios demonstrating Grove workflows with external services. Each scenario shows the complete workflow, activity, and service declarations needed for a specific integration.

Prerequisites: Workflows, Activities, Services. What you'll learn: How to integrate Grove with common external services.

Payment Processing (Stripe)

Process payments with charge creation, webhook handling, and refund support.

service stripe v1 {
  credentials {
    api_key: "stripe_secret_key"
  }
  auth {
    protocol bearer
    source credentials.api_key
  }
  operation create_charge {
    amount: Int
    currency: String
    customer_id: String
  }
  operation refund {
    charge_id: String
    amount: Int?
  }
}

workflow process_payment v1 {
  node charge = create_charge v1
  node confirm = wait_for_confirmation v1
  edge charge -> confirm
}

Email Notifications (SendGrid)

Send transactional emails as part of workflows.

service sendgrid v1 {
  credentials {
    api_key: "sendgrid_api_key"
  }
  auth {
    protocol bearer
    source credentials.api_key
  }
  operation send_email {
    to: String
    subject: String
    template_id: String
    template_data: Map<String, String>
  }
}

activity send_welcome_email v1 {
  data result {
    fetch sendgrid.send_email {
      to: input.email
      subject: "Welcome!"
      template_id: "welcome-template"
      template_data: { "name": input.name }
    }
  }
  apply(input: EmailInput) -> EmailResult {
    return { message_id: result.id, status: "sent" }
  }
}

SMS Alerts (Twilio)

Send SMS notifications for time-sensitive events.

service twilio v1 {
  credentials {
    account_sid: "twilio_account_sid"
    auth_token: "twilio_auth_token"
  }
  auth {
    protocol basic
    source credentials.account_sid
  }
  operation send_sms {
    to: String
    body: String
  }
}

Repository Events (GitHub)

React to GitHub webhook events to trigger CI/CD workflows.

webhook github "repo-events" {
  secret: "github_webhook_secret"
  on push -> ci.trigger_build
  on pull_request.opened -> ci.run_checks
  on release.published -> deploy.start_deployment
}

Data Sync (REST API)

Periodic sync from an external REST API.

schedule hourly_sync {
  when "0 * * * *"
  start sync_products v1 {}
}

workflow sync_products v1 {
  node fetch = fetch_products v1
  node upsert = upsert_products v1
  edge fetch -> upsert
}

Multi-Step Onboarding

Customer onboarding with identity verification, account setup, and welcome email.

workflow onboard_customer v1 {
  node verify = verify_identity v1
  node create_account = create_account v1
  node setup_billing = setup_billing v1
  node welcome = send_welcome v1

  edge verify -> create_account
  edge create_account -> setup_billing
  edge create_account -> welcome

  on compensated -> OnboardingResult {
    return {
      customer_id: input.customer_id,
      status: "failed",
      reason: compensation.reason
    }
  }
}

See Also