Logic Apps: Create a Shopify Custom Connector

Author:

Azure Logic Apps & Shopify

Azure Logic Apps does not have a have premium connector for Shopify (yet). In the meantime, setting up a Shopify custom connector for Azure Logic Apps is a relatively simple process.

However, the Shopify API documentation is developer focused and translating to a custom a custom connector could be confusing for those new to low-code work. This blog will take you through the process step-by-step to ensure that your custom connector deployment goes smoothly.

Before we begin, ensure you have the following:

  • Admin access to a Shopify instance
  • Access to create resources in a resource group in Azure

Once you have those two things, you can proceed to the next section.

Creating a Shopify App

The first step in creating a Shopify App is to navigate to the admin portal for your Shopify store and look for the navigation blade on the left-hand side:

Shopify admin navigation

 

You will need to expand the grouping labelled ‘Apps’:

Shopify admin blade with apps outlined

That opens this pop-up:

Select ‘App and sales channel settings’:

Shopify apps with app and sales channel settings outlined

 

Thiswill navigate you to the Apps and sales channels page. Subsequently, select ‘Develop Apps’:

Shopify Apps and Sales Channel Settings with develop apps outlined

 

On the App development page, select ‘Create an app’

Shopify app development page with create an app outlined

 

A popup prompting you for your app’s name and the app developer will appear:

Shopify Create an app screen

 

Populate them appropriately and select ‘Create app’.

Shopify Create an app screen with create app outlined

 

As a result, you will be on the overview page for your newly created app. In this example, we will create a custom connector that retrieves products from Shopify. To accomplish this we will select the ‘Configure Admin API scopes’ button on the overview page:

Shopify app development overview page with 'Configure Admin API Score' button outlined

 

This brings us to a list of the scopes that we will filter to ‘product’ and select ‘read_product_listings’:

Shopify scopes filtered to product and read_product_listings outlined

Pro Tip: If you wish to broaden the scope of your custom connector to read different sets of data or write to Shopify, now is the appropriate time to do that.

 

Finally, select ‘Save’ to save your changes:

Saving the shopify app

 

Subsequently, navigate to the API credentials tab:

Shopify API Credentials Tab

Then, you will select Install app:

This is going to grant you an Admin API Access Token that will act as the password in our basic authentication:

You can reveal the token and store it somewhere safe and accessible.

 

There is also an API key and secret key. We will only need the API Key:

 

Deploying a custom connector resource

Azure offers multiple paths to creating resources (CLI, Bicep, ARM templates, portal/wizard). For our purposes, we will utilize the Azure portal to create a custom connector. Navigate to your preferred resource group in Azure and select ‘create’.

Azure Resource group

 

This brings us to the Azure Marketplace where we will search ‘Custom Connector’ and we will select ‘Create’ for the Logic Apps Custom Connector which brings us to the resource provisioning wizard:

Azure Logic App Custom Connector Creation

 

Logic App Custom Connector Creation Wizard

 

Once you are happy with the settings, select ‘Review + Create’ to deploy the resource to your resource group. Then, select ‘Go to Resource’ and you will be taken to the overview page for your new custom connector.

Azure Logic App Custom Connector go to resource button

 

 

Setting up the Shopify Custom Connector

From our custom connector overview page, select ‘Edit’ to modify the resource in the custom connector wizard:

Edit Logic Apps Custom Connector

 

The wizard starts by having you define an API endpoint type, which is REST:

Azure Logic App Shopify Custom Connector Setup Page 1

 

Next, we can populate general information about our connector:

Azure Logic App Shopify Custom Connector General Information

 

Connector Icon: I used the Shopify’s brand assets to find an appropriate icon and plain white (hex code #FFFFFF) for the background.

Your host is going to be your Shopify URL. For the base URL, you can either leave it blank and include it as part of each individual operation or input /admin/api/.

When you are happy with your settings, progress to the security settings by selecting the ‘Security ->’ button in the lower right hand corner:

 

Azure Logic Apps Shopify custom connector host information

 

The security section allows us to choose the authentication type for our custom connector:

Azure Logic App Shopify Custom Connector Security

 

Select ‘Edit’ and set the authentication to ‘Basic authentication’:

Azure Logic App Shopify Custom Connector Edit Security

 

This section is used to name your username and password parameters. Mine are named as they are labelled in Shopify:

Azure Logic App Shopify Custom Connector Security populated

 

Next, we can select the ‘Definition ->’ button to navigate to the Definition page.

Azure Logic App Shopify Custom Connector Definition Outlined

 

The definition page allows us to add CRUD (create, read, update, delete) actions to our custom connector.

Azure Logic App Shopify Custom Connector Definition

 

We can select ‘New action’ to add our operation:

Azure Logic App Shopify Custom Connector Definition new action

 

This initializes a ‘General’ section where we will fill in descriptive information about our new action:

Azure Logic Apps Shopify Custom Connector New Action General

 

Next, we will scroll down to the Request section and select ‘Import from Sample’

A blade will appear on the right hand side:

 

The URL will be the full URL for the specific resource, following this format:

https://{store_name}.myshopify.com/admin/api/2023-01/{resource}.json

To find the a specific endpoint, refer to https://shopify.dev/api/admin-rest and review the navigation blade on the left-hand side:

 

Navigate to ‘Product’ and select ‘GET Retrieve a list of products’:

 

The URL can be found in the examples on the right:

 

Your URL will look similar to this: https://{store_name}.myshopify.com/admin/api/2023-01/products.json

While you are here, I recommend copying the example response on the right into a notepad:

 

This will allow us to define our action’s response body. Now, navigate back the custom connector wizard and enter your URL in the URL parameter:

 

We want our action to retrieve data, so select GET as your verb. When you are ready, select the ‘import’ button.

 

Then, you can scroll down to the Response section and select ‘Add default response’.

 

A new blade will appear where you can paste in the example body from Shopify’s documentation and select ‘Import’.

 

Finally, ensure you remove the first line from the response: HTTP/1.1 200 OK or you will be unable to import the response.

 

Upon finishing your changes, select ‘Update Connector’ in the top right to save your work:

 

Testing Your Shopify Custom Connector

Firstly, return to your resource group and either edit or setup a new consumption Logic App. In this example, I am using a simple Logic App with a recurrence trigger:

 

Secondly, select ‘+ New Step’ and navigate to the ‘Custom’ tab:

 

Then, populate the connection name, the API Key, and the Admin API Access Token parameters with the values we generated in Shopify and select ‘Create’:

 

Finally, save your Logic App and trigger it in whatever method you please. If done successfully, your Logic App run status will return ‘Success’ and the process will look like this:

Shopify custom connector action in Logic Apps

 

To view the outputs, select ‘Download’ in the Outputs section of the action. Browsers will not natively format the JSON for you, so I suggest you download an extension like JSON Formatter.

Shopify custom connector JSON outputs in Azure Logic Apps

 

To check that your definitions are correct, you can edit your Logic App and add a ‘Compose’ action to view the response values available in the Dynamic content pane:

Shopify custom connector dynamic content in Logic Apps

 

That’s all there is to it! I recommend you add additional procedures from the API and experiment with the responses in your custom connector to achieve the functionality you need.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish