Your first automationLesson 3 of 8

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.

6 min readBefore this: Create a projectOpen in Waiso
What you will learn
  • Create a script and pick its language
  • Write main with 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.

docs-demoCodehello.pySavePublish
Inputs
Configure the data for this run.
VisualJSON
namestringoptionalworld
hello.py
1def main(name: str = "world"):2    print(f"saying hello to {name}")3    return {"message": f"Hello, {name}!"}
Python 3.15LSP
OutputLogs1SuccessClearRun Ctrl ↵
{
  "message": "Hello, world!"
}
The editor: code in the middle, the Inputs card with one field per parameter of main, and Run at the top.

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

  1. Create the script

    In the daily-report project, open Code, press + New and pick Script. Type daily-report as the Script name, choose TypeScript (or any language below) and press Create script. The editor opens with a Hello, World starter.

  2. Replace the starter code

    Paste the code below for your language. As you type, the Inputs card grows a passing field holding 80 — the default in the code.

  3. 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.

daily-report.ts
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 }
}
Expected outputSuccessOutput of a run with passing = 80
{
  "total": 3,
  "average": 85,
  "passed": 2
}

The entry point in each language

LanguageEntry pointInputsResult
Pythondef main(...)Parameters with type hints and defaultsreturn any JSON-able value
TypeScript / JavaScriptexport async function main(...)Parameters with types (TS) or defaultsreturn 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.
3 / 8