n8n: save your top 10 and collect their emails
An n8n workflow that saves your 10 best matches, finds each one's email and adds them to a Google Sheet.
Once a week, n8n takes your 10 best-fit matches from RecruitAffiliates.ai, saves them and finds their emails. Then it writes each one to a Google Sheet you can work from.
Finding an email uses one email credit, and only when a usable address comes back. If we find nothing, the credit comes straight back. So this workflow can use up to 10 email credits a run.
What you need
- A plan that includes the API, and a key with the
finder:writescope. - n8n, on their cloud or your own server.
- A Google Sheet with columns for
Name,WebsiteandEmail.
Store the key once
- In n8n, create a credential of the type "Header Auth".
- Set the name to
Authorizationand the value toBearer rail_test_....
Every HTTP Request node below uses this credential. Your key then lives in one place, not in every node.
Build the workflow
- Add a "Schedule Trigger" node. Set it to once a week.
- Add an "HTTP Request" node to get your best matches:
| Setting | Value |
|---|---|
| Method | GET |
| URL | https://api.affiliaterail.com/v1/finder/prospects |
| Authentication | Generic, Header Auth, your credential |
| Query parameters | sort = fit, limit = 10 |
- Add a "Split Out" node on the field
data. Each match becomes its own item. - Add an "HTTP Request" node to save them all in one call. Set it to run once for all items (in its settings, "Execute Once"):
| Setting | Value |
|---|---|
| Method | POST |
| URL | https://api.affiliaterail.com/v1/finder/prospects/save |
| Send body | JSON, {"ids": {{ JSON.stringify($('Split Out').all().map(i => i.json.id)) }} } |
| Header | Idempotency-Key = save-{{ $execution.id }} |
- Add an "HTTP Request" node to reveal each email. This one runs once per item:
| Setting | Value |
|---|---|
| Method | POST |
| URL | https://api.affiliaterail.com/v1/finder/prospects/{{ $('Split Out').item.json.id }}/reveal_email |
| Header | Idempotency-Key = reveal-{{ $execution.id }}-{{ $('Split Out').item.json.id }} |
- In that node's settings, turn on "Retry On Fail" and set "Wait Between Tries" to 2000 milliseconds.
- Add a "Google Sheets" node with the operation "Append Row". Map the name and website from the Split Out node and the email from the reveal.
- Run the first node by hand with your test key to check the matches come back. A test key can't save, because saving records an event that reaches your live webhooks, so swap in a live key for a full run. Check the sheet, then turn it on.
Why the keys look like that
An idempotency key is a unique string you send so a retried request never runs twice. Each key here joins the run's id with the match's id. When n8n retries a reveal, it sends the same key, so you're never charged twice for the same email. Next week's run has a new run id, so it gets fresh keys.
If something goes wrong
- A
402means your plan doesn't include the API. - A
429means you've hit the rate limit. The retry setting in step 6 handles it. - A reveal that finds nothing still succeeds. The email is empty and the credit comes back. Add an "If" node before the sheet to skip those rows.
Keys, errors, limits and every endpoint are in the API guide.
Get events the moment they happen
The workflow above runs when you start it. A webhook starts one for you the moment something happens, like a reply or a finished search. Webhooks explains the events. You need a plan that includes webhooks.
- Add a "Webhook" node. Set the method to
POST. - Copy its production URL. The test URL only works while the editor is listening.
- In RecruitAffiliates.ai, go to Settings, then the Webhooks tab. Add the URL as an endpoint and pick your events.
- Turn on the node's "Raw Body" option if you want to check the signature in a Code node.
- Activate the workflow, then press Send a test.
Keep the URL private. Anyone who has it can post to your workflow. Checking the signature is what stops a fake.
Ready-made workflows
Two workflows you can import as they are. In n8n, open a new workflow, press the three dots, choose Import from File and pick the file.
- Interested reply to Slack: posts in Slack when someone replies with interest. That means a
reply.receivedevent whosereply_kindispositiveorquestion. - New affiliate to a Google Sheet: adds a row when an invited affiliate signs up (
affiliate.signed_up).
Each one checks the signature for you. It works the HMAC out with n8n's Crypto node and only lets through a message that's real and less than five minutes old. Then it fetches the affiliate's name and website from the API.
Before you turn one on, replace each REPLACE placeholder:
whsec_REPLACE_WITH_YOUR_SIGNING_SECRETin "Work out the signature": the secret from the Webhooks tab.rail_live_REPLACE_WITH_A_READ_ONLY_KEYin "Get the affiliate": a Read only key from the API tab.- The Slack address, or the sheet's link, in the last node. The sheet needs the columns
Name,Website,Email,Signed upandHow we know.
Was this page helpful?