DA5: Code inside the workflow

Lesson 1 of 5 · reading 15–25 minutes; practice and project time is on the module page

When a ready-made step isn't enough

🎯You'll be able to

Decide whether a change needs a ready-made node, an expression or a Code node, and justify the choice.

🏠The everyday picture

A kitchen has a mixer, a grater and a peeler, and most dishes need only those. Now and then a recipe needs something cut in an unusual way, and you pick up a knife. You wouldn't throw away the mixer, and you wouldn't chop everything by hand.

📘What it really is

📝A worked example

Sharma Textiles wants a daily WhatsApp summary for the owner: total orders, total revenue and the top three products.

Approach What it takes Verdict
Ready-made nodes only Aggregate, then Sort, then Limit, then a Set node to build the message, plus a second Aggregate for totals Works, but six nodes for one message
One Code node About 20 lines that total, group, sort and build the text Clearer here
Expression only Can't look across all items Not enough

You keep the trigger, the sheet read and the message send as normal nodes, and use one Code node named "Build daily summary" in the middle.

🌍Where it's used

📝Case scenario

A workflow routes support emails using eleven IF nodes in a row, and nobody can follow it any more. You replace the chain with one Code node that checks keywords from a small table and returns a team field, followed by a single Switch node on team. The workflow shrinks from fourteen nodes to five, and adding a new keyword now means editing one table.

🖱️Try it

Look at your order workflow from DA2. Find one place where three or more nodes do one small job. Write down whether a Code node would be clearer, and why. Don't change it yet.

⚠️Common mistakes

🛠️For your project

The inbox router's classification and Project 3's merge rule are good places for a Code node; most other steps are ready-made nodes.

✅Quick check

Name two signs that a Code node is a better choice than ready-made nodes.

Show the answer

The logic would take a long chain of nodes, or it needs to look across all items at once, such as grouping or comparing.

Why prefer ready-made nodes when they fit?

Show the answer

Other people can read and change them more easily than code.

← BackDA5
ProLearners Assist