Skip to main content

Advanced

Folder examples/Advanced. They show what diagrams can do beyond the usual flow. The escalation across e-mail, Telegram and push, also an advanced example, is in E-mail. Notes on the canvas explain the point of each diagram.

Shared Data Source Across a Join​

Advanced examples/Advanced/Shared Data Source Across a Join

A data source that is reserved before a fork survives the join. The first node reads no row; it only reserves the customer file under the data identifier customers (the option Open only). Then the diagram forks: the left path reads the first customer, the right path reads the first product of another file. After the join a node with the same data identifier reads the next customers, 2, 3 and so on, because the reference was copied into both paths. See CSV data, section Advanced.

Needs: the example data (examples/Data/address and examples/Data/eCommerce).

Prompt

Create a diagram that first reserves the customer file examples/Data/address/Fictional addresses.csv under the data identifier "customers" without reading a row (open only). Then fork into two paths: the left path reads the first customer from "customers" and writes first_customer.csv, the right path reads the first product of examples/Data/eCommerce/ECommerce dataset.csv and writes first_product.csv. After the join continue in a loop that reads the next customers from the same identifier "customers" and writes them to other_customers.csv until no row is left. Add notes that explain why the reservation must come before the fork.

Follow a Spreadsheet​

Advanced examples/Advanced/Follow a Spreadsheet

Follows an Excel workbook like tail -f. The diagram reads the sheet New orders of Orders.xlsx; at the end of the sheet it sleeps and wakes when rows are appended, each row exactly once, also after a restart (delivery=once; a safety timer of five minutes rechecks the file). A row with an amount of four or more digits (1000 and more) is mailed to the sales team; every row is logged to the sheet Processed of processed_orders.xlsx. The mail contains the key of the row (${feed.orders.rowKey}), so that a receiver can drop a repeated row. See Excel data and Table data input.

Needs: mail sending (replace sales@example.com); the example workbook examples/Data/orders/Orders.xlsx.

Prompt

Create a diagram that follows the workbook examples/Data/orders/Orders.xlsx, sheet "New orders" (columns OrderId, Customer, Amount): follow=true, delivery=once, recheck PT5M, data identifier "orders". For every new row check whether Amount has four or more digits (edge "large", condition ${Amount} matches '[0-9]{4,}'). A large order is mailed to sales@example.com with the subject "Large order ${OrderId}: ${Customer}" and a text with order id, customer, amount and the row key ${feed.orders.rowKey}. Every row, large or not, is appended to the sheet "Processed" of processed_orders.xlsx. Then read the next row.

Retry and Error Path​

Advanced examples/Advanced/Retry and Error Path

What a diagram does when a step fails. For every new mail a language model summarises the mail in one sentence and the summary is forwarded to the team. The AI step has retry.count=3 and retry.wait=10: a temporary failure (a model that is busy, a network error) enters the node again after 10, 20 and 40 seconds; a wrong setting is never retried. When the failure is final, the edge activity error tells the admin. The mail event has registration.onFailure=fail-early: the diagram does not start at all if the mailbox cannot be reached (the default, retry, starts it and retries in the background).

Needs: a language model; a mailbox (the event) and mail sending; replace team@example.com and admin@example.com.

Prompt

Create a diagram that starts on every new e-mail in the INBOX folder; set the event parameter registration.onFailure to "fail-early" so that the diagram refuses to start without its mailbox. Let the language model summarise the mail in one sentence (temperature 0.2) with the node parameters retry.count 3 and retry.wait 10. Forward the summary to team@example.com with the subject "Summary: ${email.subject}". On the edge "activity error" send an e-mail to admin@example.com that the summary failed after all retries, with the sender and the subject. Both paths end in a final node.

Using a Module​

Advanced examples/Advanced/Using a Module and examples/Advanced/Customer Check

A diagram that calls another diagram like a function. Customer Check is the module: it expects the variable Country and has two exits, accepted (for Germany, Austria and Switzerland) and rejected. Using a Module reads customers, hands over Country to the module (in=Country) and continues on the exit of the module: accepted customers are written to accepted_customers.csv, the others to rejected_customers.csv. Open Customer Check to see the module itself.

Needs: the full edition (module nodes are not available in the community edition, see editions); the example data examples/Data/address/Fictional addresses.csv.

Prompt

Create two diagrams. "Customer Check" is a module: a start, a decision "in DACH" with the condition ${Country} matches 'Germany|Austria|Switzerland' to an end node named "accepted", and "next" to an end node named "rejected". "Using a Module" reads examples/Data/address/Fictional addresses.csv row by row (Forename, Surname, Country), calls the diagram Customer Check as a module with in=Country and continues on the exit: "accepted" appends the person to accepted_customers.csv, "rejected" to rejected_customers.csv. Then read the next row; end when no row is left.

Secrets and Node Tags​

Advanced examples/Advanced/Secrets and Node Tags

A Telegram alert without a credential in the diagram. The bot token comes from the environment of the server: the property secret.telegram = env:WF_TELEGRAM_BOT only names the variable, the value is never saved, logged or shown to the agent, see Secrets. A Python step that rates an order has the tag python-3.12: only a node that offers this tag runs the step, a node without it refuses the run and names the tag, see Signed workflows and node tags.

Needs: Python; a Telegram bot, with its token in the environment variable WF_TELEGRAM_BOT of the server (without it the alert fails with a clear message) and the id of a chat instead of the placeholder 123456789; the full edition for node tags.

Prompt

Create a diagram that alerts a Telegram chat about an order that needs a look. A Python step tagged python-3.12 sets the result to "Order of 1250 needs a look" when the amount (1250) is above 1000, otherwise to "Order of ... is fine". A Telegram message to the chat 123456789 sends the result. Declare the secret telegram in the properties of the diagram as secret.telegram = env:WF_TELEGRAM_BOT, so that the bot token comes from the environment of the server and never appears in the diagram. Add a note for each of the two ideas.