Authoring Processes
A Process is a serverless function that runs on MACHHUB. You write the function body; the platform handles scheduling, input resolution, execution in an isolated worker, and applying outputs. (Processes are a different feature from Flows, which are Node-RED.)
The model
Section titled “The model”flowchart LR T["Trigger"] --> I["Inputs resolved"] I --> E["execute(context)"] E --> O["Outputs applied"]
A process is defined by:
- Triggers — what causes it to run.
- Inputs — data resolved before your code runs and handed to it.
- Code — your
executebody, in Python or TypeScript. - Outputs — what is done with the result after your code runs.
Triggers
Section titled “Triggers”| Trigger | Runs when… |
|---|---|
cron | a cron schedule fires |
interval | a fixed interval elapses |
tag_change | a subscribed tag changes |
http | an HTTP request hits the process endpoint |
manual | you run it explicitly (console / SDK) |
Inputs and outputs
Section titled “Inputs and outputs”- Inputs:
tag(a tag’s value) orsql(the result of a query). Resolved and passed in ascontext.inputs. - Outputs:
sql(write to the database) ortag_write(publish to a tag). Output templating uses{{output.field}}for SQL and dot-notation for tag writes.
Writing a process
Section titled “Writing a process”TypeScript
Section titled “TypeScript”The SDK is injected as a global sdk — no import, no initialization:
async function execute(context: ProcessContext): Promise<any> { const { inputs, trigger } = context;
const readings = await sdk.collection('myapp.readings').getAll(); const avg = readings.reduce((s, r) => s + r.value, 0) / readings.length;
return { avg };}Python
Section titled “Python”Python processes receive a context dict. (The injected SDK is available in
TypeScript processes; in Python, use SQL inputs/outputs to read and write data.)
def execute(context): inputs = context['inputs'] # ...your logic... return { 'ok': True }Deploying a process
Section titled “Deploying a process”You author and deploy processes with the MACHHUB Designer VS
Code extension, which sends your code to the platform. Each domain gets its own
isolated worker with its own dependencies (pip / npm), and the process version
auto-increments on each deploy.
Invoking a process
Section titled “Invoking a process”From an app, call it through the SDK:
const result = await sdk.processes.execute('computeAverage', { window: '1h' });A process with an HTTP trigger also exposes an endpoint at POST /process/<slug>,
where the JSON body is merged into context.inputs. See
SDK → Processes and the API Reference for the
exact calls.
Logs and packages
Section titled “Logs and packages”- Logs stream while a process runs (handy during development).
- Packages are managed per domain — add the
pip/npmdependencies your code needs.
Related
Section titled “Related”- Concept: Processes & Flows
- SDK: Processes and Advanced (caching, data transforms)