Lesson 4 of 5 · 10 min
Let the brain act with webhook actions
Create a custom action so the brain can act in any system through n8n, and verify the signature of each call before doing anything with it.
The ready-made integrations cover email, calendar, HubSpot, WhatsApp and spreadsheets. For everything else (creating an invoice in Siigo, recording a payment in the ERP, looking up a balance) there's the custom action: a new brain tool that calls a webhook in your automation. The brain decides what to do and when; your automation takes care of how to do it in the client's system.
What you'll achieve
- Create a custom action with a good description and just the right data.
- Build an n8n flow that verifies the Zunous signature and doesn't process the same call twice.
- Reply to the brain with a result that is recorded in the log.
Create the action in the Console
Only an admin can do this.
- In Autonomous Mode, go to Custom actions and click New action.
- Name: lowercase letters, numbers and
_, for examplecrear_factura. The brain will see it as the toolaccion.crear_factura. - Webhook URL: the one n8n, Make, Power Automate or Zapier gives you. It must start with
https://, use port 443 and a public domain. - What it does and when to use it: 10 to 500 characters. This is the most important part, because the brain reads it to decide. Example: "Creates an invoice in Siigo when a customer accepts a proposal and already has a registered NIT (tax ID)".
- Data it sends: one per line, in the form
name:type:description. The types aretexto(text),numero(number) orsi_no(yes/no); add an asterisk at the end of the name if it's required, for examplenit*:texto:Customer's NIT. Up to 15 fields. - Choose the Type: "Action" if it changes something in the system, or "Lookup" if it only fetches information. A lookup doesn't go through drafts and doesn't count toward the plan.
- Choose the Autonomy level (start at Draft), the Daily call cap (1 to 1,000, default 50) and, if you want, the Skills that can use it. If you don't select any, all of them use it.
- Click Create action.
The Console shows the Signing secret, which starts with whsec_, only once. Store it as a credential in your automation. If it's lost, click New signing secret and update it in the flow. Each brain supports up to 20 actions.
What your automation receives
Zunous sends a POST with a JSON body and these headers:
| Header | What it's for |
|---|---|
Zunous-Event | The action, for example accion.crear_factura |
Zunous-Delivery | Unique ID of the delivery; it repeats if Zunous retries |
Zunous-Timestamp | Timestamp in seconds |
Zunous-Signature | The signature, in the form v1= followed by a hexadecimal value |
The body includes accion, organizacion, brain, ejecucion, aprobada_por (the email of whoever approved, or null if the brain acted on its own), datos (only the fields you defined) and, on test calls, "prueba": true.
Verify the signature in n8n
Anyone who knows the URL could call it. The signature proves the call comes from Zunous and that nobody changed the content. Build the flow like this:
- Webhook node,
POSTmethod, with the Raw Body option turned on to receive the body exactly as it arrived. - Crypto node, action Hmac, type SHA256, encoding hex. The text to sign is the timestamp, a period and the raw body:
<Zunous-Timestamp>.<body>. The key is the full secret, includingwhsec_, stored as a credential. - IF node that continues only if
v1=plus the result equals theZunous-Signatureheader, and if the timestamp is no more than 5 minutes old. - A step that stores the
Zunous-Delivery(for example in a data table or a spreadsheet) and discards deliveries it has already seen. That way a retry doesn't create two invoices. - If
pruebaistrue, respond without touching the real system. - The step that does the work, for example creating the invoice.
- Respond to Webhook node with code
200and a JSON with aresultadofield.
Reply to the brain
- Respond
2xxwhen you're done. If you return a JSON withresultado, the brain reads that text (up to 2,000 characters) and it's recorded in the log. Example:{"resultado": "Invoice FV-1023 created for $1,200,000"}. - Respond
4xxif the data isn't usable. The action is marked as an error, the brain knows it and Zunous doesn't retry. - If you respond
5xx, don't respond within 10 seconds or the network fails, Zunous retries once after one second, with the sameZunous-Delivery. If it fails again, the brain receives the error. - Zunous doesn't follow redirects: a
3xxresponse counts as an error.
Before using it for real, click Send test on the action's card. Zunous calls your webhook with sample data and "prueba": true, without counting toward the cap, and the Console shows you what your automation responded.
Practice
Muebles Roble S.A.S., a furniture maker in Envigado, uses Siigo and wants the Collections Brain to record payment agreements:
- Create the
registrar_acuerdoaction with the description "Records in Siigo a payment agreement accepted by the customer, with the number of installments and the amount of each installment". - Define the data:
nit*:texto:Customer's NIT,factura*:texto:Invoice number,cuotas*:numero:Number of installments,valor_cuota*:numero:Amount of each installment in pesos. - Type "Action", level Draft, cap of 20 per day, skill
negociar_acuerdo_pago. - Build the n8n flow with the seven steps above and store the
whsec_…secret as a credential. - Click Send test and confirm the Console shows your
resultado. - Change one character of the secret in n8n, test again and check that the IF node stops the call.
Check what you learned
1. Which part of the custom action does the brain use to decide when to call it?
2. Your automation received the same call twice with the same Zunous-Delivery. What do you do?
3. What do you respond if the data the brain sent isn't usable, for example a NIT that doesn't exist?