Find us at our new Help Center where we've combined our documentation and knowledgebase articles in one easy-to-search location.
We aren't updating the Developer Portal anymore, except for the Element Docs — all updates happen in the Help Center. We're retiring the Developer Portal as you know it in:
In this Getting Started Guide, we'll walk you through the steps to integrate your contacts in Salesforce with your customers in Shopify. The data sync use case is a simple example that demonstrates the power of Cloud Elements. We'll set up your elements, create a common resource to transform the data into what we need, and then we'll set up a formula to automatically perform the sync.
The four steps in this process are:
The first step in setting up our contact sync from Salesforce to Shopify, is to authorize the Salesforce Sales Cloud and Shopify elements to connect to your accounts. To do so, you will authenticate element instances of both Salesforce Sales Cloud and Shopify. We'll walk you through a simple authentication below, but if you want more information take a look at the Element Guides for Salesforce Sales Cloud and Shopify.
In this step you will authenticate an element instance with Salesforce Sales Cloud. As part of that authentication, you will enable events so Cloud Elements can monitor any additions or changes to your list of contacts.
To authenticate a Salesforce Sales Cloud instance:
Hover over the element card, and then click Authenticate.
The Authentication page includes the fields you need to complete on the left and a code view on the right. When you start building our APIs into your app, you can use this code view to help integrate our APIs in your code. You can see the steps to authenticate by using our APIs in the Salesforce Sales Cloud Element Guide.
Because authentication between Cloud Elements and Salesforce Sales Cloud is done using OAuth 2.0, all you need to do is provide a name for the instance and set up events. After you finish, you'll authorize Cloud Elements access to your Salesforce account.
In Name enter a descriptive name for the instance. For this tutorial, we'll call it "Salesforce Contacts".
https://login.salesforce.com
. Click Events Enabled.
In Event Type, select Polling. We also offer webhooks for Salesforce Sales Cloud, but it requires more setup.
For this tutorial, leave Event Notification Callback URL and Callback Notification Signature Key empty. When you start integrating our APIs in your apps, you'll use these fields to receive event notifications and to add enhanced security.
In Objects to Monitor for Changes enter Contact
.
Change the Event poller refresh interval
to 4. This sets the poller to check every 4 minutes.
Your authentication configuration should look like the example below. Notice that the configuration is also reflected in the code view.
Click Create Instance.
As part of the OAuth 2.0 process, log in to Salesforce and allow the connection to Cloud Elements.
After you authenticate the element instance we suggest that you test it out using the API docs. Click Test in the API docs, open GET /contacts
, click Try it out, and then click Execute. The response body includes all of the contacts in your Salesforce account.
When you finish testing, move on to authenticate with Shopify.
In this step you will authenticate an element instance with Shopify. Because this example creates a one-directional sync from Salesforce to Shopify, you do not need to configure events.
To authenticate a Shopify instance:
Hover over the element card, and then click Authenticate.
Like Salesforce, Cloud Elements also uses OAuth 2.0 to authenticate with Shopify, but you also need to configure your Shopify Site Address. Because each element has its own authentication requirements, make sure you check out the Element Guides like Shopify's Element Guide.
In Name enter "Shopify Customers".
In Shopify Site Address enter the personalized portion of your myshopify.com
URL. For example, for https://cloud-elements.myshopify.com
just enter cloud-elements
.
Click Create Instance.
Log in to Shopify, and then click Install unlisted app.
Like the Salesforce Sales Cloud instance, we suggest that you test Shopify out using the API docs. Click Test in the API docs, open GET /customers
, click Try it out, and then click Execute. The response body includes all of the contacts in your Salesforce account.
With two authenticated instances, you're now ready to map the Salesforce /contacts
object and the Shopify /customers
object to a common resource that you define and that contains only the data you want.
To move a contact from Salesforce to Shopify, we need to map the Salesforce /Contact
object and the Shopify /customer
object to a common resource: A stand-alone resource, created and defined by a user with the intention of creating a one-to-many transformation. We'll help you set up a common resource below, but if you want more information take a look at Defining Common Resources & Transformations.
To define a common resource:
On the Common Resources page, click Create New Common Resource.
The Create page shows your new Common Resource with a default organization-level field of id.
Enter a name for your common resource, such as "myContact" for a resource to map multiple types of contacts or customers to.
Add additional fields: In the Organization Level Fields section, click .
In Field Name, enter Email
.
Repeat to create the following fields:
Last Name
First Name
Click Save.
Your myContact common resource should look like the example below. Notice that you can now create a transformation on the right side of the page. We'll do that next in Map and Transform Salesforce Contacts.
Now that you created a common resource, you'll map fields in the Salesforce /Contact
object to the common resource. After you map the fields, Cloud Elements transforms the data from Salesforce to match the fields in the common resource.
To map fields and transform the data:
Click Create New Transformation for "myContact".
The two authenticated element instances that you created in Step 1 appear on the left side of the list.
Click Salesforce Contacts.
The Salesforce resources — or objects — available to you appear on the right side. Salesforce has many resources, but instead of scrolling through the list we'll search.
In Search type contact
.
Click the Contact resource in the list.
Back on the Transformations page you see the fields in the myContact
common resource on the left and empty fields to map on the right.
In the first empty field type email
. The list filters the fields until you can select the Email field, like the example below.
Repeat to map the following fields:
First Name
map to FirstName
.id
map to Id
Last Name
map to LastName
Your mapping should match the the example below:
Click Save.
To be able to test the mapping and transformation in the API docs, switch the API docs on: Click , switch on Add to API Docs, and then click Save.
Test it out: Click .
On the Transformed tab, you see a payload with just the fields that you defined in the common resource.
As a comparison, click Original to see the payload before Cloud Elements transformed it.
Click Cancel to return to the Transformations page.
Now that you mapped the Salesforce /Contact
object to your myContacts
common resource, let's map the Shopify /customers
resource.
To map the fields in the Shopify /customer
object, we just need to repeat the steps that you just completed for your authenticated Shopify instance.
To map fields and transform the data:
From the Transformations page with the mapped Salesforce Contacts instance, click /myContact in the My Resources list.
The Salesforce Contact instance that you just mapped appears in the Mapped Transformations section.
Click Create New Transformation for "myContact".
This time, click the Shopify Customers instance on the left, and then locate and select the customer resource on the right.
Map the fields to:
Email
map to email
First Name
map to first_name
id
map to id
Last Name
map to last_name
Click Save.
Switch on the API docs: Click , switch on Add to API Docs, and then click Save.
Test it out: Click .
Like the Salesforce element, your response includes only the fields defined in your common resource.
In Cloud Elements you can build formula templates — reusable workflow templates that are independent of API providers. Formula templates include triggers, like events or schedules, that kick off a series of steps. Formulas support a large variety of different use cases across different services. For example, they can keep systems in sync, migrate data between systems, or automate business workflows.
For this tutorial, you'll create a formula template that:
Before we start, it's important to understand the difference between a formula template and a formula instance. The template defines how the formula works regardless of variables like the kind of element or a user input. With formula instances you plug actual values into the variables in the template. With this approach you can plug different element instances into the formula so you can sync contacts with Hubspot, Woocommerce, Zoho, Etsy, Magento, or any of our elements.
If you want to see a completed formula template for comparison, download our sample copy, and then import it.
The trigger used in a formula template is the action that kicks off the formula. You can set up triggers for events, scheduled jobs, API requests to elements, and manual triggering. Variables can represent authenticated element instances or values. When you actually run a formula by creating a formula instance, you replace the variables with actual authenticated element instances or values.
For this tutorial, the trigger will be based on an event — when a new contact is created in Salesforce. The variables will represent the Salesforce Sales Cloud and Shopify element instances that you created earlier.
To set up triggers and variables:
On the Formulas page, click Build New Formula Template.
You can build formula templates based on existing templates or by importing a JSON file that defines the template. For this tutorial, you will build the formula template from scratch. However, if you want to test your formula with ours, download our copy, and then import it later.
Click Build New Formula.
Enter a name for your formula like "Sync Contacts", and then click Create.
Cloud Elements provides you a list of triggers. Triggers define how the formula starts. Because we want to automatically sync contacts when our event framework discovers a new /Contact
, we'll use an Event trigger. When new or updated contacts appear in Salesforce, our Event framework builds a payload that can trigger a Formula.
Click Event.
As mentioned earlier, formula templates consist of variables. The variables can represent authenticated element instances or values. In this formula, the variables will represent the two element instances that you authenticated earlier. Because you have not yet created a variable you need to create one to represent the element that kicks off the formula.
Click the add button .
On the Formula Variables window, click Add New Variable, and then click Element Instance.
Name the variable that represents the element that kicks off the template OriginInstance. In our example, this will be Salesforce Sales Cloud.
The variable should look like the example below:
Click Save.
Select the variable that you just created OriginInstance, and then on the Edit event: "trigger" window click Save.
Now add a variable for the element that gets updated when a contact is created (Shopify): Click Variables in the menu bar.
Click Element Instance.
Name the variable DestinationInstance, and then click Save.
At this point you built a template based on an Event trigger with two variables to represent the origin and destination elements. Next, add the steps needed to perform the sync.
In addition to triggers and variables, formula template include steps that represent actions that the formula needs to take to accomplish its goal. At the end of every step, the formula can follow an On Success or On Failure path. For this tutorial, all steps will follow the On Success path. The steps we'll add include:
To add steps:
Under the trigger click .
You can use many different kinds of steps in a formula. Because we're going to write some logic to make sure that the event we receive is for a created contact, we'll use the JS Script step type.
Click JS Script.
Enter a name for the step like "IsCreateContact".
In the code area, enter the following, and then click Save.
let theEvent = trigger.event.eventType;
let theObject = trigger.event.objectType;
done((theEvent === 'CREATED') && (theObject === 'Contact' || theObject === 'contact'));
Now add the next step to retrieve the created contact from the element represented by the OriginInstance
variable — Salesforce Sales Cloud. Click the IsCreateContact step that you just created, and then click Add OnSuccess.
This time select the Element API Request step type. With this type of step, you need to identify the element variable to request and what the endpoint should be.
In the Add Formula Step window, enter the name for the step: "RetrieveContact".
In Element Instance Variable click , and then select OriginInstance.
In Method, select GET.
In API enter /hubs/crm/myContact/${trigger.event.objectId}
. This is the endpoint of the Common Resource that you created earlier.
${trigger.event.objectId}
refers to the context of the formula. When a trigger receives the event payload, it includes data that you can manipulate. In the case, we are creating a request to get the payload returned by an event with a specific objectId
. Also see that the API request endpoint is the common resource that we created earlier, so only the data we care about will be posted to Shopify.Click Save.
Now create the final step, which is posting the created contact to the element represented by the destination variable — Shopify. Create another Element API Request with the information below:
Field | Value |
---|---|
Name | CreateContact |
Element Instance | config.destinationinstance |
Method | POST |
API | /hubs/ecommerce/myContact |
Body | steps.RetrieveContact.response.body Note: Click Show Advanced to find the Body field. This also uses the context of the formula to look in the response to the RetrieveContact step to compose the body of its own request. |
|
You are almost done. Now we just need to create and run a formula instance to see the actual sync occur.
The formula instance actually performs the sync. In this case we're going to associate the Salesforce Sales Cloud element instance with the OriginInstance
formula variable, and Shopify with DestinationInstance
. Whenever you create a new contact in Salesforce, the Cloud Elements poller recognizes that an even occurred. The trigger for the formula kicks off when an event occurs at the element in the OriginInstance
variable, which then kicks off the logic in the formula.
To create a formula instance:
OriginInstance
, and then select the Salesforce instance that you authenticated earlier — Salesforce Contacts.ClickDestinationInstance
, and then select the Shopify instance that you authenticated earlier — Shopify Customers.
You're formula instance should look like the example below.
Click Create Instance.
Congratulations! You created your first integration. Email documentation@cloud-elements.com if you have any feedback on this tutorial.