# Change Flow Engine (`rustic_soybean/change-flow-engine`) Actor

- **URL**: https://apify.com/rustic_soybean/change-flow-engine.md
- **Developed by:** [Chris Johnson](https://apify.com/rustic_soybean) (community)
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## ChangeFlow — Apify CrewAI engine (private staging)

**Status: Staged source, NOT deployed, NOT a paid product, NOT connected to the live app.**

This is a **compatible reconstruction** of the hosted contractor change-order workflow, not an export or verified line-for-line copy of its private CrewAI Studio configuration. The reference endpoint remains `https://contractor-change-order-flow-9a19a395-48c2--062940c2.crewai.com`.

### Why it exists

The existing CrewAI Basic hosting allotment is shared across users and capped at 50 executions/month. This private Python Actor shifts workflow orchestration to Apify, where consumption can scale with usage *subject to account credits, billing and quotas*. **Apify execution, model calls and storage may cost money**; this code does not make the workflow free or guarantee profit. The model is accessed through Apify's documented OpenRouter proxy and its injected `APIFY_TOKEN`; there are no embedded credentials.

### Inputs

The six current ChangeFlow fields are `customer`, `job`, `contract_total`, `notes`, `exclusions`, `tax_rate_percent`. The optional `quoted_change_amount` is a contractor-supplied quote (positive for additions, negative for credits). Prices are strictly validated and calculated with decimal arithmetic, not written by the model. Each model completion is also constrained to 1,400 output tokens and agents to at most two iterations each; an Apify runtime/spend limit must still be set before a paid run.

Output dataset item: `{ "result": { ...draft... }, "execution": { "engine": "crewai_on_apify", "model": "...", "usage_metrics": ... } }`.

**The Actor only prepares a draft.** It never marks a customer-approved change, issues an invoice, or records a billable change. That stays in the existing application after verifiable customer acceptance. A human must check job-specific scope and legal requirements.

### Verification, offline

Install test dependency `pydantic>=2.11,<3.0` then run:

```bash
python -m unittest discover -s tests -v
python -m compileall -q src
```

### Before enabling production

1. Compare 3–5 identical representative requests against the original hosted workflow, review omissions and hallucinations, and reconcile with the original exported CrewAI configuration when available.
2. Deploy as a **private** Apify Actor and run **one explicitly authorized, capped-cost test**, confirming balance, token/model charges, Actor compute and storage costs, response schema, and latency.
3. Calculate actual cost per successful order, including retries, billing fees, support burden and monthly baseline. Set both a safe overall spend ceiling and per-customer limits **before** enabling Stripe checkout.
4. Add a server-side Apify dispatcher/poller and a controlled feature flag to ChangeFlow. Preserve the currently connected CrewAI API as a fallback; do not expose Apify tokens to browsers.
5. Verify job-selection, voice notes, consent/approval evidence, accepted-change ledger, exports and subscription enforcement end to end; verify user separation and idempotency.

Do not publish an Apify Store listing or set up Stripe subscriptions merely because this source exists. No purchases, Apify plan upgrades or charges have been authorized by this stage.

# Actor input Schema

## `customer` (type: `string`):

Customer or client name exactly as it should appear on the draft change order.

## `job` (type: `string`):

Job number and project name, such as J-001 Kitchen Renovation.

## `contract_total` (type: `string`):

Original contract amount in USD; enter digits with up to two decimal places, without commas.

## `notes` (type: `string`):

Contractor field notes describing the requested change; include verified scope, quantities, and unknowns.

## `exclusions` (type: `string`):

Work explicitly excluded from this proposed change order. Optional.

## `tax_rate_percent` (type: `string`):

Reference percentage between 0 and 100, such as 6.625; tax is not calculated automatically.

## `quoted_change_amount` (type: `string`):

Optional contractor-supplied price adjustment in USD. Use a negative number for a credit; the AI will not invent one.

## Actor input object example

```json
{
  "exclusions": "",
  "tax_rate_percent": "0"
}
```

# Actor output Schema

## `results` (type: `string`):

URL of the dataset items. A successful run writes one item with the draft change order and execution metadata.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("rustic_soybean/change-flow-engine").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("rustic_soybean/change-flow-engine").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call rustic_soybean/change-flow-engine --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rustic_soybean/change-flow-engine"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ROzDMHH8XKZC72j7e/builds/Blu7TqYzSsneyzT6d/openapi.json
