> ## Documentation Index
> Fetch the complete documentation index at: https://docs.truagents.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Salesforce with Zapier

> Use a Zap to turn TruAgents hot-lead webhooks into Salesforce Leads without code.

## Summary

A Zap catches the TruAgents webhook, tidies the name and company, and finds or creates the Lead in Salesforce. Nobody writes code, and the Salesforce login stays in Zapier.

This guide is step 2 of [Send hot leads to Salesforce](/automations/hot-leads-to-salesforce). Build the TruAgents workflow first.

## Who this is for

An ops person with a Zapier account and a Salesforce user who can create and edit Leads.

## Before you start

* A Zapier plan that includes **Webhooks by Zapier**, a premium app. Check Zapier's current plans.
* A Salesforce connection in Zapier, using an integration user that can create and edit Leads.
* `TruAgents` added to the Salesforce **Lead Source** picklist, or pick an existing value in step 5.
* One real hot-lead event to build the Zap with (step 2 explains how to send one).

<Note>
  Zapier labels change from time to time. If a label doesn't match exactly, look for the closest equivalent.
</Note>

## Build the Zap

<Steps>
  <Step title="Catch the webhook">
    Create a Zap. For the trigger, choose **Webhooks by Zapier** and the **Catch Hook** event. Leave **Pick off a Child Key** empty. Copy the webhook URL. It starts with `https://hooks.zapier.com/hooks/catch/`.
  </Step>

  <Step title="Send a sample from TruAgents">
    In TruAgents, open the workflow, click the **Send webhook** step, paste the Zapier URL into **Endpoint URL**, and click **Save workflow**. Set the workflow to **Active** and email your TruAgents inbox a hot-lead message from a test address.

    The **Test Workflow** tab never sends anything, so it can't feed Zapier. If you'd rather not activate the workflow yet, `POST` the **Example payload** from the step to the Zapier URL with `curl`.

    Back in Zapier, click **Test trigger**. Pick the request that has `data workflow name` set to your workflow.
  </Step>

  <Step title="Split the name">
    Add an action: **Formatter by Zapier** → **Text** → **Split Text**.

    * **Input**: `Data Contact Name`.
    * **Separator**: `[:space:]`.
    * **Segment Index**: **All (as separate fields)**.

    The first name is every segment except the last one, joined with spaces. "Mary Ann Smith" is "Mary Ann", not "Mary". For a two-word name, that is **Item 1** alone. For a longer name, map the earlier items with a space between them and leave the last item out.

    For the last name, add a second **Split Text** with the same input and **Segment Index** set to **Last**. If `Data Contact Name` is empty, Salesforce still requires a Last Name. Add **Formatter by Zapier** → **Text** → **Default Value**, use that last segment as the input, and set the default to `Data Contact Email`.
  </Step>

  <Step title="Get the company from the email domain">
    Add another **Formatter by Zapier** → **Text** → **Split Text**.

    * **Input**: `Data Contact Email`.
    * **Separator**: `@`.
    * **Segment Index**: **Last**.

    This gives `acme.com` for `jane@acme.com`. To drop the `.com`, add one more **Split Text** with separator `.` and **Segment Index** **First**.

    Company is required, so add **Formatter by Zapier** → **Text** → **Default Value** with the company split as the input and `Unknown` as the default. That covers an email whose domain doesn't split. It does not cover a missing email: the next step stops those contacts before Salesforce.
  </Step>

  <Step title="Require an email">
    Add **Filter by Zapier**. Continue only when `Data Contact Email` exists.

    This Zap needs an email. **Find Record** searches by it, and a blank search fails before **Create Salesforce Record if it doesn't exist yet?** can run, so the Company fallback never gets a chance to save the Lead. A contact with no email, such as one who only called or texted, stops here. Use the [relay](/automations/salesforce-relay) or [Make](/automations/salesforce-make) if those contacts should become Leads. Both set **Last Name** and **Company** to `Unknown` when the name and the email are both empty.
  </Step>

  <Step title="Find or create the Lead">
    Add an action: **Salesforce** → **Find Record**.

    * **Salesforce Object**: **Lead**.
    * **Field to Search By**: **Email**.
    * **Search Value**: `Data Contact Email`.
    * Turn on **Create Salesforce Record if it doesn't exist yet?** and fill in the Lead fields:

    | Lead field | Zapier value |
    | - | - |
    | First Name | Every name segment except the last, joined with spaces |
    | Last Name | The last name segment, or `Data Contact Email` when the name is empty |
    | Company | The company split, or `Unknown` when the domain split is empty |
    | Email | `Data Contact Email` |
    | Phone | `Data Contact Phone` |
    | Lead Source | `TruAgents` |
    | Rating | `Hot` |
    | Description | `Data Communication Subject`, `Data Communication Preview`, and `Data Communication Links Self`, on separate lines |
  </Step>

  <Step title="Optional: log each hot message on the Lead">
    Finding an existing Lead doesn't update it. To give reps every new signal, add **Salesforce** → **Create Record**, object **Task**, with **Related To** set to the Lead ID from the previous step, and the message preview and conversation link as the description.
  </Step>

  <Step title="Test and publish">
    Test each action, check the Lead in Salesforce, then click **Publish**. Continue with [Step 3: test and go live](/automations/hot-leads-to-salesforce#step-3-test-and-go-live).
  </Step>
</Steps>

## Failures and retries with Zapier

Zapier replies `200` to TruAgents as soon as it receives the request, before Salesforce is called. So:

* TruAgents shows the **Send webhook** step as **Succeeded**, even if the Salesforce step fails later.
* TruAgents never retries a lead that Zapier received. Salesforce errors show up only in **Zap history**.
* Turn on Zapier's error email notifications. On plans that include it, turn on **Autoreplay** so Zapier retries failed steps.
* If the Zap is turned off, Zapier doesn't run it. Leads sent while it's off may need to be resent by hand.

## Security

* The Catch Hook URL works like a password: anyone with it can create Leads through your Zap. Share it only in the **Send webhook** step. If it leaks, create a new Catch Hook trigger and update the step.
* Don't add Salesforce credentials as headers on the **Send webhook** step. Zapier holds the Salesforce login.

## Related pages

* [Send hot leads to Salesforce](/automations/hot-leads-to-salesforce)
* [Salesforce relay](/automations/salesforce-relay)
* [Salesforce with Make](/automations/salesforce-make)
* [Webhooks reference](/developers/webhooks)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.