It can be thrilling and intimidating to start the process of integrating your business systems and data, especially when you are just starting the process. Workato is one of the integration platforms that can really make this journey an easy and straight-forward one. In this Workato step-by-step tutorial, we will walk you through the steps of developing your first Workato integration. This tutorial will guide you through every step of the integration development process, from setting up the connectors to orchestrating data flow and automating the critical process activities. You will notice how easy it is to work with Workato, even if you are not an IT specialist or a developer.
Our use case in this article will be synchronising Salesforce accounts to Shopify customers. The idea is that we’ll read all account data from Salesforce that has been updated since our last integration run, and upsert those records as Shopify customers. We’ll focus on the build part here, then, in future articles, we’ll cover other topics such as troubleshooting, scheduling, production deployment, monitoring, etc.
We have previously implemented the same scenario using Celigo. If interested to know how to do that, check out our Celigo step-by-step tutorial article.
Creating a Project
Before we create our integration, or recipe, as called in Workato’s terminology, we’ll need to create a project, which acts as a container for one or more recipes. To do that, we’ll need to log in into the platform and click “Create Project” on the home screen
Provide a name & description for the project and click “Create Project”
Creating the Recipe
Now that the project container is created, let’s start by creating our recipe. In the project space, click “Create” then “Recipe” from the drop-down that appears
Provide a name & description for the recipe, and keep the starting point as “Trigger from an app”. We can change the trigger at any time in the future if we want to run it on a schedule basis or expose it as an API. For now, let’s keep it as is.
Configuring the Trigger
As explained in the previous introductory article about Workato, a recipe consists of a trigger, and a set of actions. The trigger is the first step of the recipe and defines how the recipe starts. In this article, we’ll define the trigger to retrieve all new/updated records from Salesforce since the last execution of the recipe. To do that, follow the below steps:
- Click on the trigger step and type salesforce in the search box to filter for the Salesforce trigger
- Select the “New/updated records” trigger among the list of available triggers. Feel free to check other triggers to get an idea of what other triggers you could use for other scenarios
- If this is the first time to connect to Salesforce, then establish the connection, else, you can just select a previous connection
- Click “Connect” and you’ll be prompted with a login screen to establish the OAuth2 connection.
- Now that the connection is established, the last step is to configure what we want to do when the trigger occurs, and that happens in the next screen. First, we’ll need to select “Account” in the Object field, because we want to retrieve the list of accounts newly created or updated. Then we’ll need to select which fields to retrieve in the “Fields to retrieve” field. We can also define a where clause in the SOQL field, a max batch size, what to retrieve on the first run, and trigger conditions.
Configure the Actions
Now that we have a list of newly created or updated accounts, we’ll need to retrieve additional fields for each one of them because Shopify requires those fields. In the next steps, we’ll see how to run such a loop, retrieve the first name, last name, and email from the Account’s associated contact, and then create the customer in Shopify. Let’s go.
- Hover under the Actions label until you see the “+” sign, click it to be represented with a list of action types of what you want to happen next. Select “Repeat action”, which allows us to loop over a list of records
- Select the “Accounts” data pill from the output of the previous step. This is a list containing previously exported accounts. You can notice it’s a list from its icon of horizontal lines
- Next is to populate what happens inside the loop. First step is to go back to Salesforce and retrieve the additional fields from the contact object. Click on the action inside the loop and select Salesforce
- Select “Search Records” as an action
- Select “Contact” in the “Search for” field, chose “First Name”, “Last Name”, and “Email” as the fields to retrieve, and chose the “Account Id” from the previous action to filter for the contact who has account id equals to the retrieved account id
At this stage, all data we need is retrieved from Salesforce. Next we’ll need to connect to Shopify and create/update customers there. What we are going to do here is first search if the customer exists in Shopify, we’ll use the email field as the unique identifier. If the customer exists, then update it, else, create it. - Hover under the Salesforce search action until the “+” sign appears, click it and select “Action in an App” option
- Select Shopify as the app to connect to
- Select “Search Customers” as the action
- Next is establishing a connection to Shopify, or selecting an existing connection if you have previously done this step. Select “Access Token” as the authentication type, enter your access token, your shop name, and click “Connect” to establish the connection
For more information on how to create your access token in Shopify, please follow this link. - Lastly, define what do we want to search by, which is the email field retrieved in the previous Salesforce step
- Now that we have searched for the customers in Shopify, we need an if/else condition to determine if we want to update an existing customer, or create a new one. Let’s do that as follows
- Define the condition of the If statement based on the search results size, if the output list size is greater than 0, as follows
- Under the IF statement scope, let’s create an action to update Shopify customer in question
- Populate the fields as shown below
- Repeat a similar steps to configure the add customer action
- The recipe should look like the snapshot below now
Test
Now that the recipe is completed, it’s time to test. Before doing that, let’s have a look at the current accounts in Salesforce
And on the current customers in Shopify
Ok, let’s run the recipe by hitting the “Test Recipe” button in the top menu
Note that you should get an exception as follows.
This is expected because one of the account contacts doesn’t have an email address defined. To solve this problem, let’s add an IF condition before the Shopify actions, this allows us to skip calling Shopify if the Salesforce contact is missing the email address.
As depicted above, we have added an IF condition, set the condition to check for the email address presence, then moved all Shopify actions to go under this IF condition.
Finally, test again and confirm that the recipe ran successfully
Verify the customer in Shopify to make sure everything got inserted successfully
Conclusion
Congratulations on completing your first Workato integration! In this Workato step-by-step tutorial, we have created our first recipe in Workato which integrates Salesforce and Shopify. We have only covered the build and test aspect. We’ll cover other concerns in future articles, such as deployment, monitoring, detailed troubleshooting and error handling. Beware, the journey of integration in Workato has just begun. So, let’s embrace innovation and thrive in the connected business world with the help of Workato!
Pingback: APIs in Workato
Pingback: Recipe Functions in Workato