How to build a sales lead generation product with Unified.to


February 27, 2024

Any lead generation solution needs to integrate with CRM (customer relationship management) applications. CRMs like HubSpot and Salesforce are the source of truth for sales professionals, centralizing core activities like contact management, deal status tracking, and email campaigns.

Unified.to makes it faster and easier for SaaS developers to add integrations to their products. Through our Unified API developer platform, developers integrate once to add multiple CRM integrations to their products simultaneously.

In this guide, we'll explore how to build a robust and scalable sales lead generation product that leverages Unified.to's pre-built CRM integrations. Seamlessly insert leads and, in some cases, companies, contacts, and deals directly into your customers' preferred CRM.

Who

You have built a Lead Generation solution for salespeople to find more opportunities.

Why (your goal)

You need access to your customers' CRM application to find new leads for your customers' products and to add leads to their CRM, so sales teams can follow-up on new opportunities and close deals.

What

You need to integrate seamlessly with the most popular CRM applications that are utilized by your customers, such as Salesforce, HubSpot, Pipedrive and more. This will provide your users with a streamlined user experience, ensuring efficient data flow and synchronization between your lead generation solution and their preferred CRM.

How to add CRM integrations to your product

New to Unified.to? Before we start, be sure to read this quick guide:

Getting Started with Unified

  1. Once you find a lead (or prospect) for your customer, you will then need to add them as a Lead or Contact in their CRM. If you are adding a contact, then you might also want to add an associated deal and company. Inserting leads or contacts into a CRM provides critical value as your customer's sales team is reliant on their CRM. All of their sales-related data, including your lead data, should be centralized within their CRM.
  2. To add a lead use the createLead API endpoint. You should check if that lead exists by searching for the corresponding email with listLeads. We also recommend checking if there is already a contact with that same email (with listContacts).
    1. Leads are not associated with Deals and Companies and will rely on your customer's salesperson to migrate them to a Contact and then create a Deal and Company for that Contact.
    import { UnifiedTo } from '@unified-api/typescript-sdk';
    
    const sdk = new UnifiedTo({
        security: {
            jwt: '<YOUR_API_KEY_HERE>',
        },
    });
    
    export async function createLead(connectionId: string, email: string, name: string) {
        // check if lead already exists
        const leadsResult = await sdk.crm.listCrmLeads({
            connectionId,
            query: email,
            limit: 1,
        });
        if (leadsResult.statusCode !== 200) {
            // handle error
            return false;
        }
        if (leadsResult.crmLeads?.length) {
            return false;
        }
    
        // check if contact already exists
        const contactsResult = await sdk.crm.listCrmContacts({
            connectionId,
            query: email,
            limit: 1,
        });
    
        if (contactsResult.statusCode !== 200) {
            // handle error
            return false;
        }
        if (contactsResult.crmContacts?.length) {
            return false;
        }
    
        const createLeadResult = await sdk.crm.createCrmLead({
            connectionId,
            crmLead: {
                emails: [{ email }],
                name,
            },
        });
    
        return createLeadResult.crmLead;
    }
    
  3. To add a contact, use the createContact API endpoint, but first check to see if a contact already exists with that email (using listContacts querying by email).
    import { UnifiedTo } from '@unified-api/typescript-sdk';
    
    const sdk = new UnifiedTo({
        security: {
            jwt: '<YOUR_API_KEY_HERE>',
        },
    });
    
    export async function createContact(connectionId: string, email: string, name: string) {
        const result = await sdk.crm.listCrmContacts({
            connectionId,
            query: email,
            limit: 1,
        });
    
        if (result.crmContacts?.length) {
            return result.crmContacts[0];
        }
    
        const createResult = await sdk.crm.createCrmContact({
            connectionId,
            crmContact: {
                emails: [{ email }],
                name,
            },
        });
    
        return createResult.crmContact;
    }
    
  4. If you are creating a Contact, you may also want to create the associated Deal and Company before and then use those IDs when creating the Contact. Again, before creating a Company, you should check if it already exists (by using listCompanies and querying on the company name).
    import { UnifiedTo } from '@unified-api/typescript-sdk';
    
    const sdk = new UnifiedTo({
        security: {
            jwt: '<YOUR_API_KEY_HERE>',
        },
    });
    
    export async function createCompanyAndDeal(connectionId: string, contactId: string, name: string, website: string) {
        const result = await sdk.crm.listCrmCompanies({
            connectionId,
            query: name,
            limit: 1,
        });
    
        if (result.crmCompanies?.length) {
            return;
        }
    
        const createCompanyResult = await sdk.crm.createCrmCompany({
            connectionId,
            crmCompany: {
                name,
                websites: [website],
            },
        });
    
        const createDealResult = await sdk.crm.createCrmDeal({
            connectionId,
            crmDeal: {
                name: `${name}'s deal`,
            },
        });
    
        if (createCompanyResult.crmCompany?.id && createDealResult.crmDeal?.id) {
            const createContactResult = await sdk.crm.getCrmContact({
                connectionId,
                id: contactId,
            });
    
            await sdk.crm.updateCrmContact({
                connectionId,
                id: contactId,
                crmContact: {
                    dealIds: (createContactResult.crmContact?.dealIds || []).concat(createDealResult.crmDeal.id),
                    companyIds: (createContactResult.crmContact?.companyIds || []).concat(createCompanyResult.crmCompany.id),
                },
            });
        }
    }
    
  5. Optionally, you can enrich the Lead/Contact and Company information by using our enrichPerson and enrichCompany endpoints. Those connections could be your own, or you could have your customers authorize access to their accounts in an enrichment application (e.g., ClearBit, ZoomInfo).
    import { UnifiedTo } from '@unified-api/typescript-sdk';
    
    const sdk = new UnifiedTo({
        security: {
            jwt: '<YOUR_API_KEY_HERE>',
        },
    });
    
    export async function enrichPerson(connectionId: string, email: string) {
        return await sdk.enrich.listEnrichPeople({
            connectionId,
            email,
        });
    }
    
  6. Optionally, you could assign the new Lead to a salesperson. First, get that salesperson's ID by using the ListEmployees endpoint and querying on their email.
    import { UnifiedTo } from '@unified-api/typescript-sdk';
    
    const sdk = new UnifiedTo({
        security: {
            jwt: '<YOUR_API_KEY_HERE>',
        },
    });
    
    export async function assignLead(crmConnectionId: string, leadId: string, hrisConnectionId: string, salesperson_email: string) {
        const salespersonResult = await sdk.hris.listHrisEmployees({
            connectionId: hrisConnectionId,
            query: salesperson_email,
            limit: 1,
        });
    
        if (salespersonResult.hrisEmployees?.length) {
            await sdk.crm.updateCrmLead({
                connectionId: crmConnectionId,
                id: leadId,
                crmLead: {
                    userId: salespersonResult.hrisEmployees[0].id,
                },
            });
        }
    }
    

    That's it. You've now built a sales lead generation product that effectively leverages third-party CRM integrations.

    Questions about Unified.to?


    Unified.to is a complete solution to power your sales lead generation product with CRM integrations. Meet with an integrations expert or chat with us on Discord.
Are we missing anything? Let us know
Was this page helpful?