Skip to content

Ask AI in a workflow

fromAi(instructions) asks your deployment’s AI model and brings the answer back as typed columns. It is a line in a formula node’s node file, so the statements after it check and shape the answer like any other data.

The Learn AI generation in workflows catalog has a runnable lesson for each shape below: 01 Classify rows, 02 Extract fields from free text, 03 Summarise a whole table, 04 Check the AI’s answer with a formula, and 05 One row in, many rows out.

eachRow().fromAi(`Classify this support ticket. Return the category that fits best, and how urgent it is.`)
.send("subject", "body")
.returns("category", "text", "billing, access, bug or other")
.returns("urgency", "text", "high or low")
.numRowsToProcess(-1)
  • .send(name, …) names the columns the model sees. Nothing else of the row leaves Fontana, and the instructions carry no row values. .send() with no names sends every column.
  • .returns(name, type, description) declares one answer field as a typed column: text, number, date, boolean, or a list such as list<text>. The description tells the model what belongs there. Every declared field is required, so an answer that leaves one out fails that row.
  • Without .returns, the answer is one text column, ai_answer.

.numRowsToProcess(n) sends the first n rows; -1 sends every row. .offset(n) starts further down.

Without .numRowsToProcess, a workflow run sends no rows: only the test in the node editor does. A new AI node therefore costs nothing until you decide how many rows it may send. Rows outside the page keep empty answer columns.

.oneToMany() turns each item of the answer into a row of its own, with the input row’s columns copied onto it. An answer with no items drops the row.

eachRow().fromAi(`List every product this customer message orders.`)
.send("customer", "message")
.oneToMany()
.returns("product", "text")
.returns("quantity", "number")
.numRowsToProcess(-1)

Without eachRow(), fromAi asks once over the rows it sends. The answer replaces the rows:

fromAi(`These are today's trades. Write a summary of two or three sentences for the head of trading.`)
.send()
.returns("summary", "text")
.returns("trade_count", "number")
.numRowsToProcess(-1)

To keep the rows and hold the answer as one value, put context("name") in front, then read it with context().prop("name"):

context("brief").fromAi(`Write one sentence for the warehouse team about these order lines.`)
.send("customer", "product", "quantity")
.returns("headline", "text")
.numRowsToProcess(-1)
setProp("headline", context().prop("brief").prop("headline"))

inputs("name").fromAi(...) writes the answer to a named table instead.

Long instructions can live in a Workspace file. Read the file’s text into a context value and pass that as the instructions:

context("instructions").fromFile("../instructions/order-lines.md")
eachRow().fromAi(context("instructions"))
.send("customer", "message")
.returns("product", "text")
.numRowsToProcess(-1)
Option Use
.model("<model id>") Uses that model instead of the deployment’s default; see Models
.from(agent("<agent id>")) Runs the call as one of your agents, with its model, settings, and instructions
.kgSearch(true) Lets the call search the Knowledge Graph

An AI answer is data like any other. Check it in the same node or the next one, and raise an exception on a value you cannot accept, so the export after it waits:

if(
not(prop("quantity") > 0),
raiseException("quantity")
.setProp("severityLevel", 3)
.setProp("message", "The quantity is not above zero")
)

See Exception management for severities and tickets.