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

# Tray.io

> Learn how to integrate MoEngage with Tray.io to automate complex workflows, trigger actions using Webhooks, and seamlessly sync data across your cloud stack.

# Introduction

[Tray.io](https://tray.io/) is an integration platform that allows organizations to easily automate complex processes through a powerful, flexible platform, and connect their entire cloud stack thanks to APIs.

# MoEngage × Tray.io

The MoEngage and Tray.io integration allows you to easily send data between MoEngage and other apps using custom logic and code functions. With this integration, you can -

1. Use MoEngage as a trigger on Tray.io via our Connector campaigns
2. Send data from Tray.io to MoEngage using our Data APIs

## Use Cases

1. When an event occurs in MoEngage, add a new row in Google Sheets.
2. Import users from HubSpot Leads into MoEngage.
3. Send a Slack message when a user performs an event.
4. Import events into MoEngage from a WebHook setup in Tray.io.

# Integration Prerequisites

* Ensure you have access to your Tray.io account.
* Ensure you have access to Data API keys in MoEngage Dashboard.
* The Data API ID and Data API Key are available at **Settings** -> **Account** -> **APIs**. The Data API ID is the same as the **Workspace ID.** The Data API Key is available on the same screen in the **API Keys** -> **Data** section.

## Use MoEngage as a Trigger

You can make use of MoEngage's Connector Campaigns to use MoEngage as a trigger.

### Step 1: Add Webhook as a Trigger on Tray.io

1. On your Tray.io Dashboard, click on "+ Add workflow" >> "From scratch" to create a new workflow.
2. Give your workflow a name and fill out other details.
3. In Step 2, select "Webhook" under the section "Through an internal trigger".

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15169876373396.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=4906c34c35d33e231f144e3c2b67ce01" alt="Step-1-Webhook-Trigger.png" width="1848" height="1464" data-path="images/partner_15169876373396.png" />

4. Click on "Create workflow" to begin.
5. In the Workflow Editor, click on the three dots menu next to the trigger >> "Copy public URL".

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15169978407700.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=b68d511af471fee4e9dc4cfa30b9d957" alt="Step1-Trigger-Dashboard.png" width="2880" height="1642" data-path="images/partner_15169978407700.png" />

6. This Public URL will be the endpoint to set up in MoEngage Connector Campaign.
7. Click on "Enable workflow" at the bottom to make this URL live.

### Step 2: Setup the Connector Campaign in MoEngage Dashboard

1. Navigate to MoEngage Dashboard.
2. Use any one of the following options:
   1. On the **All Campaigns** page, click **Create Campaign**.\
      The Create Campaign page is displayed.
      <img src="https://mintcdn.com/moengage/7iGV38YjgdBKSU0B/images/partner_22018437263764.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=9558055ef2cd5ac99d165e4d959334ce" alt="CreateCampaign_RightNav.png" width="1914" height="946" data-path="images/partner_22018437263764.png" />
   2. Click **Create New** > **Campaign**.\
      The Create Campaign page is displayed.
      <img src="https://mintcdn.com/moengage/7iGV38YjgdBKSU0B/images/partner_22018437265684.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=c78e04e0e3b7b3093dd4389a25e7f3af" alt="CreateCampaignLeftNav.png" width="1920" height="947" data-path="images/partner_22018437265684.png" />
3. Click **Custom** under Connectors.
4. For the campaign delivery types, choose "Event-Triggered".
   * For more information about delivery types, refer to [Delivery Types](https://www.moengage.com/docs/user-guide/campaigns-and-channels/getting-started/introduction/delivery-types-moengage-channels).
5. On the next screen, give your Campaign a name, and select the Criteria as "Device Uninstall".
6. For the trigger, choose "immediately".

<img src="https://mintcdn.com/moengage/7iGV38YjgdBKSU0B/images/partner_22018437268756.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=30cc8bfc768dc09cd0ae600bcfe89414" alt="UseCase2-Step3.png" width="2468" height="850" data-path="images/partner_22018437268756.png" />

7. For the audience, let us choose "All users" for this use case. Click "Next" when satisfied.
8. On the content screen, we will define our payload and webhook URL we got from the previous step.
9. Choose the method as "POST" (know more about Tray.io [Webhook Trigger](https://tray.io/documentation/connectors/triggers/webhook-trigger/)).
10. Enter the webhook URL (Public URL) you copied earlier.
11. Define the headers and parameters as per your requirements. For this use case, we will just define our payload body- (you can type @ to insert personalized values as well)

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15170107931156.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=c83afa083fe54b9898313b7a08e952a0" alt="Step-2-ConnectorCampaign.png" width="2880" height="1642" data-path="images/partner_15170107931156.png" />

12. Now you need to test this webhook, scroll down and enter a test user's data and click on "test".
13. You should see a new modal saying the test was successful:

<img src="https://mintcdn.com/moengage/7iGV38YjgdBKSU0B/images/partner_22018397365652.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=83f9f4c654244be245b29212ad08e89d" alt="UseCase2-Step5.png" width="1220" height="466" data-path="images/partner_22018397365652.png" />

### Step 3: Test the trigger on Tray.io

1. Now go back to the Tray.io Workflow editor. Open the "logs" tab from the top.
2. On the left sidebar, you should see new execution entries from the test you ran earlier.
3. Select an execution entry, and then select "Webhook". Then verify if your data has successfully reached Tray.io:

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15170220514836.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=717a0a79cb8f84acea7f8b12d6fe022d" alt="Step-2-Verify.png" width="2880" height="1642" data-path="images/partner_15170220514836.png" />

4. Once you have verified the data, click on the "Use output" button above the output tab. This will make all fields in your payload available to access in other steps.

<img src="https://mintcdn.com/moengage/W4UIG2ZYu1ajYKNS/images/partner_15170228366740.png?fit=max&auto=format&n=W4UIG2ZYu1ajYKNS&q=85&s=5af942611acb263f7de802776f9c1866" alt="Step-2-Output.png" width="2072" height="1470" data-path="images/partner_15170228366740.png" />

5. In the next steps, type `{$` to open up the interpolation dropdown. Select the fields you want to map from the trigger step. Read about [working with data.](https://tray.io/documentation/platform/working-with-data/basic-data-guide/#working-with-data-and-jsonpaths)
