Send call results to n8n
Summary
This recipe sends the summary of each finished call from Rasen to an n8n workflow through a
signed call.analyzed webhook. The workflow verifies the signature, answers 2xx at once, drops
duplicates and reads the summary from the API when the event does not carry it. It does not cover
what you do with the summary after that, for example writing it to a sheet or a CRM.
Facts
Steps
1. Create the n8n Webhook node
- In n8n, create a workflow and add a Webhook node.
- Set HTTP Method to
POSTand Path tocall-results. - Set Authentication to
None. The signature check in step 3 authenticates each request. - Set Respond to
Using 'Respond to Webhook' Node. - Under Options, add Raw Body and turn it on.
- Publish the workflow, then copy the Production URL of the node.
The Production URL has the form https://<your n8n host>/webhook/call-results. Set
N8N_WEBHOOK_URL to it. The Test URL listens for 120 seconds only, so do not register it with
Rasen.
2. Register a Rasen webhook endpoint for call.analyzed
The answer is 201 with the endpoint and its signing secret. No other answer returns the secret,
so store it at once. Set ENDPOINT_ID to the id of the endpoint.
Store the secret where your n8n edition can read it:
-
Self-hosted n8n: add these lines to the environment of the n8n server, then restart n8n.
N8N_BLOCK_ENV_ACCESS_IN_NODE=falselets every workflow read every environment variable of the server. Give edit access to workflows only to people who may read the secret. -
n8n Cloud, or a licensed self-hosted edition: create a custom variable named
RASEN_WEBHOOK_SECRETwith the secret as its value. In step 3, read$vars.RASEN_WEBHOOK_SECRETinstead of$env.RASEN_WEBHOOK_SECRET.
The endpoint receives only events that Rasen creates after the endpoint’s created_at.
3. Verify the signature and answer in n8n
Add a Code node after the Webhook node. Name it Verify signature, set Language to
JavaScript and Mode to Run Once for All Items, and paste this code:
The code checks the exact request bytes before it parses the JSON. Then add these nodes:
Accept answers Rasen before any slow node runs. The workflow then goes on with the event. A
webhook.test event passes the signature check, gets 200, and stops at Is call.analyzed?.
Paste this code into Pick summary, with Mode set to Run Once for All Items:
4. Read the summary when the event does not carry it
Add an If node named Summary ready? after Pick summary, with the condition
{{ $json.summary_state }} is equal to ready. On its false output, add an HTTP Request
node named Read summary:
These requests show what Read summary sends, with getCall for the call fields of a reduced
event. Set CALL_ID to the call_id of the item.
getCallSummary answers the summary with its state. summary holds text only when state is
ready. While state is pending, wait poll_after_seconds (an n8n Wait node,
Resume After Time Interval) and read it again. not_requested, failed and unavailable do
not change into ready on their own: store the item with summary null.
5. Send a test event
The answer is 201 with the queued delivery of one webhook.test event, signed like every other
event. In n8n, open the Executions tab of the workflow. The execution passes Verify signature
with valid: true and ends at Is call.analyzed?.
Rules
- MUST register the Production URL, and MUST publish the workflow before Rasen sends events.
- MUST verify the signature over the raw body bytes before you parse or use the event.
- MUST answer
2xxwithin 10 seconds. PutAcceptbefore every slow node. - MUST answer
401or another status that is not2xxwhen the signature check fails. - MUST drop repeats by the event
id, which equals thewebhook-idheader. Rasen delivers at least once. - MUST read the call with
getCallandgetCallSummarywhendata.truncatedistrue. - MUST answer
2xxto an eventtypethat you do not know, and ignore it. - MUST NOT store the signing secret in a node parameter that people who edit the workflow can read in plain text. Use a server environment variable (self-hosted), a custom variable (licensed editions) or your secret store.
- After
Acceptanswers2xx, Rasen does not send the event again. If a later node fails, resend the delivery withresendWebhookDelivery, or read the call withgetCall.
Verify
Expected output: at least one item with "state": "succeeded" and "last_status_code": 200.