> ## 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.

# Pipedream

# Introduction

[Pipedream](https://pipedream.com/) is a low code integration platform built for developers. With Pipedream, you can build workflows by selecting a trigger (HTTP requests, schedules, app events, and more) and adding one or more steps.

# MoEngage × Pipedream

The MoEngage and Pipedream 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 Pipedream via our Connector campaigns
2. Send data from Pipedream 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 Google Form Leads into MoEngage.
3. Send a Slack message when a user performs an event.
4. Import events into MoEngage from a WebHook setup in Pipedream.

# Integration Prerequisites

* Ensure you have access to your Pipedream 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 in 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 HTTP Webhook Requests as a Trigger

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9580617384084.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=5036f20843251b380ef2295204cc827b" alt="Trigger-Step1.png" width="2880" height="460" data-path="images/partner_9580617384084.png" />

1. Click on "Add a Trigger".
2. Search for "HTTP / Webhook".

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9580666060692.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=0ea4cd1b706da31275d6fb102deb264e" alt="Trigger-Step2.png" width="1826" height="974" data-path="images/partner_9580666060692.png" />

3. Event Data => `Full HTTP Request` HTTP Response => `Return HTTP 200 OK`
4. Click on "Save and continue".
5. A new unique URL to trigger your workflow will be displayed. Save this URL as we will need it to set up the Connector Campaign.

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9580736483732.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=c710d38f06e7ff16d47da17eeed5b466" alt="Trigger-Step3.png" width="1826" height="1076" data-path="images/partner_9580736483732.png" />

### 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_22017108045972.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=8c94bfaa7bf3879a98d22971ae8c0487" alt="CreateCampaign_RightNav.png" width="1914" height="946" data-path="images/partner_22017108045972.png" />
   2. Click **Create New** > **Campaign**. The Create Campaign page is displayed. <img src="https://mintcdn.com/moengage/7iGV38YjgdBKSU0B/images/partner_22017108047124.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=66dc4b8b89e4c97dfb5ddc81ca73fa07" alt="CreateCampaignLeftNav.png" width="1920" height="947" data-path="images/partner_22017108047124.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_22017108048404.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=49c851d915987a8e776b6ff82ab58e9c" alt="UseCase2-Step3.png" width="2468" height="850" data-path="images/partner_22017108048404.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 Pipedream [HTTP Requests](https://pipedream.com/apps/http)).
10. Enter the webhook 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/pjxkCVVFj_C6dGcn/images/partner_9580771591700.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=8421909d58b1d82c9a81dd16840965d0" alt="Trigger-Step4.png" width="2040" height="1282" data-path="images/partner_9580771591700.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_22017108049940.png?fit=max&auto=format&n=7iGV38YjgdBKSU0B&q=85&s=592b95805c522b4d9399cd29acdfb689" alt="UseCase2-Step5.png" width="1220" height="466" data-path="images/partner_22017108049940.png" />

14. Now go back to the Pipedream editor. You should see "1 New Event" in the Select Event dropdown.

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9581462512020.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=c6aa684d24986ed64862f4275cd20224" alt="Trigger-Step5.png" width="1814" height="928" data-path="images/partner_9581462512020.png" />

### Step 4: Test Trigger on Pipedream

1. Select the latest event from the "Select Event" dropdown. You should see the API request in the Exports tab. Click continue.

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9580842129556.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=3c18e6d718db1a04eda0464fcfc21a67" alt="Trigger-Step6.png" width="1814" height="1360" data-path="images/partner_9580842129556.png" />

2. You can now publish your Connector Campaign on MoEngage.
3. In Pipedream, add a new step in your workflow. For example, let's pick Google Sheets. Choose "Add Single Row" Action.
4. Select or connect a new Google Sheets Account.
5. Pick your Spreadsheet.
6. Pick your Sheet.
7. Pick "Yes" if you have the first row as Header in your Sheet.
8. Map each of the columns of your Sheet from the response of the Trigger. You can also enter custom values.

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9581319258644.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=205dbe4c48eb014e15c63703b38a8a30" alt="Action-Step2.png" width="1814" height="818" data-path="images/partner_9581319258644.png" />

9. Once you are satisfied with the configuration, you can choose to test this step or the entire workflow.

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9581344713876.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=1647db3159a9d5ded51136e2e727cf85" alt="Action-Step3.png" width="1814" height="1272" data-path="images/partner_9581344713876.png" />

10. Once the insert is successful, you can then deploy this workflow. It will insert new rows to Google Sheets each time a user performs your selected event in MoEngage.

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9581365800084.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=89720f832e291d2447f815e58e94ff4f" alt="Action-Step4.png" width="1814" height="1034" data-path="images/partner_9581365800084.png" />

## Using Data APIs in Pipedream

Using MoEngage's [Data APIs](https://www.moengage.com/docs/api/data/data-overview), you can:

1. Create or Update users
2. Import Events
3. Add or remove users in cohort (segment)

In order to make use of Data APIs in Pipedream, you need to add the "HTTP / Webhook" step. You can choose to send GET or POST Requests depending on the type of call supported in MoEngage. Data API is a collection of the following APIs:

* [User API](https://www.moengage.com/docs/api/user/track-user)
* [Event API](https://www.moengage.com/docs/api/event/track-event)

This help doc will show you how to setup User API as Action, but can be applied to any of the above APIs.

### Step 1: Add Webhook Step in Pipedream

1. Choose "HTTP / Webhook" from the list of apps.
2. Select "Send POST Request" from the list of actions.
3. For the request URL, type `https://api-0X.moengage.com/v1/customer/&lt;Workspcae_ID&gt;`. Replace `0X` with the Data Center Region your app resides in, and `Workspace_ID` with your Workspace ID.

| **Field**        | **Description**                                                                                                                |         |         |                                                                                                                                                                                       |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Workspace ID     | The Workspace ID of your MoEngage account is available at **Settings -> Account -> APIs ->Workspace ID**.                      |         |         |                                                                                                                                                                                       |
| Data API ID      | The Data API ID and the Workspace ID of your MoEngage account are the same.                                                    |         |         |                                                                                                                                                                                       |
| Data API Key     | The Data API key of your MoEngage account is available at **Settings -> Account -> APIs -> API keys** > **Data** API settings. |         |         |                                                                                                                                                                                       |
| Data Center Name | Check your MoEngage URL: `https://dashboard-OX.moengage.com` Based on the dashboard value (‘DC-01’                             | ‘DC-02’ | ‘DC-03’ | ‘DC-04’), set the correct input in the data center name on the Pipedream dashboard. [Know more](https://www.moengage.com/docs/user-guide/data/key-concepts/data-centers-in-moengage). |

4. In the Auth tab, select "Basic Auth".
   1. For Username, type your Workspace ID.
   2. For Password, type your Data API Key.

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9582156220948.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=45143c1936805ffbeeba9328c8088822" alt="Action-Webhook-Step-2.png" width="1814" height="1156" data-path="images/partner_9582156220948.png" />

5. In the Headers tab, enter a new header:
   1. Header Name: `MOE-APPKEY`
   2. Header Value: type your Workspace ID.

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9582166157844.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=0c119db3267efe8383e29c159bd0b9bc" alt="Action-Webhook-Step-3.png" width="1814" height="1156" data-path="images/partner_9582166157844.png" />

6. In the Body tab, select Content-Type as "application/json".
7. Click on the "Edit Raw JSON".
8. Copy and paste the following payload from the [User API](https://www.moengage.com/docs/api/user/track-user) docs:
   <CodeGroup>
     ```json JSON theme={null}
     {
     	"type" : "customer",
       "customer_id": "john@example.com",
       "attributes": {
         "first_name":"John",
         "last_name":"Doe",
         "email": "john.doe@example.com",
         "platforms" : [{"platform":"ANDROID", "active":"true"}]
       }
     }
     ```
   </CodeGroup>
9. You can now map values from your previous step to this JSON body. Just select the appropriate variable from the Pipedream editor Variable selector dropdown.

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9582324697876.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=6c42802bcbd0e26e8a6f31d95bca547e" alt="Action-Webhook-Step-4.png" width="1814" height="1188" data-path="images/partner_9582324697876.png" />

10. You can add/remove the fields in the Body as you like. The final payload can look something like this:

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9582328093076.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=7525fac4b684c7629e1541e0304a599f" alt="Action-Webhook-Step-5.png" width="1814" height="1342" data-path="images/partner_9582328093076.png" />

11. Once you are ready, you can "Test" the step. This will send an API Request to the MoEngage Data Centers.
12. If your call is a success, you should see the following in your Results panel:

<img src="https://mintcdn.com/moengage/pjxkCVVFj_C6dGcn/images/partner_9582395854868.png?fit=max&auto=format&n=pjxkCVVFj_C6dGcn&q=85&s=41cf6f6ab2d82ef4b7b815c59ee894c5" alt="Action-Webhook-Step-6.png" width="1814" height="838" data-path="images/partner_9582395854868.png" />

13. You can choose to Deploy your workflow once you are happy with the results.

The rest of the Data APIs can also be deployed in a similar fashion.
