# Create a Campaign Message

* Log in to your CrossEngage account.
* Go to `Campaigns` and click `Create new campaign` in the top right corner of the page.

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2FFBn7nMkW1L1hK8POg9M6%2FCampaigns_New.png?alt=media&#x26;token=8b3a70b4-89fc-43dc-960a-17fc4bbfe931" alt=""><figcaption></figcaption></figure>

* Choose an Audience campaign.
* Once you have created your campaign and filled in the “Campaign setup” and “Target group” sections, go to the `Messages` section and click `Create new message`.
* Select `Webhook` from the dropdown menu. The message setup screen will open.

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2FTXfw7bw5Hh7eTJTJDHzt%2FCampaigns_Message_Webhook.png?alt=media&#x26;token=ad8307fc-700c-4fe7-a37b-c84da3db1556" alt=""><figcaption></figcaption></figure>

* Under the “Send via integration” heading, select the webhook that you set up earlier.
* If you are using different endpoints, you can add the specific URL part in the "Delivery Settings" section, instead of making a new integration for it.
* If you are using different endpoints you can add the specific URL part by checking the *?* the "Delivery Settings" section instead of making a new integration for it.
* Under "Message Content" you will find the JSON text you set up in the Integration step. You can add more text depending on your needs.

#### **1) Passing one variable**

* Put the following code in to the "Message Content" field:

`{"email": "{{batch:email}}"}`

* Adjust the code to include your desired user attribute by changing the name of the user attribute or handelbar. For example, you can write "firstName" instead of "email", which would appear as&#x20;

  `{"firstName": "{{batch:firstName}}"}`.
* Select the right variable in Value Mapping: you can select traits (user attributes) as well as handlebars.

<figure><img src="https://985110910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Hio8LJewN8lQY2Vlqy0%2Fuploads%2FODLXu1md4A31SSEn01Fi%2FCampaigns_BatchWebhook_Message.png?alt=media&#x26;token=50d9834b-5c0d-4f8b-b47e-6e4d7b0a7469" alt=""><figcaption></figcaption></figure>

#### **2) Passing more than one variable**

* Copy and paste the following code into the Message Content field:

`{"users": "{{batch:users}}", "email": "{{batch:email}}"}`

* Adjust the code to include your desired user attribute by changing the name of the user attribute or handelbar. For example, you can write "firstName" instead of "email", which would appear as&#x20;

  `{"firstName": "{{batch:firstName}}"}`.
* Select the right variables in the Value Mapping section.

#### **3) Passing an array of objects**

* Copy and paste the following code into the "Message Content" field:

`{"userattribute": "{{batch:userattribute}}"}`

* Select the right variables and substitute the handlebar below as the value for the "userattribute" variable:

`{"email": "{{user.[traits.email]}}","country": "{{user.[traits.businessUnit]}}","address": "{{user.[traits.address]}}" }`

* This is how the webhook delivery should look like:

```
{"email": "abc@crossengage.io","country": "DE","address": "abcdefg"},
{"email": "bcd@crossengage.io","country": "UK","address": "bcdefgh"},
{"email": "cde@crossengage.io","country": "DE","address": "cdefghi"}
```

In similar fashion to a singular webhook, the users will receive "webhook.sent" event.

## **Good to Know**

* Make sure that the webhook URL is "https" not "http".
* Make sure the other endpoint gives fallback as well.
* If the endpoint has a restriction, such as not allowing an empty field, it might reject/fail a user. If one user is rejected, the whole batch will fail.
* You can use waithook/hookbin to test. Please note that waithook will not give you https support - for this you can use hookbin instead.
* Default content:

`{"users": "{{batch:userupdate}}"}`

* Start your campaign. If you are using it for testing you can monitor it in hookbin with the endpoint which you have just created. You will see:
  * Request details (time etc)
  * HTTP HEADERS
  * QUERY STRING
  * BODY
  * FILE UPLOADS
  * COOKIES
