# Integrate Callingly with Salesforce

Source: https://callingly.com/help/article/57-integrate-callingly-with-salesforce

<div data-html-block><table class="feature-chips"><tbody><tr><td><span style="color: #5B66FF" class="material-icons">swap_horiz</span> Two-way integration</td><td><span style="color: #5B66FF" class="material-icons">account_tree</span> Workflow trigger</td><td><span style="color: #5B66FF" class="material-icons">sync</span> Two-way owner sync</td></tr></tbody></table></div>

Callingly connects to your Salesforce account, allowing you to trigger calls using a workflow in Salesforce.

<div class="row relevant"><p><span class="material-icons">supervisor_account</span> Owners and Admins can set up integrations. <em class="float-right-desktop">Approx. reading time 8 min.</em></p></div>

<h2 id="connect-callingly">Connect Callingly to Salesforce</h2>

<dl><dt>1.</dt><dd><strong>Navigate to the </strong><a href="https://callingly.com/dashboard/integrations/new" target="_blank"><strong><em>New Integration</em> page</strong></a>.</dd><dt>2.</dt><dd><strong>Hit the <em>Connect</em> button</strong> next to the Salesforce integration option. The connection will take place automatically. You’ll see a green popup in the top right corner of Callingly, letting you know the connection was successful.<div class="callout-green mb-2"><span class="material-icons">info_outline</span><div><strong>Note</strong>: You'll be taken to a Salesforce login page if you need to log in.</div></div></dd></dl>

<h2 id="choose-settings">Choose Settings</h2>

Open the integration from the <a href="https://callingly.com/dashboard/integrations" target="_blank">Integrations</a> page. Its **Settings** tab has these options:

<div class="callout dashed"><h4>Name</h4><p>The integration's name in Callingly. Give it a clearer name if you connect more than one Salesforce account.</p><h4>Endpoint URL</h4><p>The address Salesforce sends new leads to. You'll paste it into Salesforce below.</p><h4>Sync Calls</h4><p>Log each of your reps' calls with a lead in Salesforce as a call activity.</p><h4>Lead Status</h4><p>The lead status to set in Salesforce after a call is completed, or leave it unchanged.</p><h4>Sync Unsuccessful Calls to Salesforce</h4><p>Also log calls that didn't reach the lead.</p><h4>Sync Lead Owner</h4><p>When Callingly assigns the lead to a user, set the same owner in Salesforce. Each user must be matched to their Salesforce user (see <a href="#sync-calls">below</a>).</p><h4>Lead Owner Field</h4><p>The Salesforce field Callingly reads the lead's owner from. <em>OwnerId</em> unless you change it.</p></div>

<p class="mb-2"><strong>What starts a call:</strong> an outbound message from Salesforce. The next sections show how to set one up.</p>

<p class="mb-2">Two more tabs finish the setup:</p><ul class="mb-2"><li><strong>Routing</strong> decides which team calls each lead, and which sequence it follows. See <a href="https://callingly.com/help/article/82-understanding-call-routing" target="_blank">Understanding Call Routing</a>.</li><li><strong>Fields</strong> matches Salesforce fields to Callingly's lead fields, including your own custom fields. It also sets which Salesforce object your outbound message sends.</li></ul>

<h2 id="configure-salesforce">Configure Salesforce</h2>

Now it’s time to configure a few things in Salesforce. Namely, you must add an endpoint URL to your Salesforce outbound messages and set up a workflow containing your desired Callingly actions. Let’s take it a step at a time, beginning with the endpoint URL.

<h3 id="endpoint-url">Grab your Salesforce endpoint URL</h3>

The Callingly endpoint URL allows the two applications to communicate with each other.

<div class="callout-yellow mb-2"><span class="material-icons">warning_amber</span><div><strong>Important</strong>: If you do not add the Callingly endpoint URL to your Salesforce outbound messages, the integration setup will not be complete, so it won’t work.</div></div>

<dl><dt>1.</dt><dd><strong>Navigate to the </strong><a target="_blank" href="https://callingly.com/dashboard/integrations"><strong><em>Integrations</em> page</strong></a> on the Callingly dashboard.</dd><dt>2.</dt><dd><strong>Hit the <em>Settings</em> button</strong> next to the connected Salesforce integration.</dd><dt>3.</dt><dd><strong>Copy your Endpoint URL</strong>. We’ll share it with Salesforce in the next step.</dd></dl>

<div class="callout-green dashed mb-2"><div>Before configuring your outbound messages in Salesforce,&nbsp; <strong>note which Salesforce fields Callingly reads</strong>, on the integration's <a href="#choose-settings"><em>Fields</em> tab</a>.</div></div>

<h3 id="create-outbound-message">Create an outbound message</h3>

Now, let’s head to Salesforce to plug in the endpoint URL. In your Salesforce account:

<dl><dt>1.</dt><dd><strong>Click the <span class="material-icons">settings</span>Settings icon</strong> in the top right corner of the page.</dd><dt>2.</dt><dd><strong>Select <em>Setup</em></strong> from the dropdown menu. You’ll be navigated to a new window.</dd><dt>3.</dt><dd><strong>Search for <em>Outbound Messages&nbsp;</em></strong>in the search bar on the left side of the screen. You should get at least two results.</dd><dt>4.</dt><dd><p><strong>Choose <em>Outbound Messages</em> under the <em>Process Automation</em> category</strong>. This is where we’ll create a new outbound message.</p></dd><dt>5.</dt><dd><strong>Hit the New Outbound Message button</strong>. The screen will redirect to a new page where you can select an object with the fields you want to include in your message.</dd><dt>6.</dt><dd><p><strong>Select <em>Lead</em> from the dropdown menu</strong>. We’re choosing the Lead object because we want Lead information to be sent from Salesforce to Callingly.</p><div class="callout-green mb-2"><span class="material-icons">info_outline</span><div><strong>Note</strong>: You can also use the Contact object if you’d prefer. The rest of the setup remains the same.</div></div></dd><dt>7.</dt><dd><strong>Click <em>Next</em></strong>.</dd><dt>8.</dt><dd><p><strong>Configure your outbound message</strong>. This is where you’ll configure the data sent from Salesforce and the endpoint URL where the data is sent so that it reaches your Callingly account. There are three fields you’ll want to be sure are completed before moving on:</p><table class="table-bordered"><colgroup><col style="width: 25%"> <col style="width: 75%"></colgroup><tbody><tr><td>Name</td><td>It’s always good practice to use a unique and identifiable name. This makes it easy to find the message in the future if you need to change something or troubleshoot. We’ll use: <em>New lead sent to Scranton Team.</em></td></tr><tr><td>Endpoint URL</td><td>This is where you’ll paste the Callingly Endpoint URL copied earlier. Go ahead and paste it in! Phew. You can finally stop worrying about losing what’s in your clipboard.</td></tr><tr><td>Selected Fields</td><td>Select the fields that match the Field names present in your integration from the <em>Available Fields</em> box, matching the integration's <a href="#choose-settings">Fields tab</a> in Callingly. For our purposes, we’re selecting:<ul><li>FirstName</li><li>LastName</li><li>Phone</li><li>Email</li><li>Company</li></ul>Id will always be selected as well.</td></tr></tbody></table></dd><dt>9.</dt><dd><strong>Click <em>Save</em></strong> to save your new message!</dd></dl>

<h2 id="create-a-flow">Create A Flow in Salesforce</h2>

We now need to set up a Flow — or a workflow — that causes this outbound message to send to the Callingly endpoint URL. This allows information to pass from Salesforce to Callingly. For this article, we want our workflow to cause new leads to be called through Callingly.

From the setup page of your Salesforce account:

<dl><dt>1.</dt><dd><strong>Search for <em>Flows</em>&nbsp;</strong>in the search bar on the left side of the screen.&nbsp;</dd><dt>2.</dt><dd><strong>Select <em>Flows</em> under the Process Automation category</strong>. This will cause the screen on the right to reload with the Flows panel.</dd><dt>3.</dt><dd><strong>Press the <em>New Flow</em> button</strong> to start creating your new workflow. This will open the Flow builder in a new window.</dd><dt>4.</dt><dd><strong>Select the <em>Record-Triggered Flow</em> option</strong> from the pop-up menu. Since we want the workflow to trigger based on lead records, a record-triggered flow is the optimal way to make that happen.&nbsp;</dd><dt>5.</dt><dd><p><strong>Click the <em>Create</em> button</strong>. A new pop-up window will appear where you can configure the start of your Flow.</p></dd></dl>

<h3 id="configure-start">Configure start</h3>

The workflow creation is broken into three parts. We’ll start by configuring the start, before creating an action, and end by saving and activating the flow.

<dl><dt>1.</dt><dd><strong>Select <em>Lead</em></strong> from the dropdown menu under the Select Object header. This will specify to Salesforce that the workflow should begin when something happens with a Lead record. We’ll define that ‘something’ next.</dd><dt>2.</dt><dd><strong>Choose the option <em>A record is created or updated&nbsp;</em></strong>under the <em>Configure Trigger</em> heading. This ensures that Salesforce starts the Flow when the Lead meets the conditions, even if the conditions update later.</dd><dt>3.</dt><dd><strong>Select </strong><i style="font-weight: bold;">All Conditions Are Met</i><i style="font-weight: bold;"> (AND)</i><strong> from the dropdown menu </strong>under the <em>Set Entry Conditions</em> heading. This allows us to ensure that the Flow only triggers if we have the lead’s phone number. As Callingly can’t make a call to an email address, we don’t want to use up resources triggering our Flow for leads that only have an email address attached.</dd><dt>4.</dt><dd><strong>Search for <em>Phone</em></strong> in the Field input&nbsp;box.</dd><dt>5.</dt><dd><strong>Set the operator to <em>Does Not Equal</em></strong>.</dd><dt>6.</dt><dd><strong>Choose the value of {!$GlobalConstant.False} constant</strong> using the Value dropdown menu. This means the workflow will begin once a value is entered for the phone number field when a lead is created.</dd><dt>7.</dt><dd><strong>Choose the option <em>Only when a record is updated to meet the condition requirements</em></strong> under the When to Run the Flow for Updated Records heading. This ensures that Salesforce knows only to run the Flow once per Lead.</dd><dt>8.</dt><dd><strong>Click the <em>Done</em> button</strong> to save your choices and continue to the next step to set up your action.</dd></dl>

<h3 id="create-action">Create an action</h3>

It’s great for the Flow to start, but nothing will happen if we don’t define an action. So let’s define what is meant to happen to our Leads after they enter the Flow.

<dl><dt>1.</dt><dd><strong>Hit the + button</strong> in your workflow path to add an element to the Flow. A new window will pop up.</dd><dt>2.</dt><dd><strong>Search for <em>Action</em></strong> in the search bar at the top of the Add Element screen. The pop-up will change to a <em>New Action</em> window so you can define your action.</dd><dt>3.</dt><dd><strong>Select <em>Outbound Message</em></strong> on the left side of the pop-up.</dd><dt>4.</dt><dd><strong>Choose the outbound message</strong> that we <a href="#create-outbound-message">created previously</a> from the search bar/dropdown on the right side of the pop-up.</dd><dt>5.</dt><dd><strong>Enter a <em>Label</em></strong> for your action, such as <em>Send Lead to Callingly</em>. The <em>API name</em> box will automatically fill in. Add a description if you’d like.</dd><dt>6.</dt><dd><strong>Click <em>Done</em></strong>. The pop-up will close and return you to the overall Flow.</dd></dl>

<h3 id="save-and-activate">Save and activate your Flow</h3>

It's crucial that you both _Save_ and _Activate_ your flow; otherwise, all the work you’ve done is for naught!

<dl><dt>1.</dt><dd><strong>Hit the <em>Save</em> button</strong> in the upper right corner of the screen to save your Flow! A pop-up will appear.</dd><dt>2.</dt><dd><strong>Give your Flow a name in the <em>Flow Label</em> box</strong>. We’ve used <em>New lead is sent to Callingly</em>.</dd><dt>3.</dt><dd><strong>Click <em>Save</em></strong> to finalize your Flow.</dd><dt>4.</dt><dd><p><strong>Press the <em>Activate</em> button</strong> at the top of the screen to turn your workflow on.</p><div class="callout-yellow mb-2"><span class="material-icons">warning_amber</span><div><strong>Important</strong>: If you don't activate the Flow, the integration won't work!</div></div></dd></dl>

<h2 id="sync-calls">Sync Calls and Lead Owner</h2>

Match each Callingly user to their Salesforce user. Synced calls are then logged under the right person, and <strong>Sync Lead Owner</strong> can set the lead's owner.

<dl><dt>1.</dt><dd><strong>Go to the <a href="https://callingly.com/dashboard/users" target="_blank">Users</a> page</strong> and click <strong>Edit</strong> next to the user.</dd><dt>2.</dt><dd><strong>Under <em>Integrations</em>, pick their account</strong> in the <em>Salesforce User</em> dropdown.</dd><dt>3.</dt><dd><strong>Save</strong>, and repeat for each user.</dd></dl>

<h2 id="next-steps">Next Steps</h2>

1.  **Test the integration by creating a new fake lead in your Salesforce account**. This should automatically call Callingly, which will route the phone call to the Team selected during the [Choose Settings](#choose-settings) step.
2.  **Set the call schedule**. Once you've added your team, you'll want to <a href="https://callingly.com/help/article/37-setting-availability-schedules" target="_blank">set the schedule</a> for when they can receive calls. This way, nobody will receive a call outside of work hours.

<h2 id="pro-tip">Pro-tip</h2>

#### Use a sandbox connection to test Salesforce with Callingly.

By creating a sandbox connection with Callingly, you can use Salesforce within a separate environment for testing and training. 

To do this, **simply choose _Connect Sandbox_** when [connecting Callingly to Salesforce](#connect-callingly).

<h2 id="common-questions">Common Questions</h2>

#### How do I route leads to multiple teams?

You can do this by creating another instance of the Salesforce integration in Callingly. Each integration will have a unique endpoint URL. You’ll need to create new outbound messages and new workflows for each instance of the integration.

#### How do I integrate with the Salesforce Sandbox vs. Production?

Salesforce gives every account a Sandbox version to test things in a non-production environment. To integrate with the Sandbox version,  **choose _Connect Sandbox_** during the first step of connecting your accounts.

#### How do I sync the lead owner between Salesforce and Callingly?

You can do this by heading to the <a href="https://callingly.com/dashboard/users" target="_blank">Users</a> page in Callingly and editing the user you want to modify. Look for the _Salesforce User_ field box and select the user from the dropdown menu. When a Lead is synced into Callingly, the Lead will maintain that relationship with your user as the lead owner.
