> ## Documentation Index
> Fetch the complete documentation index at: https://partner-integrations.voyado.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Shopify Flow with custom triggers

Shopify Flow is an e-com automation platform that you can use to automate tasks and processes within your Shopify store and across your apps. Shopify Flow monitors your store for events and lets you create a sequence of actions that are taken in response. You can automate tasks and processes within your store and across your apps by creating workflows using triggers, conditions, and actions.

Using Shopify Flow's “Send HTTP request“ action, you can trigger a marketing automation in Engage and build user journeys based on the various customer activities in Shopify.

This example looks at how to synchronize selected customer tags from Shopify to Engage and link them to a contact. By configuring a custom trigger in Engage and invoking that trigger within Shopify Flow, you will be able to associate tags as labels in Engage.

## Configuration in Engage

Follow these steps:

<Steps>
  <Step title="Log into Engage and go to Config Hub">
    Config Hub is found under **Administration** on the left-hand menu in Engage.

    <Card title="See where to find Config Hub" href="https://help.engage.voyado.com/hc/en-gb/articles/21844586790940-Finding-Config-Hub" icon="https://mintcdn.com/voyado-partners/0IxEIB2Y6a--gNYY/icons/help-center-link.png?fit=max&auto=format&n=0IxEIB2Y6a--gNYY&q=85&s=4e7f518f776580d7cdae461a964ea2dc" horizontal width="128" height="128" data-path="icons/help-center-link.png" />
  </Step>

  <Step title="Create custom trigger">
    Go to the **Custom Triggers** page and create a new custom trigger with the values you need. For example:

    * Name: “Gender - Shopify tags”
    * TriggerId: “genderTags“
    * Description: “Set gender labels in Voyado Engage“
  </Step>

  <Step title="Add new field">
    To your new custom trigger, add a new field. For example:

    * Name: “gender"
    * Description: “Gender“
  </Step>

  <Step title="Save the trigger" />

  <Step title="Create a new automation" />

  <Step title="Enable custom trigger ">
    Pick the custom trigger you just created from the list of triggers
  </Step>

  <Step title="Add a value split">
    Add a value split in your automation
  </Step>

  <Step title="Input expected values">
    Input the expected values coming from Shopify Flow and select “Ok”.
  </Step>

  <Step title="Set the label">
    Add a “Set label“ activity in each leg of the split
  </Step>

  <Step title="Activate">
    Now activate the automation.
  </Step>
</Steps>

<Frame>
  <img src="https://mintcdn.com/voyado-partners/KvDepjP7QxlhSY95/images/shopify/shopify-flow-01.png?fit=max&auto=format&n=KvDepjP7QxlhSY95&q=85&s=ec469a7980a7153badc2f4a0e2e616e5" alt="shopify-flow-01" width="3441" height="859" data-path="images/shopify/shopify-flow-01.png" />
</Frame>

## Configuration in Shopify

Follow these steps:

<Steps>
  <Step title="Create new flow">
    Create a new flow in Shopify Flow
  </Step>

  <Step title="Choose trigger">
    Choose a trigger (for example: “Customer tags added”).
  </Step>

  <Step title="Add action">
    Add the action “Flow” > “Send HTTP Request“
  </Step>

  <Step title="Choose method">
    Choose POST as the HTTP method.
  </Step>

  <Step title="Input Request URL">
    Input the Request URL listed below in the URL field. Be sure to replace “\[tenantId]“ with the actual name of your tenant.
  </Step>

  <Step title="Add headers">
    Add the request headers as shown in the section "Request headers" below. Remember to replace the value of *apikey* with your actual API key, which you can find via the [Config Hub](https://help.engage.voyado.com/hc/en-gb/articles/23405185859228-API-connections)
  </Step>

  <Step title="Add body">
    Add the body and loop through the tags you want to send over to Engage. Remember to change the name of the “gender“ field to something more relevant if you are syncing tags that are not related to this specific use-case.
  </Step>

  <Step title="Activate the automation" />
</Steps>

<Frame>
  <img src="https://mintcdn.com/voyado-partners/KvDepjP7QxlhSY95/images/shopify/shopify-flow-02.png?fit=max&auto=format&n=KvDepjP7QxlhSY95&q=85&s=82016380da55577f1b29620f51969eb4" alt="shopify-flow-02" width="1523" height="1296" data-path="images/shopify/shopify-flow-02.png" />
</Frame>

### The request URL

This URL triggers the custom trigger endpoint by using the Shopify ID which is linked to the *externalId* field in Voyado Engage.

```http theme={null}
https://[tenantId].voyado.com/api/v2/automation/customTriggers/[TriggerId]/triggerByExternalContactId/{{customer.id | remove_first: "gid://shopify/Customer/"}}
```

Remember to replace the \[tenantId] and \[TriggerId] in the URL with your values.

### The request header

*apikey: 00000000-0000-000-000000000000*

*Content-Type: application/json*

### Payload body in Shopify Flow

The request payload loops through all the tags of a customer in Shopify and checks for a matching tag defined in the payload.

The for-loop code example below checks if a customer has any of the tags: “Male“, “Female“ or “Other“ and sends it through to Engage as "gender":

```liquid theme={null}
{
"gender" : "{%- for tags_item in customer.tags -%}
  {%- if tags_item contains "Male" -%}
    {{tags_item}}
  {%- elsif tags_item contains "Female" -%}
    {{tags_item}}
  {%- elsif tags_item contains "Other" -%}
    {{tags_item}}
  {%-endif -%}
{%- endfor -%}"
}
```

The code example above results in a request payload to Engage that looks like this:

```json theme={null}
{
"gender" : "Female"
}
```
