Skip to main content

Stage 3 · Seven languages

Code and Code file blocks accept seven language values. Every lesson in this stage builds the same block: it reads trigger.text and publishes it as message. That way you can compare the languages side by side.

Starter workflow

Paste this once, then swap in each lesson’s language and body:

schema: 1
name: Seven languages
id: seven-languages
blocks:
  - id: echo
    name: Echo
    kind: code
    language: python
    uses: [trigger.text]
    input_sample: |-
      {"trigger":{"text":"Hello from curl"}}
    body: |
      # replace with the lesson's source
    outputs:
      type: object
      properties:
        message:
          type: string

Test each one with Open code editor → Execute step.

At a glance

LanguagelanguageRunnerJSON in the standard library?
BashbashbashNo. Use jq
PowerShellpowershellpwsh -NoProfile -NonInteractive -ExecutionPolicy BypassYes (ConvertFrom-Json)
Pythonpythonpython3 -uYes (json)
C#csharpdotnet run snippet.cs (.NET 10+)Yes (System.Text.Json)
Rustrustrustc --edition 2024 -ONo, and there’s no Cargo
JavaScriptjavascriptnode snippet.mjs (ES module)Yes (JSON)
TypeScripttypescriptNode 22.6+ native, or tsxYes (JSON)
Read trigger.text → publish message
set -euo pipefail
jq -ce '{message: .trigger.text}' "$TERMORQ_INPUT"
$data = Get-Content -Raw -LiteralPath $env:TERMORQ_INPUT | ConvertFrom-Json
@{ message = $data.trigger.text } | ConvertTo-Json -Compress
import json, os
data = json.load(open(os.environ["TERMORQ_INPUT"], encoding="utf-8"))
print(json.dumps({"message": data["trigger"]["text"]}))
using System.Text.Json;
using System.Text.Json.Nodes;
using var doc = JsonDocument.Parse(File.ReadAllText(Environment.GetEnvironmentVariable("TERMORQ_INPUT")!));
var text = doc.RootElement.GetProperty("trigger").GetProperty("text").GetString();
Console.WriteLine(new JsonObject { ["message"] = text }.ToJsonString());
use std::{env, fs};
fn main() {
    let input = fs::read(env::var("TERMORQ_INPUT").unwrap()).unwrap();
    println!("{{\"input_bytes\":{}}}", input.len()); // declare input_bytes: number
}
import { readFileSync } from "node:fs";
const data = JSON.parse(readFileSync(process.env.TERMORQ_INPUT, "utf8"));
console.log(JSON.stringify({ message: data.trigger.text }));
import { readFileSync } from "node:fs";
type Input = { trigger: { text: string } };
const data = JSON.parse(readFileSync(process.env.TERMORQ_INPUT!, "utf8")) as Input;
console.log(JSON.stringify({ message: data.trigger.text }));

The short versions above leave out validation. Each lesson shows the production version, which validates its input.

  • Bash

    jq-based JSON handling, strict mode, and returning compact output.

  • PowerShell

    Raw reads, ConvertFrom-Json, and compact ConvertTo-Json output.

  • Python

    Standard-library JSON, stderr diagnostics, and Unicode-safe output.

  • C#

    .NET 10 file-based apps, System.Text.Json, and reflection-free output.

  • Rust

    rustc without Cargo: standard library only, byte-level input, and careful output.

  • JavaScript

    Node.js ES modules, node: built-ins, and JSON.stringify output.

  • TypeScript

    Native Node type stripping, erasable syntax, and runtime validation.