# Make: send saved affiliates to your CRM

Every morning, Make picks up the affiliates you saved in RecruitAffiliates.ai and adds each one to your CRM.

Save affiliates in RecruitAffiliates.ai as you find them. Every morning, Make copies the new ones into your CRM and tags them, so nobody gets added twice. A **CRM** is the tool where you track the people you're talking to, like HubSpot or Pipedrive.

This recipe only reads and tags. It never spends a credit.

## What you need

- A plan that includes the API, and a key with the `finder:write` scope. Writing a tag needs write.
- A Make account, and your CRM connected to Make.

## Build the scenario

1. In Make, create a scenario. Start it with the "HTTP" app and the module "Make a request".
2. Fill in the request:

| Setting | Value |
| --- | --- |
| URL | `https://api.affiliaterail.com/v1/finder/saved` |
| Method | `GET` |
| Query string | `view` = `saved`, `limit` = `100` |
| Header | `Authorization` = `Bearer rail_test_...` |
| Parse response | Yes |

3. Add an "Iterator" module. Map its array to `data` from the HTTP module. Each saved affiliate now runs through the rest of the scenario one at a time.
4. Add a filter after the iterator. Let a row through only when `tags` doesn't contain `in-crm`.
5. Add your CRM's "Create a contact" module. Map the affiliate's details across. The email is only there if you've revealed it.
6. Add a second "Make a request" module to tag the affiliate:

| Setting | Value |
| --- | --- |
| URL | `https://api.affiliaterail.com/v1/finder/prospects/{{id}}` |
| Method | `POST` |
| Headers | `Authorization` = `Bearer rail_test_...`, `Content-Type` = `application/json`, `Idempotency-Key` = `crm-{{id}}` |
| Body type | Raw, JSON |
| Request content | `{"tags": ["in-crm"]}` |

Use the `id` from the iterator in both places.

7. Set the schedule to once a day, at a time that suits you.
8. Press "Run once" in Make to test it with your test key. Then swap in a live key.

## Tags, not a memory

The `in-crm` tag is how the scenario remembers who it's already sent. You'll see it on each affiliate in the app too. Take the tag off and that person goes to your CRM again the next morning.

The tags you send replace the ones already there. If you use other tags, read `tags` from the iterator and send them back along with `in-crm`.

## More than 100 saved

One request returns up to 100 people. If the answer says `has_more` is true, you have more. Add a "Repeater" and call again with `cursor` set to `next_cursor` from the last answer, until `has_more` is false. [The API guide](/api) explains how cursors work.

## If something goes wrong

- A `402` means your plan doesn't include the API.
- A `403` means the key only has `finder:read`. Make a key with `finder:write`.
- A `429` means you've hit the rate limit. Turn on "Allow storing of incomplete executions" in the scenario settings, and Make retries later.

## Get events the moment they happen

The scenario above checks on a schedule. A webhook tells Make the moment something happens instead, like a reply or a finished search. [Webhooks](/webhooks) explains the events. You need a plan that includes webhooks.

1. Start a scenario. Add the "Webhooks" module, then "Custom webhook".
2. Add a webhook, name it, and copy the address Make gives you.
3. In RecruitAffiliates.ai, go to **Settings**, then the **Webhooks** tab. Add the address as an endpoint and pick your events.
4. Press **Send a test**. Make learns the shape of the body from it.

Keep the address private. Anyone who has it can post to your scenario. [Checking the signature](/webhooks#check-the-signature) is what stops a fake.

## Ready-made scenarios

Two scenarios you can import as they are. In Make, create a scenario, press the three dots at the bottom, choose **Import Blueprint** and pick the file.

- [Interested reply to Slack](/recipes/make-interested-reply-to-slack.blueprint.json): posts in Slack when someone replies with interest. That means a `reply.received` event whose `reply_kind` is `positive` or `question`.
- [New affiliate to a Google Sheet](/recipes/make-signed-up-to-google-sheet.blueprint.json): adds a row when an invited affiliate signs up (`affiliate.signed_up`).

After you import one:

1. Open the webhook module and add a new webhook. Copy its address into the Webhooks tab.
2. Put a **Read only** key in place of `rail_live_REPLACE_WITH_A_READ_ONLY_KEY` in the module that gets the affiliate.
3. Put your Slack address in the last module, or connect Google and pick your sheet. The sheet needs columns for name, website, email, date and source, in that order.

Make passes the body on already parsed, so these scenarios can't check the signature. The webhook's address is long and random, and that's what keeps a stranger out. If you need the signature checked, use [the n8n version](/recipes/n8n) or your own code.
