> ## Documentation Index
> Fetch the complete documentation index at: https://domoinc-openapi-sync-dataflows.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Triggering a Campaign from a Domo DataSet Alert

## Intro

You can start a Campaign from a Domo DataSet Alert. Documentation on Domo DataSet Alerts can be found [here](/s/article/360042925994 "Creating an Alert for a DataSet").

## Setting up a Domo DataSet Alert with Campaigns

### Go to DataSet Alerts

To setup a Domo DataSet Alert, go to **Data**, select your DataSet, select the **Alerts** tab, and click on **New Alert**.

<Frame>
  <img alt="Alerts.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKK.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=85b7544f3b3f9eaad000bdd2268c9f76" width="1402" height="501" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKK.png" />
</Frame>

### Configure your Alert

Configure your Alert Rule. Documentation on setting up your Alert can be found [here](/s/article/360042925994 "https://knowledge.domo.com/Optimize/Notifications_and_Alerts/Creating_an_Alert_for_a_DataSet").

<Warning>
  **Note:** B e sure to go to the "You'll be notified when this alert is in a triggered state **every time your data updates**:" section and **Uncheck** the check box "Keep sending notifications while in a triggered state". Otherwise, your Campaign could be triggered over and over again and you could end up spamming your recipients.

  <Frame>
    <img alt="Continue_Triggering.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKM.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=aecb3564d76e17df72cfca0f9c51d550" width="1025" height="636" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKM.png" />
  </Frame>
</Warning>

Click **Next** when finished.

### Create a Domo Webhook

The next step is to create the Domo Webhook that will be triggering your Campaign. In the Message screen, click **Attach Action** and select **Domo Webhook**.

<Frame>
  <img alt="Domo_Webhook.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKP.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=19b537f9f0a1f86b70ecd49ca4a8bd0a" width="1024" height="636" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKP.png" />
</Frame>

### Configure the Domo Webhook

Next:

1. In the box titled **URL**, paste the following URL:

   [https://campaigns-prod.domolabs.io/api/v1/campaigns/bae/start](https://campaigns-prod.domolabs.io/api/v1/campaigns/bae/start "https://campaigns-prod.domolabs.io/api/v1/campaigns/bae/start")
2. Set **Method** to **POST**.
3. Leave the box **Secret (optional)** blank.
4. Click on **Webhook body** to expand that section.

<Frame>
  <img alt="Configure_Webhook.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKL.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=f38a41ae9c4f366cf583c4263640c02d" width="1023" height="636" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKL.png" />
</Frame>

### Configure the Domo Webhook body

In order to configure the Domo Webhook body, you need to click the pencil icon next to **Message**.

<Frame>
  <img alt="Pencil_Icon.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKN.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=bd9fc25f68dc32fba64c3311119ad460" width="1024" height="636" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKN.png" />
</Frame>

In the **Customize the webhook's body's message** section, paste the following JSON:

```json theme={"dark"}
{
 "campaignId": 0, 
 "instance": "", 
 "domoAccessToken": "", 
 "domoAccessTokenOwnerEmailAddress": "", 
 "emailAddresses": [""], 
 "isTest":true,
 "fields":[{"key": "", "value": ""},
           {"key": "", "value": ""},
           {"key": "", "value": ""}]
}
```

<Frame>
  <img alt="Json_Body.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKJ.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=c60ec7cd03640f7f1c9f91a4e81c691b" width="1029" height="638" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKJ.png" />
</Frame>

Each of the values should be defined as follows:

#### Campaign Id

The id of the Campaign you want to start. You can get the Campaign Id by editing the Campaign and going to the **Settings** tab:

<Frame>
  <img alt="Settings.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKR.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=82730d26dcdd1f8a52b05bd598a8b57b" width="1123" height="625" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKR.png" />
</Frame>

#### Domo Access Token

A Domo access token that has been generated in Domo. You can generate Domo Access Tokens by logging in, going to the **Admin** settings section, go to **Security**, and selecting **Access tokens**. There you can simply generate a new access token to use for calls to the API.

<Frame>
  <img alt="AccessToken.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKU.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=42fddc435d6143ef7a2f883762302f00" width="1271" height="756" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKU.png" />
</Frame>

#### Domo Access Token Owner Email Address

The email address of the user who owns the **Domo Access Token** specified above.

#### Email Addresses (OPTIONAL)

A list of email addresses the campaign should be delivered to. If no email addresses are selected, the entire campaign will be started and delivered to all recipients in the distribution list.

<Note>
  **Note:** T hese email addresses **MUST** exist in your distribution list.  If you specify an email address that does not exist in your distribution list, no email will be delivered to that email address.
</Note>

<Tip>
  **Tip:** You can use the **+ Metric** button to include values from the row in the DataSet that triggered this Alert. For instance, if you want to only deliver this Campaign to the email address in the row in the DataSet that triggered this Alert, you would click on **+ Metric** and select the field in your DataSet that contains the email address.

  <Frame>
    <img alt="Email_Metric.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKS.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=0e31ef9bcbc1bd1fe05b932b5bf2e89e" width="1142" height="727" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKS.png" />
  </Frame>

  This will add a tag to your webhook's body's message that will reference that field in your DataSet. Now when this Alert is triggered, the email address from the row that triggered the Alert will be included in the message that is sent to Campaigns. This will cause the Campaign to only be delivered to that email address. Again, please note that the email address **MUST** exist in your distribution list or the email will not be delivered.
</Tip>

#### Instance

You Domo instance (e.g. [domo.domo.com](http://domo.domo.com) ).

#### Is Test (OPTIONAL)

You can use this flag to send a test Campaign. This can help you test your Campaign, connection, access token, etc. without actually sending an email to your recipients. This is the same functionality as when you click the **Test Email** button from within the **Distribution List** in the Campaigns app. When you send a test Campaign the email will be delivered to the **Sender Address** of the Campaign rather than the recipients so that the delivered content can be tested and verified.

<Note>
  **Note:** If you set this flag to **true**, you **MUST** specify at least one email address in the **Email Addresses** field. You cannot send a Test Campaign without specifying at least one email address.
</Note>

#### Fields (OPTIONAL)

Fields give you the ability to pass other information and values from the Alert to Campaigns so that information can be used in the Campaign messages.

For instance, if the DataSet to which I am adding this Alert has a field for **first name** and **last name** and I want to include those fields in my Campaign, I would include those fields from my DataSet in the **fields** list.  You can then use the **key** to insert those values into Campaigns.

<Frame>
  <img alt="Fields_Example.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKV.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=53a9d86be77710999a8da58eb4f45df8" width="1143" height="728" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKV.png" />
</Frame>

Then I would go to my Campaign and add the following tag into my Campaign anywhere I would want my Alert fields to be rendered.

```json theme={"dark"}
{{domo-alert-[field key goes here]}}
```

So anywhere I want **first name** rendered I would add the tag

```json theme={"dark"}
 {{domo-alert-first name}}
```

and anywhere I want **last name** rendered I would add the tag

```json theme={"dark"}
{{domo-alert-last name}}
```

In Campaigns it would look like this:

<Frame>
  <img alt="In_Campaigns.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKT.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=13d79e51bd901b738bb3cafc207df58b" width="1127" height="513" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKT.png" />
</Frame>

<Warning>
  **Note:** To avoid failures and issues, make sure the name of your key in your DataSet Alert exactly matches the name in your Campaigns tag.

  <Frame>
    <img alt="Match.png" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKO.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=d70bbbafa5f00ba8e2a6cd730f846053" width="607" height="233" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKO.png" />
  </Frame>
</Warning>

#### Example of Webhook's Body's Message

An example of a completed webhook's body's message would look like this:

<Frame>
  <img alt="Example.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKQ.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=75f2b2f4bb02c66e3dd80514d293b283" width="1029" height="637" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKQ.png" />
</Frame>

### Testing and errors

#### Testing

Once you have your webhook's body's message configured, you can test it by clicking on the **Send Test** button.

<Frame>
  <img alt="Send_Test.PNG" src="https://mintcdn.com/domoinc-openapi-sync-dataflows/3A4Whxu66v2UwluW/images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKI.png?fit=max&auto=format&n=3A4Whxu66v2UwluW&q=85&s=72a3d2c2c4fb20d6015986a1a2aaf954" width="1026" height="636" data-path="images/kb/ka05w00000123UJ-00N5w00000Ri7BU-0EM5w000005vOKI.png" />
</Frame>

This will call the endpoint in Campaigns with your custom webhook's body's message and will notify you if the call succeeded or failed.

<Note>
  **Note:** b e sure to have the **isTest** flag set to **true** and include at least one email address in the **emailAddresses** field so you don't accidentally deliver this Campaign to all of your recipients.
</Note>

#### Errors

If your test does not succeed, there are a number of things to check. A few of them are:

1. Ensure your Campaign Id is correct.
2. Ensure you have a valid Domo Access Token specified in the **domoAccessToken** field.
3. Ensure the Domo user who owns the Domo Access Token has access to the Campaign and the Campaign's distribution list DataSet.
4. Ensure the email address specified in the **domoAccessTokenOwnerEmailAddress** field matches the email address of the user in Domo who owns the Domo Access Token.
5. If the **isTest** flag is set to **true**, ensure you have included at least one email address in the **emailAddresses** field.
6. Ensure your webhook's body's message is a correctly formed JSON object. There are a number of JSON validators available online that you could use to check.
