Session 4 / 15๐Ÿ”Žืขื‘

How to work with the challenges

The challenges here are harder than the practice tasks, and are meant for those who finished and want to go deeper. Try on your own for at least 20 minutes before opening the hints, and the solution only after that. There is no single right solution: if your scenario meets the requirements, it is right.

Broken scenario โ€” find the bug

This is what real work looks like: something broke, and all you have is the History. Read the error, and pick the right fix.

Advanced: An endpoint for fetching a lead

๐Ÿ”ฅ Advancedโฑ๏ธ ~40 min

๐ŸŽฌ The scenario

Add a second API: GET with a leadId returns the lead's details.

๐ŸŽฏ The requirements

  1. Save leads (data store) in the first API.
  2. A GET webhook with ?id=โ€ฆ
  3. 404 when not found.

๐ŸŽฏ The desired result โ€” how the scenario should look and work

Click Run once and then each module: you will see its settings, and on the last module โ€” the output you should get.

๐Ÿ“ค Example of the final output
{
  "status": 200,
  "body": {
    "id": "L-042",
    "email": "dana@acme.co.il"
  }
}

๐ŸŽฌ Stuck? To the guided solution with a click simulation โ†’

๐Ÿ’ก Hints (try without them first)
  • Data store โ†’ Get a record by key = leadId.
  • Filter: Exists on a field of the record.
  1. In the existing API: Data store โ†’ Add/replace a record (key: leadId).
  2. A new webhook: GET โ†’ Data store Get a record (key: {{1.id}}).
  3. Router: Exists โ†’ Response 200 with Create JSON; fallback โ†’ 404.

๐ŸŽฌ The guided solution โ€” a click simulation

๐Ÿ“ธ The illustrated guide โ€” step by step, click by click

For every step: a screenshot of the (simulated) Make editor with the click spot marked, and below it exactly what to click and what to type. You can work from here next to an open Make window.

  1. 1
    Save leads in the existing API
    In the session's API: Data store โ†’ Add/replace a record with key = leadId.
    Marked screenshot โ€” step 1: Save leads in the existing API
    ๐Ÿ“ธ Step 1 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Data store and click the Data store app.
    3. In the list of actions choose Add/replace a record.
    4. In the Data store field type: leads
    5. In the Key field map (drag from the panel or type): {{leadId}}
    6. In the email field map (drag from the panel or type): {{1.email}}
    7. In the name field map (drag from the panel or type): {{1.name}}
    8. Click OK (or Save) to close the module window.
  2. 2
    A new GET webhook
    A new scenario with a webhook that receives ?id=โ€ฆ
    Marked screenshot โ€” step 2: A new GET webhook
    ๐Ÿ“ธ Step 2.1 โ€” the red ring marks where to click
    Marked screenshot โ€” step 2: A new GET webhook
    ๐Ÿ“ธ Step 2.2 โ€” the red ring marks where to click
    1. In the left menu click Scenarios โ†’ + Create a new scenario.
    2. Click the scenario name at the top left (New scenario) and type: C04 - Get lead.
    3. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    4. In the search box type Webhooks and click the Webhooks app.
    5. In the list of actions choose Custom webhook.
    6. In the Webhook field type: get-lead
    7. In the Get request headers field choose: No
    8. Click OK (or Save) to close the module window.
  3. 3
    Read from the data store
    Get a record with key = {{1.id}}.
    Marked screenshot โ€” step 3: Read from the data store
    ๐Ÿ“ธ Step 3 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Data store and click the Data store app.
    3. In the list of actions choose Get a record.
    4. In the Data store field type: leads
    5. In the Key field map (drag from the panel or type): {{1.id}}
    6. Click OK (or Save) to close the module window.
  4. 4
    Router: found โ†’ 200, else โ†’ 404
    Two webhook responses by whether the record exists.
    Marked screenshot โ€” step 4: Router: found โ†’ 200, else โ†’ 404
    ๐Ÿ“ธ Step 4.1 โ€” the red ring marks where to click
    Marked screenshot โ€” step 4: Router: found โ†’ 200, else โ†’ 404
    ๐Ÿ“ธ Step 4.2 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Flow Control and click the Flow Control app.
    3. In the list of actions choose Router.
    4. Keep the defaults.
    5. Click OK (or Save) to close the module window.
    6. Click the small + coming out of the Router (to its right) to open a new route.
    7. In the search box type Webhooks and click the Webhooks app.
    8. In the list of actions choose Webhook response.
    9. In the Status field type: 200
    10. In the Body field map (drag from the panel or type): {"id":"{{1.id}}","email":"{{2.email}}","name":"{{2.name}}"}
    11. Click OK (or Save) to close the module window.
    12. Click the ๐Ÿ”ง icon on the line between the last two modules โ†’ Set up a filter.
    13. In the Label field type: Found.
    14. In Condition set: 2.email Exists (pick the field from the panel, the operator from the list, and type a value).
    15. Click OK โ€” a funnel icon appears on the line.
    16. Click the small + coming out of the Router (to its right) to open a new route.
    17. In the search box type Webhooks and click the Webhooks app.
    18. In the list of actions choose Webhook response.
    19. In the Status field type: 404
    20. In the Body field type: {"error":"not found"}
    21. Click OK (or Save) to close the module window.
    22. Click the ๐Ÿ”ง on the line of the last route โ†’ Set up a filter.
    23. Type Fallback as the Label, and tick Fallback route: Yes.
    24. Click OK โ€” this route runs only when no other route matched.
  5. 5
    Test in the browser
    Open the webhook URL with an existing and a non-existing ?id=.
    Marked screenshot โ€” step 5: Test in the browser
    ๐Ÿ“ธ Step 5 โ€” the red ring marks where to click
    1. Click โ–ถ Run once at the bottom left.
    2. When the run ends, bubbles with numbers appear above the modules. Click the bubble of the last module and check the Output.
    3. The output should look roughly like this:
      {
       "status": 200,
       "body": {
        "id": "L-042",
        "email": "dana@acme.co.il"
       }
      }

Experts: Receiving a batch

๐Ÿ”ฅ๐Ÿ”ฅ Expertsโฑ๏ธ ~50 min

๐ŸŽฌ The scenario

A system sends an array of 50 leads in one request.

๐ŸŽฏ The requirements

  1. Receive an array in the body.
  2. Process each lead.
  3. One response with how many succeeded and how many failed.

๐ŸŽฏ The desired result โ€” how the scenario should look and work

Click Run once and then each module: you will see its settings, and on the last module โ€” the output you should get.

๐Ÿ“ค Example of the final output
{
  "ok": 47,
  "failed": 3
}

๐ŸŽฌ Stuck? To the guided solution with a click simulation โ†’

๐Ÿ’ก Hints (try without them first)
  • An Iterator over the array, then a Numeric aggregator / Array aggregator.
  • Webhook response after the aggregator.

Webhook โ†’ Iterator (Array: leads) โ†’ validation as Set variable valid โ†’ Array aggregator (Source: Iterator) โ†’ Set variables: ok = length(filterโ€ฆ) or two Numeric aggregators with a filter โ†’ Response 200 with the summary. (Iterator and aggregator โ€” in session 6.)

๐ŸŽฌ The guided solution โ€” a click simulation

๐Ÿ“ธ The illustrated guide โ€” step by step, click by click

For every step: a screenshot of the (simulated) Make editor with the click spot marked, and below it exactly what to click and what to type. You can work from here next to an open Make window.

  1. 1
    A webhook that receives an array
    Send a sample with leads: [...] so Make learns the structure.
    Marked screenshot โ€” step 1: A webhook that receives an array
    ๐Ÿ“ธ Step 1.1 โ€” the red ring marks where to click
    Marked screenshot โ€” step 1: A webhook that receives an array
    ๐Ÿ“ธ Step 1.2 โ€” the red ring marks where to click
    1. In the left menu click Scenarios โ†’ + Create a new scenario.
    2. Click the scenario name at the top left (New scenario) and type: C04 - Batch.
    3. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    4. In the search box type Webhooks and click the Webhooks app.
    5. In the list of actions choose Custom webhook.
    6. In the Webhook field type: leads-batch
    7. Click OK (or Save) to close the module window.
  2. 2
    An Iterator over the leads
    Array: {{1.leads}}.
    Marked screenshot โ€” step 2: An Iterator over the leads
    ๐Ÿ“ธ Step 2 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Flow Control and click the Flow Control app.
    3. In the list of actions choose Iterator.
    4. In the Array field map (drag from the panel or type): {{1.leads}}
    5. Click OK (or Save) to close the module window.
  3. 3
    Validate each lead
    valid = true if the email has @ and a dot.
    Marked screenshot โ€” step 3: Validate each lead
    ๐Ÿ“ธ Step 3 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Tools and click the Tools app.
    3. In the list of actions choose Set variable.
    4. In the Variable name field type: valid
    5. In the Variable value field map (drag from the panel or type): {{contains(2.email; "@") and contains(2.email; ".")}}
    6. Click OK (or Save) to close the module window.
  4. 4
    Aggregate and count
    Array aggregator (Source: Iterator) and then count succeeded/failed.
    Marked screenshot โ€” step 4: Aggregate and count
    ๐Ÿ“ธ Step 4.1 โ€” the red ring marks where to click
    Marked screenshot โ€” step 4: Aggregate and count
    ๐Ÿ“ธ Step 4.2 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Flow Control and click the Flow Control app.
    3. In the list of actions choose Array aggregator.
    4. In the Source Module field type: Flow Control - Iterator [2]
    5. Click OK (or Save) to close the module window.
    6. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    7. In the search box type Tools and click the Tools app.
    8. In the list of actions choose Set multiple variables.
    9. In the ok field map (drag from the panel or type): {{length(map(4.array; "valid"; "valid"; true))}}
    10. In the failed field map (drag from the panel or type): {{length(4.array) - ok}}
    11. Click OK (or Save) to close the module window.
  5. 5
    One response with the summary
    Webhook response 200 with ok and failed.
    Marked screenshot โ€” step 5: One response with the summary
    ๐Ÿ“ธ Step 5.1 โ€” the red ring marks where to click
    Marked screenshot โ€” step 5: One response with the summary
    ๐Ÿ“ธ Step 5.2 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Webhooks and click the Webhooks app.
    3. In the list of actions choose Webhook response.
    4. In the Status field type: 200
    5. In the Body field map (drag from the panel or type): {"ok":{{5.ok}},"failed":{{5.failed}}}
    6. Click OK (or Save) to close the module window.
    7. Click โ–ถ Run once at the bottom left.
    8. When the run ends, bubbles with numbers appear above the modules. Click the bubble of the last module and check the Output.
    9. The output should look roughly like this:
      {
       "ok": 47,
       "failed": 3
      }

Boss challenge: A Stripe webhook with signature verification

๐Ÿ‘‘ Boss challengeโฑ๏ธ ~60 min

๐ŸŽฌ The scenario

Receive a payment event from Stripe and verify it really came from Stripe.

๐ŸŽฏ The requirements

  1. JSON pass-through to receive the raw body.
  2. Compute HMAC SHA256 per Stripe's docs.
  3. 401 if it doesn't match.

๐ŸŽฏ The desired result โ€” how the scenario should look and work

Click Run once and then each module: you will see its settings, and on the last module โ€” the output you should get.

๐Ÿ“ค Example of the final output
{
  "type": "payment_intent.succeeded",
  "verified": true
}

๐ŸŽฌ Stuck? To the guided solution with a click simulation โ†’

๐Ÿ’ก Hints (try without them first)
  • The signature is in the stripe-signature header: t=โ€ฆ,v1=โ€ฆ.
  • The string to sign: t + "." + raw body.

A webhook with JSON pass-through + headers โ†’ Set variables: t and v1 from the header (split) โ†’ sha256(t + "." + 1.value; "hex"; secret) โ†’ Filter: equals v1 โ†’ Parse JSON โ†’ continue. Otherwise โ†’ 401. In practice, Make's Stripe app has a ready trigger that handles this โ€” but it's important to understand what happens underneath.

๐ŸŽฌ The guided solution โ€” a click simulation

๐Ÿ“ธ The illustrated guide โ€” step by step, click by click

For every step: a screenshot of the (simulated) Make editor with the click spot marked, and below it exactly what to click and what to type. You can work from here next to an open Make window.

  1. 1
    A webhook with the raw body
    JSON pass-through + Get request headers โ€” to receive the body as is.
    Marked screenshot โ€” step 1: A webhook with the raw body
    ๐Ÿ“ธ Step 1.1 โ€” the red ring marks where to click
    Marked screenshot โ€” step 1: A webhook with the raw body
    ๐Ÿ“ธ Step 1.2 โ€” the red ring marks where to click
    1. In the left menu click Scenarios โ†’ + Create a new scenario.
    2. Click the scenario name at the top left (New scenario) and type: C04 - Stripe.
    3. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    4. In the search box type Webhooks and click the Webhooks app.
    5. In the list of actions choose Custom webhook.
    6. In the Webhook field type: stripe
    7. In the JSON pass-through field choose: Yes
    8. In the Get request headers field choose: Yes
    9. Click OK (or Save) to close the module window.
  2. 2
    Split the header
    t and v1 from Stripe-Signature.
    Marked screenshot โ€” step 2: Split the header
    ๐Ÿ“ธ Step 2 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Tools and click the Tools app.
    3. In the list of actions choose Set multiple variables.
    4. In the t field map (drag from the panel or type): {{replace(first(split(get(map(1.__headers; "value"; "name"; "stripe-signature"); 1); ",")); "t="; "")}}
    5. In the v1 field map (drag from the panel or type): {{replace(last(split(get(map(1.__headers; "value"; "name"; "stripe-signature"); 1); ",")); "v1="; "")}}
    6. Click OK (or Save) to close the module window.
  3. 3
    Compute the signature
    sha256(t + "." + body; "hex"; secret) โ€” the secret from Keychain.
    Marked screenshot โ€” step 3: Compute the signature
    ๐Ÿ“ธ Step 3 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Tools and click the Tools app.
    3. In the list of actions choose Set variable.
    4. In the Variable name field type: sig
    5. In the Variable value field map (drag from the panel or type): {{sha256(2.t + "." + 1.value; "hex"; "whsec_โ€ฆ")}}
    6. Click OK (or Save) to close the module window.
  4. 4
    Router: match โ†’ continue, else โ†’ 401
    Filter sig = v1; Fallback returns 401.
    Marked screenshot โ€” step 4: Router: match โ†’ continue, else โ†’ 401
    ๐Ÿ“ธ Step 4.1 โ€” the red ring marks where to click
    Marked screenshot โ€” step 4: Router: match โ†’ continue, else โ†’ 401
    ๐Ÿ“ธ Step 4.2 โ€” the red ring marks where to click
    1. Click the + (the big circle in the middle, or the half-circle to the right of the last module).
    2. In the search box type Flow Control and click the Flow Control app.
    3. In the list of actions choose Router.
    4. Keep the defaults.
    5. Click OK (or Save) to close the module window.
    6. Click the small + coming out of the Router (to its right) to open a new route.
    7. In the search box type JSON and click the JSON app.
    8. In the list of actions choose Parse JSON.
    9. In the JSON string field map (drag from the panel or type): {{1.value}}
    10. Click OK (or Save) to close the module window.
    11. Click the ๐Ÿ”ง icon on the line between the last two modules โ†’ Set up a filter.
    12. In the Label field type: Valid signature.
    13. In Condition set: 3.sig = 2.v1 (pick the field from the panel, the operator from the list, and type a value).
    14. Click OK โ€” a funnel icon appears on the line.
    15. Click the small + coming out of the Router (to its right) to open a new route.
    16. In the search box type Webhooks and click the Webhooks app.
    17. In the list of actions choose Webhook response.
    18. In the Status field type: 401
    19. In the Body field type: {"error":"bad signature"}
    20. Click OK (or Save) to close the module window.
    21. Click the ๐Ÿ”ง on the line of the last route โ†’ Set up a filter.
    22. Type Fallback as the Label, and tick Fallback route: Yes.
    23. Click OK โ€” this route runs only when no other route matched.
  5. 5
    Test with a sample event
    Stripe CLI: stripe trigger payment_intent.succeeded.
    Marked screenshot โ€” step 5: Test with a sample event
    ๐Ÿ“ธ Step 5 โ€” the red ring marks where to click
    1. Click โ–ถ Run once at the bottom left.
    2. When the run ends, bubbles with numbers appear above the modules. Click the bubble of the last module and check the Output.
    3. The output should look roughly like this:
      {
       "type": "payment_intent.succeeded",
       "verified": true
      }