NAL — Nocarta Automation Language
NAL is Ruby. Every line of a script is either an ordinary Ruby statement or one of the commands listed on this page — the ones that open a page, fill a field, read a table, call an API or drive a Windows window. Anything else is refused before the run starts, with the line number and the form that exists.
That is the whole language, and it is worth saying precisely, because it is a promise rather than a family resemblance:
- What NAL accepts behaves exactly as Ruby does.
7 / 2is3.-7 % 2is1."abcdef".slice(1)is"b". If you know Ruby, nothing here will surprise you; if you do not, anything you read about Ruby is true here. - What NAL does not have, it refuses out loud. There are no classes, no
begin/rescue, nolambda, no libraries to require. You get an error naming the thing that exists instead, never a silent difference. - One deliberate exception, written out under “Maps” below:
:nameand"name"are the same key, because a separate Symbol type is the first thing that trips up someone who has never programmed.
Four things shaped it, in this order:
- Anyone who uses a browser and a spreadsheet can learn it. A script reads like plain instructions, with ordinary programming when you need it: variables, conditions, loops, functions. A mistake is reported with its line number before anything runs.
- The same words everywhere. Whether an automation drives a website, runs in your own browser tab, or drives a Windows application, the language is identical. Only the commands that talk to that kind of target change.
- An assistant can write it for you. Claude, ChatGPT or any other MCP client reads this same page, and can create, update and check your automations through Nocarta’s API. If you are that assistant: write Ruby.
- It is Ruby, so the names, the punctuation and the behaviour are all the ones you already know.
If you are looking for how to create an automation, bind a credential or dispatch a run, see Automation. This page covers only the language itself.
The three kinds of automation
All three are written in NAL. Every automation picks one of these when you create it. The kind decides where the script runs and which commands it may use; the language is the same in each.
| Kind | Runs on | NAL, plus |
|---|---|---|
| Desktop | The Nocarta desktop app, driving its own browser | The page commands, js / pw |
| Browser | Your own browser tab, no desktop app needed | Nothing extra: the core language, http and api |
| Windows | The Nocarta desktop app, driving a Windows application | The Windows commands |
The core language below is NAL itself and works in all three, and so do
http requests and api calls. Everything else is listed under the kind it
belongs to. If you use a command your kind does not have, the editor tells you
when you save — it names the command and the kind that does have it, so nothing
surprising happens mid-run.
Core language (every kind of automation)
Comments
A line that starts with # is a comment. After a command, # starts a
comment when it has a space before and after it. # is the only comment marker.
# find the invoice table first
click ".invoices" # then open it
Variables
name = "Maria Silva"
count = 0
count += 1 # also -= *= /=
rows[0] = "first"
totals["march"] = 1200
Some words belong to the language and cannot be used as names: every
statement word (log, ask, validate, output, stuck, finish, if,
for, def, …) and the first word of every command (click, fill, type,
read, list, take, upload, launch, …), in any capitalisation. Writing
type = 1 or for click in rows stops with an error that names the word and
suggests another name, such as type_value. The words are still fine after a
dot or as a key: row.type and {page: 2} work.
record, beats and file are such words too, because they start
record camera, record microphone, beats of and file from data. Name a
recording recording, clip or note instead. A line that starts with one of
them and is written differently, such as record camra, seconds: 10, stops
with an error that shows the right form. After a dot they still work:
instance.fields.file.
location is one of these words too: it is the statement that tells where the
device is (see “Where the device is”). Name a position here, place or
position instead.
Put a value inside text with #{...}, in double quotes:
log "found #{rows.length} rows for #{name}"
Single quotes keep the text exactly as written: '#{name}' is those seven
characters, and so is '{{PORTAL.VALUE}}' — nothing inside single quotes
is ever replaced. To keep a literal #{ or {{ inside double quotes, write
\#{ or \{{.
The last value produced — by a command, an expression or an assignment — is
always _, an ordinary variable:
read table "#grid"
log "rows: #{_.length}"
rows = _
Values
Text, whole numbers, decimals, true, false, nil, lists and maps.
items = ["a", "b", "c"]
person = {name: "Maria", age: 41}
range = 1..10
exact = 1...10 # 1 to 9 — the end is left out
false and nil are false; everything else is true, including 0 and
"". A number and a piece of text never mix silently: "5" + 1 is an error,
"5".to_i + 1 is 6.
Whole numbers and decimals are different kinds of number, as they are in
Ruby. 7 / 2 is 3, because dividing two whole numbers gives a whole number;
7 / 2.0 and 7.fdiv(2) are 3.5. A decimal writes itself with its point, so
5.0 reads as "5.0" — call .to_i or .round before putting one in a form
field.
Maps: {name: "Maria"}, {"name" => "Maria"} and {"name": "Maria"} all
build the same thing, and person[:name], person["name"] and person.name
all read it. This is the one place NAL parts from Ruby on purpose: a map key
is always text, so :name and "name" are the same key. (In Ruby they are
not.) Two consequences worth knowing: a key that is also a method name, like
length, is reachable as person["length"] rather than person.length; and
keys that read as whole numbers come back before the others when you list them.
Conditions
if count > 10
log "plenty"
elsif count > 0
log "a few"
else
log "none"
end
unless paid
log "open invoice"
end
Compare with == != < <= > >= <=>. Combine with &&, ||, ! or
their word forms and, or, not — the words bind more loosely, exactly as
in Ruby:
if total > 0 && !paid
log "open invoice"
end
x || "N/A" gives x, or "N/A" when x is nil or false.
A condition can sit at the end of the line it governs, and if itself has a
value:
log "open invoice" if total > 0
status = if paid
"closed"
else
"open"
end
case picks a branch by value, by range, or by pattern:
case amount
when 0
log "nothing to pay"
when 1..99
log "small"
when /^EUR/
log "already in euros"
else
log "large"
end
Loops
rows.each do |row|
break if row == "stop"
log row
end
rows.each_with_index do |row, i| # with the position
log "#{i}: #{row}"
end
5.times { |n| log n }
for n in 1..5
log n
end
while count < 10
count += 1
end
until done
done = check_something
end
break leaves the loop, next skips to the following item; both take a value
(break row) which becomes the loop’s answer.
A do |row| … end block is how Ruby loops, and it is what an assistant will
write. for exists too and reads more plainly; the only difference is that
for leaves its variable behind after the loop, as Ruby’s does.
Blocks are only ever attached to a method call. You cannot store one in a
variable, so lambda, -> and yield are not part of NAL.
Functions
def full_name(first, last)
"#{first} #{last}"
end
log full_name("Maria", "Silva")
A function gives back the value of its last line; return leaves early. A
function cannot take a block — pass it the values it needs.
Saying things
Two separate channels, and the difference matters:
log "starting the invoice run" # for a person — chat panel and run log
output invoices: rows, total: amount # for the next step — machine-readable
output takes key: value pairs, keys in lower_snake_case. Use it more
than once and the pairs merge; the last value written for a key wins. To hand
instances to the next step of a recipe, emit them as instance_ids.
ask puts a question to the assistant and gives you back its answer:
ask "which of these looks like the invoice total? #{cells}"
answer = _
Add , model: "…" to say which model should answer — the name of one of your
own models, or of one of ours.
The model also reads your last 10 questions to ask in this chat or run, each
with its answer, so a question can follow on from the one before. Nothing else
you ran is sent: not sleep, click, fill or any other command. Add
, history: to change how many earlier questions go with it — a whole number
from 0 to 100, and 0 sends none:
ask "Which button saves the form?", history: 0
A question with , image: (below) is sent with its picture only, so it takes
no history:.
Deciding
ask can also look at a photo of the instance: instance.pages lists the
instance’s page images, and , image: names one.
ask "What is written on the nameplate?", image: instance.pages[0]
tag = _
The question goes to the model that fills fields from an image (your own vision model, if you chose one, else Nocarta’s), and the answer comes back as words. Naming something that is not a page stops the run.
ask gives you words back. decide gives you an answer with a number
attached, from a model built for judging rather than for writing:
d = decide "Is this a refund request?" about notes
if d.answer
log "refund, #{(d.probability * 100).round}% sure"
end
team = decide "Which team should handle this?" about notes among ["billing", "support"]
level = decide "How urgent is it?" about notes levels ["calm", "normal", "urgent"]
Write the question, then about what it is about — text, a map or a list.
With nothing else, the answer is yes or no: d.answer is true or false,
and d.probability is how sure the model is. among gives it a list of names
to pick from; levels gives it an ordered scale to place things on. Those two
answer with d.answer and d.confidence.
Two things can follow, after a comma:
d = decide "Is this a refund?" about notes, threshold: 0.7, model: "Airwalk"
threshold: is where yes begins — 0.5 unless you say otherwise, so a
probability of 0.6 is a yes by default and a no at 0.7. model: names which
of your models answers.
Every answer also carries d.answered_by, which tells you which model actually
answered — so a script can check it was the one you asked for.
A decision model is one of your own, set up in Connections → External LLM/Models → LLM Configurations. It always runs on your own machine through Nocarta Desktop: in a browser automation the question is sent to your desktop and the answer comes back, so your desktop has to be running.
Running a capability
A capability is a question you wrote for a model, on the Capabilities page.
capability asks one of them and gives you the answer back. It writes nothing:
what you do with the answer is up to your script.
A script names your capability by the name shown next to it on the
Capabilities page, after In a script or a recipe: my. and its name in
small letters, with _ between the words. “Seal check” is my.seal_check.
That name stays the same when you rename the capability. A name without my.
is always one of Nocarta’s; written without it, your own capability is not
found, and the run stops with its my. name.
leak = capability "my.seal_check"
cover = capability "my.land_cover", page: 2
capability "my.land_cover", on: other_id, page: 1
capability "my.pressure", media: media_id
p = capability "my.priority", text: email
Without on:, it asks about what the run is for: the run’s instance, or the
media item when the run is on a media item. These can follow, after a comma:
on:— another instance, notebook or media item, by its id.page:— the page to read, by its number (1 is the first page).with_page:— the second page, for a capability that reads two pages (Compare and Locate), by its number.of:— what Count counts, in words, for exampleof: "ticked checkboxes". Only Count takes it.media:— one of the instance’s media items, by its id.text:— a text sent instead of the item’s own text, for a capability that reads text. Withtext:, no item is needed.image:— a picture to read instead of a page, for a capability that reads a picture: an image your script took (shot = take image of "#screen", see Streams and images), or the id of one of your images. Withimage:, no item is needed. An image your script took is sent for this one question and deleted when the answer comes.model:— the model that answers this question only, instead of the one chosen in Settings: the name of one of Nocarta’s models that answers this capability (model: "Kickflip"), or the name you gave one of your own models. A name that does not answer this capability stops the run and lists the ones that do.
What is read depends on what the capability receives: a page, a text, audio or a video. When the item has one, that one is read. When it has several and you did not say which, the run stops and says what to add, for example this notebook has 4 pages; say which one with page:. Any other word after the comma is refused, by name, before the script runs.
Nocarta’s own capabilities run by name too, the names shown on the Capabilities page under Nocarta’s capabilities, written in any of the interface languages. They need no question. Among them: “Text” reads the text of a page, “Image” reads the text of a page with the image model, “Speech” writes down audio speech, and:
- “Describe” says what a page shows, in two to four sentences.
- “Compare” lists what differs between two pages of the instance. The answer has one line per difference, what differs: in page 1 → in page 2, or no difference.
- “Count” counts on one page what
of:names in words, for exampleof: "ticked checkboxes". The answer is a whole number. Withoutof:, the run stops with Count needsof:: what to count, in words (“ticked checkboxes”). When the instance has several pages,page:names the one to read. - “Locate” finds on page 1 the thing page 2 shows. Page 2 is a picture of the
thing. When Locate finds a place, it then checks that this part of page 1
shows the same thing as page 2. The answer is the text
{"box": [x1, y1, x2, y2]}, a box in pixels of page 1, or{"box": null}when the thing is not on page 1 or the check says the place shows something else. - “Translate” translates a text, from English into your language.
from:names the text’s language andto:the language to translate into, by its name, in any of the interface languages:to: "Italian"orto: "italiano". It translates between English, Italian, Portuguese, Spanish, French, German, Chinese, Korean and Japanese. - “Pros and cons” lists the arguments for and against what a text proposes or
describes: two short lists, one headed Pros and one headed Cons, in the
language of the text. It reads the text of the instance or notebook, or the
text
text:gives. - “Say” speaks a text aloud with the voice of the computer that runs the
script, and asks no model: the text stays on that computer.
text:is what to say;language:the language to say it in, by its name, your language unless you name another. The answer comes when the sentence has been said:"on", or"blocked"when the computer keeps the sound off. On a Nocarta Runner nobody hears it: it says nothing, answers"skipped", and the run goes on. When the computer has no voice for that language, the run stops with This computer has no voice for Korean. Say chooses the voice itself.voice:names one of that computer’s voices instead, by the name the computer gives it, likevoice: "Luciana"; the voices differ from one computer to another. On a computer that has no voice of that name, Say chooses the voice itself.
shot = take image of "#screen"
words = capability "Text", image: shot
it = capability "Translate", text: words, to: "Italian"
capability "Say", text: it, language: "Italian"
Compare and Locate read page 1 and page 2. To read two other pages,
name them with page: and with_page:. When the instance has no page 2, the
run stops with this instance has no page 2; it reads page 1 and page 2; name
two other pages with page: and with_page:.
words = capability "Text", page: 1
said = capability "Speech", media: media_id
words = capability "Describe", page: 1
changes = capability "Compare" # page 1 against page 2
changes = capability "Compare", page: 3, with_page: 4
n = capability "Count", page: 1, of: "ticked checkboxes" # how many page 1 shows
where = capability "Locate", page: 1, with_page: 2
Either side of Compare and Locate can be one of your images instead of a page. Upload a picture on the Recordings page and give it a name with Edit name. Then:
with_image:— what to look for: the name of one of your images.image:— where to look: the id of one of your images, or an image your script took.by:— how Locate finds it:"model", the image model (the default), or"pixels", the same pixels at the same size.
Give page: or image: for where to look, not both, and with_page: or
with_image: for what to look for, not both. When none of your images has
that name, the run stops with You have no image named “…”. The box is in
pixels of the page or image looked in.
by: "pixels" does not ask a model. It finds the thing only where it looks
the same as in your image and has the same size: a button shown larger,
smaller or in another colour is not found, and the answer is
{"box": null}.
box = capability "Locate", page: 1, with_image: "Save button"
box = capability "Locate", image: image_id, with_image: "Save button"
box = capability "Locate", page: 1, with_image: "Save button", by: "pixels"
The answer is the model’s text, as the model gave it; nothing checks it.
Write your question so that the answer is one you can use, for example
Answer yes or no. Keep the answer with leak = capability "…": _ holds
it too, but only when there is one.
ask and decide take a question. capability takes the name of a question
you already wrote. To run one you wrote, name it with capability; to ask
something new, use ask or decide.
It works in every kind of automation and needs no API token. Nocarta’s model answers on Nocarta’s servers. Your own model, chosen for the capability in Settings, is called by the window that runs the script; in a browser automation it is called by Nocarta Desktop, which then has to be running. The script waits up to 5 minutes for the answer. These stop the run, with a message: the capability or the item does not exist, the item has several pages or media items and none was named, the model failed, or no answer came within 5 minutes.
Choosing who answers
In a Desktop automation, a capability you wrote and a decide can say who
answers, and in which order, with route::
answer = capability "my.person_check", image: shot, route: ["This Desktop App", "Nocarta Backend"], within: 2
d = decide "Is the cabinet overheating?" about reading.value, route: ["This Desktop App", "Nocarta Backend"], sure: 0.8
In route: |
Who answers |
|---|---|
"This Desktop App" |
the desktop app that runs the script calls your own model itself. The image or the text goes to your model and nowhere else. Choose your model for the capability once, in Settings → Which model answers what; give the capability an image the script took (image:) or a text (text:) |
"Nocarta Backend" |
Nocarta’s models |
"Remote: 6b7344_Truck" |
your model on another of your desktop apps, written with the name the Connections page shows for it |
Each one is asked in turn, and the first answer is the one you get. When none answers, the run stops and says what each one answered.
An answer from This Desktop App costs 1 credit, and nothing on a paid plan. An answer from Nocarta Backend or from another desktop app costs what it costs without a route.
| Option | What it does |
|---|---|
within: 2 |
the seconds each one gets. One that has not answered by then is passed over and the next is asked |
sure: 0.8 |
for decide: how sure an answer must be, from 0 to 1. A less sure answer is kept aside and the next one is asked; if no surer answer comes, you get the surest one kept aside |
check: 0.05 |
also asks the last one in the list about that share of the answers, and counts how often the two agree. It changes no answer |
A decision tells you where it was answered: d.destination.
stats = read route status gives the numbers of the run so far, per capability
(or "decide") and per name in the route: asked, answered, unsure, slow,
failed, first_seconds, median_seconds, slowest_seconds, checked,
agreed, agreement and credits.
After the run. When a run of an automation ends, its numbers are added to
that automation’s page. The Overview tab shows them under Who answered:
for each question and each name in the route, how many answers came in the last
30 days, the average time of an answer, and, when you use check:, how often
the last one in the list gave the same answer. Your desktop app counts these
numbers. No image, text or answer is kept with them.
Was the answer right? Only you know, so you can say it. On the Run screen,
the Routes tab lists the last answers with Right and Wrong. When a
wrong answer was about an image, Nocarta offers to keep that image with your
saved images, so that you can look at it later; it is kept only if you say yes.
A script that learns the truth later, from a door sensor for example, says it
with mark answer seen right or mark answer seen wrong, where seen is the
value the routed capability or decide gave. When two answers of the run are
equal, the newest one not marked yet is marked. The Overview shows, for each
question and each name in the route, how many of the marked answers were right.
The answer’s text is kept with its mark, the newest 50 of each question, so that
Suggest guidance can read it. The mark also keeps the start of what the model
was given: the text of a capability, or the question and options of a
decide. Under a wrong answer, a box asks What was the right answer?: type
it and press Save. It is optional, and it is the clearest thing you can
give Suggest guidance.
Guidance for a question. What is true of one camera is not in the question:
“the red crate by the door is always there”. Write it as guidance. On the Run
screen, the Routes tab has a box under each question of the run; on the
automation’s Overview, the same box is under Guidance for these questions.
Type the guidance (600 characters at most) and press Save guidance. The model
that answers the question reads the guidance after the question, on every call
of this automation, whoever answers: This Desktop App, Nocarta Backend or
another of your desktop apps. Guidance is for your own capabilities (my.…)
and for decide; every decide of the automation shares one box. Save an
empty box to remove the guidance. Never write a password in guidance; guidance
that holds a {{…}} placeholder is not saved. Your guidance is also listed on
What the assistant remembers. The Overview has a box for every
capability "my.…" and decide in the script, with a route: or without one,
and the guidance reaches the model either way. Once you have marked answers
right or wrong, Suggest guidance asks Nocarta’s model to write guidance from
those answers and from the pictures of wrong answers you kept; the text goes
into the box, and it is kept only when you press Save guidance. It needs at least one
wrong answer with its right answer, with the text the model was given, or with a
kept picture: an answer alone does not show what the model gets wrong, so until
then Nocarta asks you to mark more answers or write a right answer.
An example: is your own model good enough to answer first? The script below finds out. It takes ten images from the camera, asks your model on this computer about each one, has Nocarta’s model answer the same ten for comparison, and logs how fast your model was and how often the two agreed.
s = open stream of camera, every: 0.3, size: [320, 240]
n = 0
for shot in s
seen = capability "my.person_check", image: shot, route: ["This Desktop App", "Nocarta Backend"], within: 5, check: 1
n += 1
break if n == 10
end
close stream s
stats = read route status
here = stats["my.person_check"]["This Desktop App"]
log "median #{here.median_seconds} s, agreed on #{here.agreed} of #{here.checked}"
One measurement of that script, as an example only: on a Mac with an M4 Max processor running the model qwen2.5vl:3b on Ollama 0.40.9, ten camera images were answered by This Desktop App in 1.15 seconds each (the middle value; 1.2 at the slowest), with the model already loaded. Nocarta Backend answered the same ten in 0.51 seconds each, and the two agreed on all ten. Your numbers depend on your computer, your model and the size of the image. A model on your own computer is the choice when the images must not leave it, or when there is no connection; it is not always the faster one.
What the script did. It opened the camera and took ten images, one every
0.3 seconds. Each image went first to your own model, through This Desktop
App, and that answer is the one the script received. Because of check: 1,
every image was also sent to Nocarta Backend, only to compare the two answers.
read route status then gave the numbers the last line logs. To use this for
real, remove check: once you trust your model, so the images stay on your
computer, and keep "Nocarta Backend" in the route for the times your model
does not answer within within:.
Recording the camera and the microphone
clip = record camera, seconds: 10
clip = record camera "Logitech", seconds: 5, size: [640, 360], fps: 15, bitrate: 800
note = record microphone, seconds: 30
note = record microphone "USB", seconds: 30, bitrate: 96
log "saved #{clip.kind}, #{clip.seconds} s, #{clip.bytes} bytes"
record camera records the camera’s picture with the microphone’s sound;
record microphone records sound only. Each records for seconds:, saves the
recording as one of your media items (on your Recordings page) and gives you
{id, kind, seconds, bytes}: the item’s id, "video" or "audio", how long
it recorded and its size. They work the same way in every kind of automation:
in a browser automation your Nocarta page records, in a desktop or Windows
automation the desktop app does, in a window of its own. While it records you
see what it records and the seconds left, with Stop and keep (end now and
keep what was recorded) and Cancel (keep nothing; the run stops there).
When the run is for an instance, the recording belongs to that instance.
| Option | What it is | Without it |
|---|---|---|
seconds: |
how long to record, 0.5 to 300. Required | — |
size: [w, h] |
the picture’s size in pixels, at most 1920 by 1080. The picture is scaled to that size. record camera only |
the camera’s own size, made smaller to fit 1280 by 720 |
fps: |
pictures per second, 1 to 30. record camera only |
15 |
bitrate: |
kilobits per second: the picture’s for record camera (100 to 8000), the sound’s for record microphone (16 to 256) |
1000 for the camera, 64 for the microphone |
A camera recording’s sound is always 64 kilobits per second. A smaller size, a
lower fps: and a lower bitrate: make a smaller file: 10 seconds at the
defaults are at most about 1.3 MB. A text after camera or microphone picks the
device whose name contains it; when none does, the run stops and lists the
names of the devices the computer has. A recording larger than your plan’s
media size is refused when it is saved, with the reason.
Your permission. An automation records only when you allowed it, in two
settings on its Settings tab: Let it use the camera and Let it use
the microphone. record camera needs both, because the recording has sound;
record microphone needs the second. When one is off, the run asks you the
first time and saves your answer; a no stops the run at that line. An
automation that runs with nobody watching needs both turned on beforehand. An
app you installed starts with both off. Your browser, or your computer’s
system, may also ask once whether Nocarta may use the camera and the
microphone. A Nocarta Runner has no camera and no microphone: there the run
stops at the line and says so.
To record for longer than 300 seconds, record one clip after another in a loop; each clip is its own media item.
Where the device is
here = location
log "#{here.lat}, #{here.lng}, accurate to #{here.accuracy_m} m"
office = {lat: -23.5505, lng: -46.6333}
validate distance(here, office) < 200
here = location, timeout: 20, precise: true, fresh: true
location gives you where the device that runs the automation is:
{lat, lng, accuracy_m, time} — the latitude and longitude in degrees, how
accurate the reading is in metres, and when the device took it. Write it on its
own line or alone after =, then use the name you gave it:
distance(here, office), not distance(location, office). It works the same
way in every kind of automation.
| Option | What it is | Without it |
|---|---|---|
timeout: |
how many seconds to wait for the device, 1 to 60 | 10 |
precise: |
true asks the device for its most precise reading, which is slower and uses more battery |
false |
fresh: |
true refuses a position the device kept from earlier |
false (a position up to a minute old is fine) |
distance(a, b) gives the distance in metres between two positions, each with
lat and lng.
Your permission. An automation reads your location only when you allowed it, in the setting Let it use my location on its Settings tab. When it is off, the run asks you the first time and saves your answer; a no stops the run at that line. An automation that runs with nobody watching needs it turned on beforehand. An app you installed starts with it off. Your browser, or your computer’s system, may also ask once whether Nocarta may use your location.
When the device cannot tell where it is, the run stops at that line and says
why: the browser did not allow it, no answer came within timeout:, or the
device has no position. The Nocarta desktop app gives no position yet, so in a
desktop or Windows automation the run stops after timeout:. A Nocarta Runner
has no location. A position is what the device says; it is not proof of where
it was.
Showing and asking the person watching
display "Get ready"
display "3", size: "large"
display picture, "This is what I see"
display clip
code = im_stuck "Type the code from your phone", expect_input: true
ok = im_stuck "Continue with the import?"
move = im_stuck "What did you play?", choices: ["Rock", "Paper", "Scissors"]
display shows something in the run’s panel and the run goes on at once:
nobody has to click. Give it one thing or several, separated by commas; they
show top to bottom. A text shows as text, an image the script took (take image of page, take image from cam) as the picture, and a recording from
record camera or record microphone as a player. Each display replaces
what the panel showed before, so three display lines make a countdown.
size: "large" writes the texts large. Anything else — a list, a hash — stops
the run at that line.
im_stuck pauses the run and waits for the person. It asks in the same panel,
under what display showed last, so the person sees the picture while they
answer. With expect_input: true you get what they typed; with choices: the
panel shows one button per choice and you get the text of the one they
clicked; with neither, true when they confirm. Cancelling stops the run,
unless you add fail_on_cancel: false, which gives false instead.
Both work where a person is watching: the assistant chat, the debugger, or a
recipe step someone started by hand. The panel stays open after the run, with
its last display, until the person closes it. Where nobody is watching — a
batch, an unattended run, a browser automation — display shows nothing and
the run goes on, and im_stuck stops the run. A recipe step on a Nocarta
Runner asks its im_stuck question on the run’s page instead, with the same
buttons.
Checking as you go
validate rows.length > 0
If the check comes out false the run stops there and says so. It never quietly carries on — which is the whole point of writing the check.
Finishing, and getting stuck
checkpoint "logged-in" # a named point you can resume from
finish "nothing to invoice today" # end the run early, successfully
stuck "the portal is down for maintenance", category: "external_outage"
on fail message "Could not reach the invoice list"
on stuck restart from checkpoint max 2 with fresh browser
checkpointgoes at the top level of the script, or inside anif. Not inside a loop or a function, and each name is used once.finishends the run as a success.stuckends it as needing help, and the message is what the person reading the run will see.on stuck restartis written once, at the top level.maxis 1 to 5, and you restartfrom start,from checkpointorfrom command.with fresh browsercombines with the first two, in Desktop automations.
Working with values
Methods chain: rows.first.upcase. To work on what a command gives back,
capture it first:
cells = read row 0
log cells.join(", ")
The methods are Ruby’s, with Ruby’s names and Ruby’s behaviour. Every Ruby method on text, whole numbers, decimals, lists, maps and ranges that does not take a block is here, and so are the block ones listed below. Anything else is refused by name.
Text — length size empty? upcase downcase capitalize swapcase
strip lstrip rstrip chomp chop reverse chars lines to_s
to_i to_f split slice sub gsub scan match match? index
rindex include? start_with? end_with? ljust rjust center tr
delete squeeze count partition rpartition succ ord %
each_char each_line
Lists — length size empty? first last reverse flatten
compact uniq sort slice include? index rindex concat join
push pop shift unshift insert delete delete_at min max sum
take drop rotate zip product transpose tally fetch dig
values_at to_a to_h count any? all? none?
— and with a block: each each_with_index each_with_object map select
reject find find_index filter_map flat_map reduce sort_by
min_by max_by group_by partition take_while drop_while each_slice
each_cons uniq sum count any? all? none?
Maps — keys values length size empty? include? key?
has_key? value? key fetch dig merge delete invert to_a
to_h values_at — and with a block: each map select reject find
transform_values transform_keys sort_by sum count any? all?
Numbers — to_s to_i to_f abs ceil floor round truncate
fdiv divmod even? odd? zero? positive? negative? succ pred
gcd lcm digits clamp between? chr — and with a block: times
upto downto step
Ranges — to_a size count first last min max sum include?
cover? exclude_end? — and every list method that takes a block.
The behaviour is Ruby’s, which means:
gsub("a", "b")changes everya;subchanges only the first. Both take a pattern too:gsub(/\d+/, "#").splitwith nothing splits on spaces and drops empty ends:"a b c".splitgives["a", "b", "c"].split(" ", 2)gives at most two parts:"ROSSI MARIO LUIGI".split(" ", 2)is["ROSSI", "MARIO LUIGI"].slice(1)gives ONE item;slice(1, 3)gives three from position one;slice(1..3)does the same."abcdef"[1, 3]is another way to write it.sortneeds a list it can order — one that mixes numbers and text is an error, because neither order is right.compactremovesnilonly.""and0are values and stay.joinwith nothing puts the items straight together;join(", ")separates.concat,push,popand their kind change the list in place, as Ruby’s do.+gives a new one.to_ion text that is not a number is an error, not0. This is the one place NAL refuses something Ruby answers, and it is deliberate: a field reading “N/A” must never quietly count as zero in a total.- Two digits is
rjust(2, "0"):"7".rjust(2, "0")is"07".
Regular expressions are Ruby’s, written between slashes:
if code.match?(/^INV-\d{4}$/)
number = code.match(/\d+/)[0]
end
clean = name.gsub(/[^a-zA-Z0-9 ]/, "")
i ignores case, m lets . match a line break, x lets you space the
pattern out.
Built-in functions
today() # "2026-09-15"
today("dd/MM/yyyy")
now() # "2026-09-15 14:30:00"
weekday(2026, 9, 15) # "TUE" — add a language: weekday(2026, 9, 15, "it")
days_in(2026, 9) # 30
format_date(2026, 9, 15, "EEE dd MMM")
url_encode("Ada & co") # "Ada%20%26%20co" — safe inside a URL
exists(".invoice-table") # true when something on the page matches
distance({lat: 0, lng: 0}, {lat: 0, lng: 1}) # 111194.93 — metres between two positions
Date tokens: yyyy MM dd HH hh mm ss tt EEE.
exists needs a page to look at, so it is available to Desktop
automations.
The data a run is given
A run over a form instance sees that instance as instance; a step in a recipe
sees what the previous step emitted as input. Both are ordinary maps:
fill "#name" with "#{instance.fields.full_name}"
fill "#code" with instance.fields["code_" + day]
open "https://portal.example.com/invoice/#{input.invoice_id}"
Reading a field the run was not given is an error, never a blank — a blank
would let a form be submitted empty while the run reports success. To ask
whether it is there, use || or compare with nil:
phone = instance.fields.phone || "N/A"
Every field of the template is there, filled or not. A field nobody wrote
anything in arrives as "", so you can read it, compare it and fill with it
like any other. What stops the run is a name that is not on the template —
instance.fields.notse for a field called notes is an error naming it, which
is how a typo is caught instead of quietly filling a form with nothing.
instance.fields walks as [name, value] pairs — instance.fields.each do |name, value| — and so do instance.metadata,
instance.instance_id and instance.template_id are also there.
instance.owner_email is the email of the account the instance belongs to. When
you run an automation on entries other people made with your form, it tells you
whose entry each run is for.
Calling other people’s APIs
http makes a request, in every kind of automation:
r = http get "https://api.example.com/items/#{id}"
r = http post "https://api.example.com/cards?list=#{url_encode(list_id)}", {
headers: {"X-Request-Source": "nocarta", Authorization: "Bearer {{TRELLO.VALUE}}"},
body: {name: title, desc: "Card for #{customer}"}
}
r = http put "https://api.example.com/items/#{id}", {body: {name: title}}
r = http patch "https://api.example.com/items/#{id}", {headers: {"If-Match": etag}, body: {name: title}}
r = http delete "https://api.example.com/items/#{id}"
A request is always one line: the method, the address, and — when you need to
say more — one {…} after a comma holding headers: and body:. The {…}
may be spread over several lines, as here. There is nothing else to learn: a
token is an Authorization header like any other, and a query string is part
of the address, written there with url_encode(value) around anything that
could contain a space or an &.
Methods: get post put patch delete.
You get back {status, status_text, headers, body, json}. A 404 or a 500 is
a result you inspect, not a failure — only a request that could not be made
at all stops the run:
r = http get "https://api.example.com/invoices"
if r.status == 200
log "got #{r.json.length} invoices"
else
stuck "The invoice API answered #{r.status}"
end
The body’s kind decides how it is sent: a map or a list goes as JSON, text
goes exactly as you typed it. Write body: {name: title}, never
body: "{\"name\": \"#{title}\"}" — the map is turned into correct JSON for
you, whatever the values contain. A get request has no body.
Requests go only to the hosts listed on the automation’s Settings tab. An empty list reaches nothing.
Your Nocarta data
api reads and writes your own Nocarta data from inside a script, in every
kind of automation. You give it a path, not a full address — the script works
the same wherever it runs, and you never paste a token into it:
instances = api get "/form_instances?form_template_id=#{template_id}"
result = api post "/form_instances/bulk_create", {
body: {form_template_id: template_id, instances: rows}
}
api put "/form_instances/#{id}", {body: {name: "Checked"}}
api patch "/form_instances/#{id}", {body: {name: "Checked"}}
api delete "/form_instances/#{id}"
Same request hash and same result shape as http. The script runs as you, with your
own permissions. api get "/documentation" lists everything it can reach.
Credentials
Never type a password into a script. Bind the credential to the automation and refer to it by name, in capitals:
fill "#password" with "{{PORTAL.VALUE}}"
{{...}} in capitals is the only use of double braces: it means a
credential. The placeholder is what is stored, and what appears in logs. The
real value is put in at the last moment, on the machine running the automation.
The script never contains it and never prints it. See Secrets.
A placeholder is filled in only where you wrote it inside double quotes (or in
js/pw code). Inside single quotes it is plain text, like everything else
there: '{{PORTAL.VALUE}}' reaches the page as those braces. Text that
comes from a page or from an instance field is never filled in either, even if
it happens to look like a placeholder.
Desktop automations: page commands
These drive the browser inside the Nocarta desktop app.
A command can stand alone, or be the whole right-hand side of an assignment:
open "https://example.com/invoices"
rows = read table
Moving around
open "https://example.com"
back
forward
refresh
screenshot
close browser
browser status
Doing things on the page
click "#submit" # a CSS selector
click text "Log in" # whatever carries that text
click "#row-9" holding "Shift" # click with keys held down
hover ".message" # point at it: what shows only on hover appears
fill "#email" with "[email protected]"
fill "Maria Silva" into "the customer name box" # described in words
type "some text" # keystrokes, wherever the focus is
type "Rome" into "#city" # clears the field, then presses each key
select "Italy" from "#country"
press "Enter" # a key name
press "Control+A" in "#notes"
press "Cancel" # not a key name: clicks that button
search and click "the blue download button"
fill … with names the field with a selector; fill … into describes it in
words and lets the assistant find it. fill sets the value at once; type
presses the keys one by one, for a field that reacts to each key (a search box
that suggests as you type). Without into, type presses them wherever the
focus already is.
Key names are the usual ones: Tab Enter Escape Backspace, F1–F24,
the arrows, Home End PageUp PageDown, and chords like Control+A.
click … holding holds keys down for the length of the click — Shift to
extend a selection to the row you click, Control to add one row without
losing the rest. Name several with +, the same way a chord is written:
click "#row-3"
click "#row-9" holding "Shift" # rows 3 to 9
click "#row-12" holding "Control+Shift"
You can hold Shift Control Alt Meta, or ControlOrMeta for the one
that means “the usual shortcut key” on whichever system the automation runs on.
Holding keys works with a selector only — click text "…" finds its element by
reading the page, and that kind of click cannot carry held keys.
hold keeps keys down for everything that follows, until release lets them
go; when the run ends, any key still held is released for you:
hold "Shift"
press "ArrowDown" # three rows selected
press "ArrowDown"
press "ArrowDown"
release "Shift"
Looking at the page
links = list links
links = list links "invoice" # only those matching
matches = find by text "Total"
box = find input near "Customer name"
thing = find "the download button" # described in words
items = find on selected
text = read focus # what is in the focused field
layout = show elements
sel = get selector
ok = wait for "#result" # true once it appears, false after 30 s
ok = wait for "#result", timeout: 10
items = read elements "#list li" # one entry per match
wait for waits until the selector matches and gives back true, or false
after 30 seconds (timeout: sets another number of seconds). read elements
gives back one entry per matching element, in page order, each with text,
label, link, source and the element’s other attributes.
find by text, find … near and find give back nil when nothing matches,
so you can test them:
button = find "the export button"
if button
click button
end
find input near "…" accepts input button select textarea link a
checkbox radio field element.
Tables
rows = read table
rows = read table ".invoices"
row = read row 2
cell = read table cell row 2 col 3
col = find column "Amount" in row 0
fill table row 2 col 3 with "180,00"
switch to table ".invoices"
exit table
Rows are numbered from 0 in the order they appear in the table, every row
included. If the table starts with a header row, that row is row 0 and the first
data row is row 1. Columns start at 0. Every table command counts rows this
way, so in a table that starts with a header row, find column "Amount" in row 0
searches the header row and fill table row 2 col 3 fills the second data row.
Frames, tabs and windows
list iframes
list frames
switch to iframe "#payment"
switch to frame "content"
exit iframe
list pages
switch to page "last"
switch to page "invoices"
switch to page 2
open "https://web.whatsapp.com" in window "whatsapp"
switch to window named "whatsapp"
exit window # back to the run's own window
names = list windows named
close window named "whatsapp"
A named window belongs to its automation: another automation cannot reach it,
and each automation keeps its own logins to outside sites. A named window is
reached by its name, never by a number. It closes when the run ends, or earlier
with close window named; a login made in it stays, so the next run’s window
opens signed in.
Handy
sleep 2 # seconds
highlight ".total" red # red blue green black white orange
clear highlights
Files
photo = take file from "#message img" # the file an image, video, audio or link shows
photos = take files from ".gallery img" # one per match
invoice = take download by clicking "#export", wait: 120
scans = take pages from invoice # a PDF, one PNG image per page
attach photo to "input[type=file]" # fills a file input
r = upload photo to "/notebooks" as "notebook[original_uploaded_image_file]", fields: {"notebook[name]": "Receipt"}
id = save file invoice as "March invoice" # one of your items
f = take file from api "/media_notes/#{id}/download"
A file is {file, name, type, size}; its contents stay in the desktop app.
Files come from a page, from a download or from your Nocarta data — never from
your computer’s disk. upload and take file from api work like api: a path
on Nocarta, your API token, and this Nocarta host in the automation’s allowed
hosts. An image from a stream can be used wherever a file can. take download
waits 90 seconds unless wait: says otherwise, and take pages splits at most
100 pages. A run’s files are deleted when it ends; your plan sets the largest
file and how many files a run holds. upload, save file, take pages and
take file from api also work in Windows automations.
b = beats of song # {bpm, times}: the beats of a sound file
log "#{b.bpm} beats a minute, the first at #{b.times[0]} s"
text = song.data_url # "data:audio/webm;base64,…"
copy = file from data answer as "song.mp3" # a file from a data URL
beats of reads a sound file the desktop app can play and gives bpm, the beats a minute with one decimal (nil when it
finds fewer than two beats), and times, the seconds at which each sound starts.
It reads 600 seconds of sound at most. .data_url gives a file as one text,
data: and its type, then its contents; a service that takes a file as text
takes this. file from data does the opposite: it makes a file from such a text,
with the name you give; text that does not start with data: stops the run at
that line. beats of and .data_url take files of 25 MB at most. All three work
in desktop and Windows automations.
Streams and images
s = open stream of url "https://app.nocarta.ai/play/ydakf", element: "#screen", every: 0.1, size: [384, 216]
for image in s
road = read color at 1, 168 in image
boxes = find color road in image, area: [0, 138, 384, 25], within: 5
ahead = boxes.select { |b| b.left > 80 }.min_by { |b| b.left }
if ahead
play tone 196 + ahead.height * 20, seconds: 0.07
end
end
close stream s
A stream gives you pictures of a page, one element of it, at a steady rate: each picture is an image. Your script reads it with the commands below and decides what to do, for example play a tone for each obstacle that comes towards a game’s player, so the game can be played by ear. The page comes to the front, so your keys reach it.
| Command | What it gives back |
|---|---|
s = open stream of url "https://…", element: "#screen", every: 0.1, size: [w, h] |
a stream of that page, opened in the automated browser. Without element: it streams the whole page. every: is the seconds between images: 0.1 (10 a second) unless you say, 0.034 at the fastest. size: shrinks each image to that many pixels |
s = open stream of camera · open stream of camera "Logitech", every: 0.5, size: [640, 480] |
a stream of this computer’s camera, picture only. Without a name it is the computer’s default camera; with one, the camera whose name contains that text. A small window shows what the camera sees while the stream is open. The automation needs Let it use the camera turned on in its settings; when it is off, the run asks you the first time and saves your answer |
s = open stream of page "#screen", every: 0.1 |
a stream of the page already open |
s = open stream of sensor "mqtts://broker.example:8883", protocol: "mqtt", topic: "line1/#" · open stream of sensor "ws://robot.local:9090", protocol: "rosbridge", topic: "/battery" |
a stream of the readings a sensor, a machine or a robot publishes. protocol: is "mqtt" or "rosbridge" and topic: names what to read. It only reads; it never sends anything to the device. The address’s host must be in the automation’s allowed hosts; when it is not, the run asks you the first time and adds it. user: and password: take a credential bound to the automation, written like "{{BROKER.USERNAME}}" and "{{BROKER.VALUE}}"; a password travels only over an encrypted address (mqtts://, wss://) or to a device on your own network. keep: works as on every stream |
reading = take reading from s · for reading in s |
the oldest reading waiting: topic, value (the message; when it is JSON, read its parts like reading.value.temperature), time (milliseconds) and skipped. It waits for the next one when none waits. A message larger than 1 MB is left out and counted in too_large of read status of s |
saved = save readings from s as "Cabinet alarm" · …, last: 60 |
keeps the stream’s readings as one sensor recording in your media, where you find it under Recordings. Open the stream with remember:, the seconds of readings it keeps for this (at most 600, and 5,000 readings), like remember: 300. Without last: everything remembered is saved; last: 60 saves the last 60 seconds. The answer has saved.name and saved.readings, the number saved. When you already have a recording of that name, the time is added to the new one’s name. Save before close stream |
keys = open stream of run panel · open stream of run panel, keep: 50, moves: true |
the keys you press in the run panel, and where you click or tap on what display shows there, while the run goes on: how an automation reacts to you without stopping, as in a game. The panel says when it is listening. It reads the panel only, never another window or the page the automation drives, and never what you type into an im_stuck question. It works only where someone watches, as display does; anywhere else the run stops at this line. One run at a time can read the panel, and closing the panel closes the stream. keep: is how many readings wait for your script (50 unless you say, at most 200); moves: true also reads the pointer moving |
r = take reading from keys · for r in keys |
the oldest reading waiting. A key: kind is "key", name is the name press uses ("ArrowUp", "Tab", "Escape", "Space", "a"), down is true when pressed and false when let go; a key held down gives one reading, not one per repeat. A click or a tap: kind is "pointer", down, x and y in the pixels of the picture you pressed (nil over a text), part which thing of the last display it was (from 0) and by ("mouse", "touch" or "pen"). Both have time (milliseconds) and skipped |
image = take image from s |
the newest image: image, time (milliseconds), width, height, and skipped, the images your script was too slow to take. nil once the page is closed |
images = take images from s every 0.5 for 3 |
a list of images, one every 0.5 seconds for 3 seconds; without for, for one second |
for image in s … end |
one image each time round, until the page closes or break |
s = open stream of page "#screen", keep: 50, changed: 0.02 |
keep: is how many images wait for your script: 1 unless you say, so a slow script gets the newest one. With more, your script gets them oldest first, and when one more arrives the oldest is dropped. changed: leaves out an image that differs from the last one kept in no more than that share of its pixels (0.02 is 2 in 100); take image then waits until the page changes |
status = read status of s |
how the stream is doing: received (images since it opened), taken (by your script), dropped (removed because too many waited), unchanged (left out by changed:), waiting, and delay, the age in seconds of the oldest image waiting |
close stream s |
nothing |
shot = take image of page / take image of "#screen" |
a screenshot: one image of the page, or of one element of it, as it is now, as sharp as the screen shows it, with no stream. Give it to a capability to read it: capability "Text", image: shot. shot = screenshot is the same as shot = take image of page; in the assistant chat it also shows the image |
read color at x, y in image |
the colour there, like "#e7b008", or nil outside the image |
find color "#e7b008" in image |
the shapes of that colour: each patch of touching pixels, with x, y (its middle), left, right, top, bottom, width, height and pixels. The largest come first, 200 at most |
part = crop image image to x, y, width, height |
that part of the image, as an image |
find images like picture in image |
the matches: the places the picture appears, with x, y, left, top, width, height and score (how many of its pixels match, in percent). The best come first |
find best image like picture in image |
the best match, or nil |
equality image a with b |
the percentage of pixels that are equal in two images of the same size, from 0 to 100 |
photo = take image of instance page 2 |
a page of the instance the run is on, as an image the script holds: for image:, likeness image and find saved images like. Add , on: other_id for another instance you may read. A photo someone sent as evidence is one of the instance’s pages, after the paper sheet |
likeness image a with b |
how alike two images are in what they show, from 0 to 100. A change of light gives a low equality and a high likeness. b can be the name of one of your saved images. Nocarta’s model compares them on the server: the two images go there for that one question and are not kept. When this computer hosts that model itself (Models on your machines, Hugging Face Transformers, the model google/siglip2-base-patch16-224), the images are compared on this computer and do not leave it |
find saved images like shot |
your saved images, and the frames kept on your videos, that show something alike, best first: a list of {name, time, score}, with time in seconds for a video. Options: most: 5 (10 unless you say, 50 at most) and in: "Dock camera" to look in one image or video only |
find saved images for "a red box" |
the same list, for what the words describe. Read the order, not the number: the score of words is low even for a good fit, so it ranks the images and cannot answer yes or no |
changed image from a to b above 0.05 |
true when more than that share of the pixels (0.05 unless you say) differ |
find changes from a to b |
the shapes where two images of the same size differ |
find moving shapes from a to b |
the shapes that moved from one image to the next, each with dx and dy: how many pixels it moved across and down (negative: left or up). What stays in place, such as text that only changes colour, is left out |
find outlines in image |
the shapes found by their edges, for things that are not one flat colour. within: says how sharp an edge must be (10 unless you say) |
n = opencv with image … end |
for people who already know OpenCV: OpenCV.js code that the desktop app runs on your images. Inside, mat(image, "grey") turns an image into an OpenCV image, and an OpenCV image you return comes back as an image |
save image part as "YDAKF logo" |
saves the image as one of your image items, under that name |
play audio "Door bell", volume: 0.5 |
plays one of your audio items, found by its name (record or upload it on the Recordings page). volume: from 0 to 1 (1 unless you say); after: starts it that many seconds later. Answers "on", or "blocked" when the computer keeps the sound off |
play tone 440, seconds: 0.1, wave: "sine", volume: 0.3, after: 0.2 |
"on", or "blocked" when the computer keeps the sound off. wave: is "sine", "square", "sawtooth" or "triangle"; after: starts the tone that many seconds later |
The picture to look for is an image, or the name of one of your image items:
find images like "YDAKF logo" in image. Your image items are on the Recordings
page, where you can see, upload and delete them; a script finds them by name.
Options for the searches: area: [left, top, width, height] looks only there;
within: is how different a colour may be, from 0 (exactly that colour) to 100
(any colour), 10 unless you say, and 2 for equality image; smallest: drops
shapes with fewer pixels; score: is the lowest score a match needs, 90 unless
you say. To count, use .size on what a search gives back: write
reds = find color "#dc2828" in image, then reds.size.
Take colours from the image itself with read color: a screen can show a colour
slightly differently from how the page wrote it. These commands run in the desktop
app, so a loop over images is fast. On the Run screen, turn Live steps off for
a script like this: the screen then shows the run when it pauses or ends, and the
script keeps up with every image. Desktop app only.
When the commands are not enough
js document.querySelectorAll(".row").length
js
const rows = document.querySelectorAll(".row")
return rows.length
end
js with customer, year
return findInvoice(customer, year)
end
pw
await page.getByRole("button", {name: "Export"}).click()
end
js runs JavaScript in the page, pw runs a Playwright instruction. The code
inside is passed through exactly as written — nothing is substituted in
it, so #{...} does not work there, and # is not a comment there either.
To get a script value in, list it after with and use it as an ordinary
variable. A credential placeholder {{ALIAS.FIELD}} is the one thing that
does get filled in.
Nocarta asks you before it runs this code. Nocarta does not check what
js, pw or opencv code does. js can read and change everything on the page
the automation opens. pw and opencv run in the desktop app, with your user’s
access to the files and programs of that computer. When you press Run on a script
that has such code, a dialog shows each piece of code and asks you to confirm it.
It asks again each time the script changes. Until you confirm, a run that starts
where nobody can be asked (a schedule, a Recipe, a Batch, the API) is refused.
Build it for me never writes pw or opencv, and it asks you before the
first run with JavaScript it wrote.
Browser automations
These run inside your own browser tab, and need no desktop app — the only kind
that works on a phone. They use the core language, http and api, exactly as
described above. There are no page commands (there is no automated browser), no
js / pw, and no exists.
r = http get "https://api.example.com/invoices"
validate r.status == 200
api post "/form_instances/bulk_create", {
body: {form_template_id: template_id, instances: r.json.items}
}
Windows automations
These drive a native Windows application through the desktop app. The control names and key notation are those of the Windows UI Automation library the desktop app uses.
Every command has one written form, and the editor checks it when you save: a
missing word is an error that shows the form. A control is written as its
kind, bare, then its name in quotes, then the window it lives in:
button "Save" in "Invoices". Kinds: button, edit, checkbox,
combobox, menu, menu item, tree, tree item, datagrid, tab,
link, radio.
Commands that give you something back. Each names the window it reads from:
title = read title of "Invoices"
text = read text from "Invoices"
value = read value of edit "Name" in "Invoices"
grid = read grid "Invoices"
grid = read grid datagrid in "Invoices"
cell = read grid cell row 0 col 1 "Invoices"
fields = read fields in "Invoices"
ctrls = read controls button in "Invoices"
tree = read tree of "Invoices"
dialog = read dialog
list windows
read controls lists every control of one kind in a window, and read tree
gives you the whole window as the application lays it out: both are how you
find out what things are called before you write the commands that act on
them. read grid cell counts rows and columns from 0.
What you get back: read title, read text, read value of and
read grid cell give text. read grid and read tree give a map you look
inside (grid.headers, grid.cells[0][1], tree.tree); read dialog gives a
map when a dialog is open and false when none is; read fields,
read controls and list windows give a list.
Commands that act:
launch "C:\\Program Files\\App\\app.exe"
launch "notepad.exe" "C:\\notes.txt"
focus window "Invoices"
click button "Save" in "Invoices"
set value of edit "Name" in "Invoices" to "Maria Silva"
type "some text" into "Invoices"
press "Enter" in "Invoices"
select combobox "Country" in "Invoices"
toggle checkbox "Active" in "Invoices"
expand tree item "Edit" in "Invoices"
collapse tree item "Edit" in "Invoices"
invoke button "Refresh" in "Invoices"
focus edit "Name" in "Invoices"
click dialog button "OK"
set clipboard to "text"
wait 500
sleep 2
close window "Invoices"
close app "app.exe"
launch waits for the program’s window — up to 15 seconds — so the next
command can use it straight away; no wait is needed after it.
wait and sleep are not the same unit. wait belongs to the Windows
vocabulary and counts milliseconds, like the rest of it — wait 500 is half
a second. sleep is the core command and counts seconds everywhere in the
language, here included. Writing wait 2 pauses for two milliseconds, which
looks like no pause at all.
These are all the Windows commands there are. Anything else is not a command: the editor refuses it when you save, naming the line.
When something goes wrong
A command that finds nothing fails the step — click "#missing" stops the
run rather than passing silently. That is deliberate: a script that quietly
skips its own work is worse than one that stops. When an element really is
optional, say so:
if exists(".cookie-banner")
click text "Accept"
end
Ruby that NAL does not have
NAL is a subset of Ruby. These are refused by name, with the thing that exists in their place — never silently.
| Ruby | Why not, and what to write |
|---|---|
begin / rescue / ensure / raise / retry |
A run does not catch its own failures. Stop with stuck "…", assert with validate, set the message a person sees with on fail message, and retry with on stuck restart. |
class, module, attr_accessor, self |
A script is statements and defs. |
lambda, ->, proc, yield, &blk |
A block is only ever attached to a method call; it is never a value. Name reusable code with def. |
require |
There are no libraries to load. |
rand, sample, shuffle |
A run has to be repeatable. |
freeze, dup, clone, object_id, class, is_a? |
There is no object identity to work with. |
Date, Time, File, IO, gets |
Use today(), now(), format_date(), and im_stuck to ask a person. |
[1, 2].map with no block, each_slice(2).to_a |
There is no Enumerator: every one of these methods needs its block. |
"abc".to_i, nil.to_i |
Ruby answers 0. NAL stops instead, so a field reading “N/A” never counts as zero. |
"a" << "b" |
Text never changes in place. Write a += "b". |
2 ** -1 |
That is a fraction in Ruby, and NAL has no Rational. Write 1.0 / (2 ** 1). |
x = a and b |
Ruby reads this as (x = a) and b, which is almost never what someone means. Write x = a && b. |
Older NAL spellings
The language used to have its own names for some of these. Each is refused with a message naming the Ruby form.
| Instead of | Write |
|---|---|
set x = 5, preset, runtime, init |
x = 5 |
// a comment |
# a comment |
each x in items, repeat 5 |
for x in items, 5.times do |n| |
x ?? "N/A" |
x || "N/A" |
else if, elseif |
elsif |
"{{name}}", "{{instance.fields.x}}" |
"#{name}", "#{instance.fields.x}" — double braces are for credentials only |
cells.includes("a") |
cells.include?("a") |
s.starts_with("a"), s.ends_with("z") |
s.start_with?("a"), s.end_with?("z") |
s.replace(a, b), s.replace_first(a, b) |
s.gsub(a, b), s.sub(a, b) |
s.pad_left(3, "0"), s.pad_right(3), s.pad_zero |
s.rjust(3, "0"), s.ljust(3), s.rjust(2, "0") |
s.remove_special |
s.gsub(/[^a-zA-Z0-9 ]/, "") |
push items, "a" |
items.push("a") |
name result rows |
rows = read table |
echo "hi", report "hi" |
log "hi" (or Ruby’s puts) |
click if present "#x" |
if exists("#x") … end |
type "Maria" into "#name" |
fill "#name" with "Maria" |
read active, click by text "Go" |
read focus, click text "Go" |
output rows |
output rows: rows |
press Enter |
press "Enter" — a bare word is a variable |
Examples
Walk a site and report what is there
open "https://example.com"
links = list links
log "found #{links.length} links"
screenshot
output link_count: links.length
Fill a form and check it went through
open "https://example.com/contact"
fill "#name" with "Maria Silva"
fill "#email" with "[email protected]"
click text "Send"
if exists(".confirmation")
log "submitted"
else
stuck "No confirmation appeared after sending the form"
end
Log in, then read a table
on stuck restart from checkpoint max 2 with fresh browser
open "https://portal.example.com/login"
fill "#user" with "{{PORTAL.USERNAME}}"
fill "#password" with "{{PORTAL.VALUE}}"
click text "Sign in"
validate exists(".dashboard")
checkpoint "logged-in"
open "https://portal.example.com/invoices"
rows = read table
rows.each do |row|
log row.join(" | ")
end
output invoices: rows
Fill a portal from an instance, one run per instance
open "https://portal.example.com/customers/new"
fill "#name" with "#{instance.fields.full_name}"
fill "#email" with instance.fields.email
fill "#phone" with instance.fields.phone || ""
click text "Save"
validate exists(".saved")
Read your own Nocarta data and post results back
template_id = "your-template-id"
existing = api get "/form_instances?form_template_id=#{template_id}"
log "#{existing.json.length} entries already"
open "https://portal.example.com/invoices"
rows = read table
api post "/form_instances/bulk_create", {
body: {form_template_id: template_id, instances: rows}
}
finish "imported #{rows.length} invoices"
Need More Help?