Quick start: your first script
A script is one file with a main function. Waiso calls main, passes it the values from the Inputs card, and shows whatever it returns. In this lesson you write daily-report — it summarises three scores — and run it from the editor.
- Create a script and pick its language
- Write
mainwith an input that has a default - Run it and change the input without touching the code
How a script runs
The editor has three parts that matter today: the code in the middle, the Inputs card beside it, and the panel under the code with Output, Logs and Problems. Waiso reads the parameters of main as you type and turns each one into a field in the Inputs card, typed by its annotation or its default.
1def main(name: str = "world"):2 print(f"saying hello to {name}")3 return {"message": f"Hello, {name}!"}{
"message": "Hello, world!"
}Pressing Run sends the code in the editor and the input values to a worker. It runs exactly what you see — saved or not — so you can try a change before keeping it.
Write and run daily-report
- Create the script
In the
daily-reportproject, open Code, press + New and pick Script. Typedaily-reportas the Script name, choose TypeScript (or any language below) and press Create script. The editor opens with a Hello, World starter. - Replace the starter code
Paste the code below for your language. As you type, the Inputs card grows a
passingfield holding80— the default in the code. - Run it
Press Run (or Ctrl+Enter). The panel shows the run going from queued to running to done, then the result in Output. Press Save (Ctrl+S) to keep the code.
export async function main(passing: number = 80) {
const scores = [85, 92, 78]
const total = scores.length
const average = scores.reduce((sum, s) => sum + s, 0) / total
const passed = scores.filter((s) => s >= passing).length
console.log(`${total} scores, ${passed} passed`)
return { total, average, passed }
}{
"total": 3,
"average": 85,
"passed": 2
}The entry point in each language
| Language | Entry point | Inputs | Result |
|---|---|---|---|
| Python | def main(...) | Parameters with type hints and defaults | return any JSON-able value |
| TypeScript / JavaScript | export async function main(...) | Parameters with types (TS) or defaults | return any JSON-able value |
| C / C++ | int main(int argc, char *argv[]) | // @param name type = default comments, read with waiso_arg_* / waiso::arg* | waiso_set_result(json) / waiso::setResult(json) |
Change the input, not the code
Type 90 in the passing field and run again: passed drops to 1. The same field is what a schedule, a flow step or an API call fills in later — main’s parameters are the script’s public contract. More on types, lists and dates in Script inputs.
When it does not run
- It raises. The Output turns into an error block with the message and the frames of your code; click a frame to jump to its line. See Script errors.
- Run is greyed out. A required input is empty — every parameter without a default must be filled first.
- It stays queued. No worker is online for the project; check Workers.