Open Navigation

Shopify

Shopify is an E-commerce platform for online stores and retail point-of-sale systems.

Overview

The Shopify connector currently provides operations to manage orders, fulfilments and customers in your shop be it online, on social media, or in person.

Authentication

When using the Shopify connector, the first thing you will need to do is go to your Tray.io account page, and select the workflow you wish to work on. Once in the workflow dashboard itself, search and drag the Shopify connector from the connectors panel (on the left hand side) onto your workflow.

With the new Shopify connector step highlighted, in the properties panel on the right, click on 'New Authentication' which is located under the 'Settings' heading.

shopify-auth

As of v1.2 the Shopify connector uses OAuth as its authentication method.

So when you click on 'New Authentication' you will be presented with the following screen, where you can specify the domain of your store, and the permission scopes you want the Tray.io app to have.

shopify-con-trig-auth

Your domain name is displayed in the URL of your main Shopify dashboard. For example, if "west.shopify.com" and "east.shopify.com" are both URLs with the root domain "shopify", this means that "east" and "west" are the SUBDOMAINS.

Copy yours over and make sure you set you permission scopes as appropriate. There are several scopes to choose from so make sure to scroll through to view them all.

IMPORTANT: Please make sure that the account you are authenticating with has the corresponding permission scopes else this will not authenticate properly!.

shopify-auth-permissions

Once you click 'Next', you will be presented with a popup login screen for Shopify and to enter your access credentials - provided you are not already logged into your Shopify account.

If you are using v1.1 or earlier, your popup will be different, and as you can see, besides from naming your authentication appropriately, you will need your 'API key', 'API Password' and 'Shop subdomain'.

shopify-auth-v1

In order to get these, first log into the Shopify app and head to the admin section; choose "Apps". Click on "Manage private apps" (near the bottom of the page).

shopify-auth-v1-manage-apps

Then click on "Create a new private app".

shopify-auth-v1-create-new

In the "App details" section, enter a name for the private application and a contact email address as appropriate.

Within the "Admin API" section, select the areas of your store that you want your app to be able to access. Click "Save".

You should now see the 'API key', 'API password' and your 'Shop subdomain' name (in the "Admin API" section).

shopify-auth-v1-api-creds

Copy these pieces of information and paste them into your Tray.io auth window as displayed earlier, including your subdomain name. If your shop URL is: https://traytest-123.myshopify.com, you will enter traytest-123 as you subdomain.

Once you have clicked the 'Add authentication' button, go to back to your authentication field (within the workflow dashboard properties panel from earlier), and select the recently added authentication from the dropdown options now available.

Your connector authentication setup should now be complete.

Shopify Trigger

If you wish your workflow to be kicked off by a particular action in Shopify, you can use the Shopify Trigger.

The Shopify trigger allows you to receive notifications and trigger workflows when given events occur associated with the selected trigger operation.

Trigger operations available:

  • GDPR Webhook
  • Webhook

Webhook Setup

When creating a new workflow, click the 'Create new workflow' button in the top right hand corner of your main Tray.io dashboard. When the trigger popup window opens, search and select the Shopify trigger. Wait to be redirected to your new workflow and the workflow dashboard itself.

shopify-select-trigger

With the new Shopify trigger step highlighted, in the properties panel on the right, click on 'New Authentication' which is located under the 'Settings' heading.

shopify-auth-new

This will result in a Tray.io authentication pop-up window, that should look like this:

shopify-con-trig-auth

As of v2.0 the Shopify connector uses the same OAuth authentication method as the standard Shopify connector (version 1.2+).

Follow the instructions above in the v1.2+ authentication tab to set up your trigger, and select 'Webhook' as the event you want your trigger to listen to (aka the operation), in order to set off the workflow itself.

As this uses a webhook as its operation type, besides from naming your authentication appropriately and clicking the 'Add authentication' button etc, you will also need to integrate it with your Shopify account, in order to complete the authentication process fully.

First get your Tray.io Public URL for the workflow by clicking on the settings wheel in the top left of the build screen, and copying it from the settings window:

shopify-workflow-url

Then head to your Shopify account settings, and click on notifications:

shopify-settings-notifications

Scroll all the way to the bottom of your notification options until you see a heading called "Webhooks". Here you will have the option to create a new one, whcih you do by pressing the "Create new" button on the left.

shopify-settings-webhooks

The settings should be up to date, and all you need to do is add in the Tray.io public url which you copied and saved from earlier before clicking "Save webhook":

shopify-settings-save-webhook

The best way to confirm if you webhook is set up correctly is by sending a text notification to your new webhook. Do this by first making sure your workflow is already ENABLED in the Tray.io builder else the notification will not register (check the button in the lower right hand corner).

Back in your Shopify webhooks section, if you look to the right of your new webhook, you should see the option for "Send test notification" (as displayed in the image earlier).

Shopify GDPR webhooks

Shopify have three webhooks specifically designed to help with GDPR compliance. However, they work differently to other webhooks, and so can be found under a separate operation: GDPR Webhook.

This operation will be triggered when:

  • Customer data has been requested.
  • Customer data has been erased, following a request.
  • Your account has de-authorised Tray.io.

You can choose to subscribe either to all three topics at once or to an individual one:

shopify-gdpr-op

Unlike the main Webhook operation, you do not need to setup subscriptions in the Shopify Admin UI. As long as the trigger is configured properly and enabled, the webhooks will be sent.

Trigger operations available:

  • On webhook

Webhook Setup

When creating a new workflow, click the 'Create new workflow' button in the top right hand corner of your main Tray.io dashboard. When the trigger popup window opens, search and select the Shopify trigger. Wait to be redirected to your new workflow and the workflow dashboard itself.

shopify-select-trigger

With the new Shopify trigger step highlighted, in the properties panel on the right, click on 'New Authentication' which is located under the 'Settings' heading.

shopify-auth-new

This will result in a Tray.io authentication pop-up window, that should look like this:

shopify-auth-v1-2

Follow the instructions above in the v1.1 or earlier authentication section to authenticate with your trigger also, and select from the operation options 'On Webhook', in order to set off the workflow itself.

The only difference between this popup and the connector is that there is an added section called: 'API Secret'. You can find this is the same section as your other API Shopify auth details (in the "Admin API" section of your "Apps").

Note that 'API Secret' and "Shared Secret" mean the same thing in this case.

Add this to your trigger Tray.io authentication window.

Next, go and get your Tray.io Public URL for your workflow by clicking on the settings wheel in the top left of the build screen, and copying it from the settings window:

shopify-workflow-url

Then head to your Shopify account settings, and click on notifications:

shopify-settings-notifications

Scroll all the way to the bottom of your notification options until you see a heading called "Webhooks". Here you will have the option to create a new one, whcih you do by pressing the "Create new" button on the left.

shopify-settings-webhooks

The settings should be up to date, and all you need to do is add in the Tray.io public url which you copied and saved from earlier before clicking "Save webhook":

shopify-settings-save-webhook

The best way to confirm if you webhook is set up correctly is by sending a text notification to your new webhook. Do this by first making sure your workflow is already ENABLED in the Tray.io builder else the notification will not register (check the button in the lower right hand corner).

Back in your Shopify webhooks section, if you look to the right of your new webhook, you should see the option for "Send test notification" (as displayed in the image earlier).

Basic Operations List

Full list of operations can be found HERE

  • Cancel fulfillment
  • Close order
  • Create product image with image URL
  • Delete product variant
  • Get Location inventory levels
  • Update customer

Using the Raw HTTP Request ('Universal Operation')

As of version 2.0, it is now possible to effectively create your own operations.

This is a very powerful feature which you can put to use when there is an endpoint in Shopify which is not used by any of our operations.

To use this you will first of all need to research the endpoint in the Shopify API 2020-01 documentation, to find the exact format that Shopify will be expecting the endpoint to be passed in.

Note that you will only need to add the suffix to the endpoint, as the base url will be automatically set (the base url is picked up from the value you entered when you created your authentication).

The base url is in the format of https://{{YOUR-SUBDOMAIN}}.myshopify.com/admin/api/

For example, say that the 'Get customer' operation did not exist in our Shopify connector, and you wanted to use this endpoint, you would use the Shopify API docs to find that the 'Get customer' endpoint is a get request at the following url:

shopify-get-url

So if you know what your customer ID is, you can get the customer details with the following settings:

shopify-raw-http

Final outcome being: https://{{YOUR-SUBDOMAIN}}.myshopify.com//admin/api/2020-01/customers.json?since_id=123456789

As a result, this will return your singular customer's details.

Example usage

TRAY POTENTIAL: Tray.io is extremely flexible. By design there is no 'fixed' way of working with it - you can pull whatever data you need from other services and work with it using our core and helper connectors. This demo which follows shows only one possible way of working with Tray.io and this connector. Once you've finished working through this example please see our Introduction to working with data and jsonpaths page and Data Guide for more details.

Below is an example of a way in which you could potentially use the Shopify connector, to use the 'Search customers' operation and specify orders_count:0 into the 'Query' property. I.e: to search for customers that haven't ordered anything on your shop.

Additionally, you can specify only a set of fields that should be in the output by adding them in the 'Fields' property such as id, name.

The steps will be as follows:

  1. Set up Shopify trigger and boolean branch.
  2. Add a Slack connector notification step.

The final outcome should look like this:

shopify-complete-workflow

Please note that this is a very simplified example - you would normally use the data to update a record in Salesforce, or something similar.

1 - Setup trigger & Boolean branch

Once you have clicked 'Create new workflow' on your main Tray.io dashboard (and named said new workflow), select the Shopify trigger from the trigger options available:

shopify-select-trigger

Make sure you have set up your trigger as explained depending on the version you are using, before going any further.

Once you have been redirected to the Tray.io workflow dashboard, from the connectors panel on the left, add a Boolean connector to your second step. Set the operation to 'Boolean condition'.

If you have used the 'Send test notification' option, from the admin section in your Shopify webhook dashboard (as detailed earlier in the trigger section above), you should have gotten an output similar to the below:

This is viewable in the Debug panel under your step output.

shopify-test-output

The data sent by the Shopify webhook can be extracted and used with a jsonpath beginning with either $.steps.trigger.topic or $.steps.trigger.data.[field].

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with Tray.io, please see our Intro page and Data Guide for more details.

You can achieve most of this path by using the connector-snake to save you time and effort.

CONNECTOR-SNAKE: The simplest and easiest way to generate your jsonpaths is to use our feature called the Connector-snake. Please see the main page for more details.

In our case we will create a boolean branch to check if the user accepts marketing, by setting the comparison type to 'Equal to' and the second value to 'The 2nd of 2 values to compare'.

Take special notice of the Input types! if they are net set correctly, your condition will fail.

shopify-boolean

2 - Add a Slack notification

Add a Slack connector step to your workflow on the TRUE branch. Set up your auth and set the operation to 'Send message'.

Choose your channel, and then use Tray.io's interpolation method to have your result displayed in the message output.

Note the use of { } to input the result of the jsonpath in to a string field

INTERPOLATION: When you wish to include JSON generated data within another input/ output/ result, use our Interpolation method as described here.

shopify-slack

Now, whenever the boolean branch returns a TRUE result, a notification message will be sent to this particular Slack channel, to let people know that a user (as identified by their email address) has accepted the marketing material.

BEST PRACTICES: Whenever you do decide to use create your own workflow, please make sure you take a look at our Managing data best practices guide.

Was this article helpful?
Yes
No