Module 04 · foundations · intermediate
Exercises 04 · Bulletproof Workflows
Exercise 1: Retry a flaky API
Task: First build your own flaky API: a workflow with a Webhook (GET flaky) and a Respond to Webhook whose response code is {{ Math.random() < 0.67 ? 500 : 200 }}. Publish it. It fails about two times out of three. Then build a second workflow with a Manual Trigger and an HTTP Request to http://localhost:5678/webhook/flaky, and make it succeed reliably without code.
Done when: running the second workflow 5 times in a row succeeds every time (check the node's retry count in the execution).
Hint
HTTP Request node → Settings → Retry On Fail. Pick Max Tries and Wait Between Tries. Building the flaky API yourself means the exercise doesn't depend on any outside service.
Exercise 2: Send real alerts
Task: Replace Send Alert (Exercise 2) in the Error Logger with Gmail, Slack or Telegram so a crash notifies you.
Done when: curl -X POST http://localhost:5678/webhook/crash puts the alert in your inbox/channel.
Hint
Send {{ $json.alert }} as the message. The execution URL lets you jump straight to the failure.
Exercise 3: Reuse the sub-workflow
Task: Make a second workflow POST /webhook/average {numbers: [..]} that calls the same Divide sub-workflow to compute sum / count.
Done when: {"numbers":[2,4,9]} returns {"result":5} and {"numbers":[]} returns the 422 error.
Hint
Compute sum and count with expressions ($json.body.numbers.reduce(...)), then map them to the sub-workflow's a and b.
Stretch: One error workflow for everything
Set 04 - Error Logger as the error workflow of every module workflow you've built so far, and add the module name to the alert.