Laya package – overview and setup

The Aeovi.Laya package brings fast, local AI decisions into your Robomotion flows. It talks to Laya, a small AI model that is built for deciding, not for writing. Laya never invents text. It only spreads probabilities over the answers you give it. That makes it predictable, cheap and very fast: a request with several decisions usually takes 20–40 ms on a graphics card.

Typical uses

  • Routing e-mails and tickets to the right team
  • Spotting refund or cancellation requests
  • Detecting phishing
  • Rating urgency or sentiment
  • Pre-sorting documents before a human looks at them

The four nodes at a glance

NodeQuestion typeAnswer from LayaUse it when …
NoulYes or nonoul: probability of “yes” from 0 to 1, plus route = yes no unsureyou need a yes/no answer and want to branch on it. Example: “Does the customer ask for a refund?”
ChoicePick exactly one of several choiceschoice: the picked choice, plus the probability of every choicethe answers are different things without an order. Example: which department, which topic, which product.
ScoreRate on an ordered scalescore: a number between the first and the last level, plus the probability of every levelthe answers go from “little” to “a lot”. Example: urgency, anger, satisfaction, risk.
AdvancedMany questions of all three types at onceLaya’s full answer with one entry per questionyou ask several things about the same text. Five questions cost hardly more time than one.

All four nodes also work in batch mode: you pass many records (for example 1,000 e-mails) and every record gets the same question(s). See Batch mode.

Setup

What you need

  1. A running Laya server. Laya runs on your own machine or server. Nothing is sent to a cloud service.
  2. The Aeovi.Laya package in your Robomotion workspace.
  3. A robot that can reach the Laya server over the network (by default on the same machine).

Step 1 – Install and start the Laya server

Install Laya as described in the Laya repository. Then start the HTTP server. To understand German and other languages as well as English, load both models.

Windows (PowerShell)

$env:LAYA_MODELS = "english,multilingual"
laya-serve

Linux / macOS

LAYA_MODELS=english,multilingual laya-serve

By default the server listens on port 8000. Check that it runs by opening this address in a browser:

http://127.0.0.1:8000/health

You should see "status":"ok" and the loaded models.

  • Graphics card: with a CUDA graphics card a decision takes a few milliseconds. On a CPU Laya still works but needs roughly 0.2–0.5 s per request.
  • First request: the very first request after starting the server takes about half a second longer while the model warms up.

Optional API key: if you start the server with the environment variable LAYA_API_KEY, every request must send this key. Store it in a Robomotion vault and select it in the node option API Key (optional).

Step 2 – Add the package to your flow

Open your flow in the Designer, search for Laya in the package panel and drag one of the nodes onto the canvas. The package is added to the flow’s dependencies automatically.

Step 3 – Your first decision

  1. Add an Inject node and a Function node with this code:
    msg.text = "You charged my invoice twice, I want my money back!";
    return msg;
  2. Connect a Noul node. Keep the default question “Does the customer ask for a refund?”.
  3. Connect a Debug node and run the flow.
  4. In the debug output you see msg.laya.noul (about 0.9) and msg.laya.route = yes.

📷 Image placeholder: Screenshot of the canvas with Inject → Function → Noul → Debug, and the debug panel showing msg.laya with noul and route.

Settings that every node has

SettingDefaultWhat it does
Text (input)msg.textWhat Laya looks at. A plain text or a whole object, for example an e-mail with subject and body.
Result (output)msg.layaWhere the answer is written. Choose another name, for example msg.refund, when you use several Laya nodes in a row.
BatchoffOn: Text holds many records. See Batch mode.
ModelAutoAuto lets Laya pick the model by the language of the text. Choose english or multilingual only if you know the language in advance.
Server URLhttp://127.0.0.1:8000Address of the Laya server. Must start with http:// or https://. localhost is replaced by 127.0.0.1 automatically because that is a little faster on Windows.
API Key (optional)emptyOnly needed if the Laya server was started with LAYA_API_KEY. Select the vault item that holds the key.
Timeout (sec)30Maximum time the node waits for Laya. After that it fails with an error.

Every input field can be filled from Custom (fixed value), Message (msg.…) or JS (a JavaScript expression), like in the standard Robomotion nodes.

  • Do not force english for German texts. In our tests the answers became clearly wrong. Keep Auto if in doubt.
  • Laya only reads text. Convert PDFs, Word files or scans to text first.

Reading the result

The nodes write Laya’s answer unchanged into Result. Field names are Laya’s own names. Only the Noul node adds one extra field, route, to make branching easy. Fields you will meet in every answer:

FieldMeaning
typenoul, choice or score
answer_confidenceHow sure Laya is about the answer it gives, from 0 to 1. This is the number to use for thresholds.
confidenceA second, uncalibrated measure. Laya itself recommends not to use it for thresholds.
actionInternal value of Laya’s decision model. Not needed in flows.
modelName of Laya’s engine, for example laya-rl-agent.
routing.modelWhich model answered: english or multilingual. routing.detection.language shows the detected language.
usage.truncatedtrue if the text was too long and Laya cut off the end. Then the decision is based on the beginning of the text only.
low_confidenceOnly present when you set Min Confidence and the answer is below it.

To branch, use a standard Switch node after the Laya node, for example:

msg.laya.route == "yes" // Noul
msg.laya.choice == "Billing" // Choice

Batch mode

Turn on Batch when you have many records and want to ask every record the same question(s). Instead of a loop that calls Laya once per record, the node sends up to 64 records per request. With 1,000 e-mails and 7 questions each, our demo flow went from 45 ms to 17 ms per e-mail.

In batch mode, Text must be one of these:

A list of records – the result is a list in the same order (msg.laya[0], msg.laya[1] …):

msg.text = ["first text", "second text"];

An object with IDs – the result has the same IDs (msg.laya.T1, msg.laya.T2 …). This is the easiest way to match answers back to your records:

msg.text = {
"T1": { "subject": "…", "body": "…" },
"T2": { "subject": "…", "body": "…" }
};

Every entry in Result looks exactly like the result without batch mode. More than 64 records are split into several requests automatically. Empty records are rejected with an error that names the record.

Limitation: Laya’s batch interface does not support min_confidence. If Min Confidence is filled in while Batch is on, the node stops with an error. Compare answer_confidence yourself instead.

Good questions, good results

  • Ask one thing per question. “Does the customer ask for a refund?” works better than “Is the customer angry and wants a refund?”.
  • Avoid negations. Ask “Does the customer want to cancel?” rather than “Does the customer not want to stay?”.
  • Describe the choices. In Choice, a short description per choice (“invoices and payments”) improves accuracy noticeably.
  • Only send what matters. Extra fields like IDs, headers or signatures distract Laya. In a test, a refund request dropped from 0.89 to 0.67 when the e-mail was wrapped in a large object with headers and CRM data.
  • Test thresholds with your own data. Laya’s confidence values are optimistic out of the box. Run 50–100 real examples and look where wrong answers start.
  • Keep the number of choices small. Above about 20 choices accuracy drops. Split into two steps (department first, then topic).

Limits

WhatLimit
Text lengthAbout 1,000 tokens (1–2 pages) are read. Longer texts are cut and usage.truncated is true.
Input typeText or JSON only. No images, no files.
Choices per Choice question2 to 100 (accuracy drops above about 20)
Levels per Score question2 to 32
Questions per request (Advanced)64
Records per batch request64 (the node splits larger batches)

Errors that all nodes can report

MessageCause and fix
Laya server at … is not reachable. Is laya-serve running?The server is not started, runs on another port or a firewall blocks it. Open /health in a browser on the robot machine.
Laya did not answer within … Increase Timeout or check the serverThe server is overloaded or very slow (for example on CPU with long texts). Raise Timeout (sec) or check the server.
Laya rejected the API key (401)The server expects a key and none or a wrong one was sent. Check the vault item in API Key (optional).
Laya is busy (503). Try again laterThe server has too many requests at the same time.
Laya reported error …Laya rejected the request, for example because of too many choices. The message contains Laya’s reason.
Server URL must start with http:// or https://Fix the Server URL option.
Text is empty. Please pass a text or an objectThe field selected in Text does not exist or is empty. Check the variable name, for example msg.text vs. msg.body.
Batch: Text must be a list of records or an object with one record per IDBatch is on but Text is a single text. Turn off Batch or pass a list/object.
Min Confidence is not supported by Laya in batch modeClear Min Confidence or turn off Batch.

A failing Laya node stops the flow like any other node. To continue anyway, add a Catch node or enable Continue On Error in the node’s common settings.

Next steps


Was this article helpful?
© 2026 Robomotion Help by aeovi.com