Skip to content
  • There are no suggestions because the search field is empty.

Linking people to an existing organisation using n8n

Learn how to set up an n8n workflow that automatically links people records to their matching company record in your CRM, using either the Firmable domain or the company name as the lookup.

Prerequisites

Before building this workflow, make sure:
  • You are on a Small Teams, Teams Pro or Enterprise plan with Firmable.  
  • You have the Admin, Manager or Integration role on Firmable and the Admin role in your CRM. 

There are two common situations you may need to handle when linking contacts to companies in your CRM. Choose the scenario that matches how your data is set up.

Scenario 1: Companies pushed from Firmable

Map people records to company records that have already been pushed from Firmable, using the company domain (FQDN) as the identifier.

Scenario 2: Companies already in your CRM

Map people records to company records that already exist in your CRM, using the company name stored in a custom field as the lookup.

Best practice: Ideally, push the company record before pushing people records. This way, the FQDN is already mapped on the company record and the lookup will reliably find a match.

Scenario 1: Matching by domain (Firmable-pushed companies)

This is the recommended approach. It uses the company's domain (FQDN) as a reliable, unique identifier to find the matching company record in your CRM.

Workflow steps

  • Trigger on person creation: use your CRM's trigger node, configured to fire when a new person record is created.
  • Get the person record: retrieve the full record details using a Get node.
  • Extract the domain from the email address: use a Code node to parse the email and return just the domain portion.
  • Check if the domain exists: use an If node to ensure the domain value is not empty before proceeding.
  • Search your CRM for the company record: search using the custom field mapped to FQDN (or the Firmable ID if you mapped that instead).
  • Update the person record: link the person record to the matching company by setting the relevant company ID field.

An n8n workflow: Pipedrive Trigger, Get a person, Code, If, Search an organization by domain, then Update a person

CRM trigger

The Pipedrive Trigger node set to the Create action for the Person entity

Configure the CRM trigger to fire on person creation events.

Get a person

The Get a person node using the person ID from the trigger

Retrieve the full person record to access their email address for domain extraction.

Extracting the domain from the email address

This Code node extracts the domain portion from the person's email address, which is then used to search for the matching organisation in your CRM.

Code node

The Code node with JavaScript that extracts the domain from the email address

The Code node parses the person's email address and appends the domain to the item payload.

// Extract the domain from the person's email address
const items = $input.all();

const updatedItems = items.map((item) => {
const email = item?.json?.Email?.[0]?.value;
const domain = email?.includes("@") ? email.substring(email.indexOf("@") + 1) : undefined;
item.json.domain = domain;
return item;
});

return updatedItems;

If node, check domain exists

The If node with one condition: domain is not empty

The If node checks whether a domain value exists before attempting the organisation search.

Update a person

The Update a person node setting Organization Name or ID to the ID returned by the organisation search

The Update a person node sets the org_id field using the ID returned from the organisation search.

Scenario 2: Matching by company name (existing CRM companies)

Use this approach when company records already exist in your CRM and were not pushed from Firmable. The lookup is based on the organisation name stored in a custom field on the people record. 

Note: This flow can be less reliable because it matches on company name, which is not a guaranteed unique identifier. There may be better identifiers available depending on your data setup. It's worth investigating before building this workflow at scale.

Workflow steps

  • Map the company name to the people record using a custom field before this workflow runs.
  • Trigger on person creation: use your CRM trigger node.
  • Get the person record using a Get node, so the company name custom field is available to the search.
  • Search your CRM for an organisation using the company name from the custom field.
  • Update the person record with the matching organisation ID.

Search an organisation by name

The Search an organization by name node using the Company name field from Get a person

This node searches your CRM for an organisation matching the company name. Note: this assumes the company already exists in your CRM.

Update a person: link to organisation

The Update a person node linking the person to the organisation found by name

Map the organisation ID returned from the search to update the person record and create the link.

If you have a mix of Firmable-pushed companies and existing CRM data, consider building both flows and using an If node at the start to route records based on whether a Firmable domain field is populated.