# Create a webhook

> Let's create a webhook in the Campaign Manager to send a message from Talon.One.

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

We will use [Webhook.site](https://webhook.site/) as the recipient of our webhook, which
allows us to inspect the webhook's content.

We want to send the following data:

- Two attributes: The customer integration ID and the session integration ID.
- One parameter: The body text of the message.

We highly recommend that you read about [webhooks](/docs/product/account/dev-tools/manage-webhooks.md) and
[defining their payload](/docs/product/account/dev-tools/manage-webhooks.md#define-the-webhook-payload)
before following this tutorial.

:::note
- If you prefer sending the data from Talon.One as an effect, [create a custom effect](/docs/dev/tutorials/create-custom-effects.md)
  instead.
- To create and manage webhooks, ensure you are the admin or Application admin for every
  Application the webhook is connected to.
:::

## Create the webhook

Let's create our webhook:

1. Open [Webhook.site](https://webhook.site/) and, from the **Your unique URL** section,
   click **Copy to clipboard**.
1. In the Campaign Manager, click <Account className="icon"/> **Account** > <Tools
   className="icon"/> **Tools** > **Webhooks** > <Add className="icon" /> **Create
   Webhook**.
1. In **Name**, type `My webhook test`.
1. In **Connected Applications**, select the Applications where you want the webhook to be
   available.
1. In **Request details**, set the **Verb** and **URL** as follows:
   - **Verb**: **POST**
   - **URL**: Enter the Webhook.site URL you copied in step 1.
1. In **Parameters**, add the following parameter:
   - **Type**: **String**
   - **Name**: `bodyText`
   - **Description**: `The text of the message.`
1. In the **Payload** section, enter the following payload:

   ```json
   {
     "customer_integrationId": "${$Profile.IntegrationId}",
     "session_integrationId": "${$Session.IntegrationId}",
     "body": "${$bodyText}"
   }
   ```

1. In the **Test** section, click <Compass className="icon" /> **Test Webhook**.
   Talon.One sends a test request to Webhook.site, which should look like this:

   ```json
   {
     "body": "",
     "customer_integrationId": "",
     "session_integrationId": ""
   }
   ```

1. Click **Create Webhook**.

## Create the rule that uses the webhook

In a [standard campaign](/docs/product/campaigns/overview#standard-campaigns),
let's create a rule that triggers the webhook when a customer purchases products worth more than $200.

1. Open the [Rule Builder](/docs/product/rules/overview.md) in your campaign and create the following rule:

   
   | What          | Name                                          | Properties                                                                                    |
   | ------------- | --------------------------------------------- | --------------------------------------------------------------------------------------------- |
   | **Condition** | Check attribute value                         | <Attribute name="Session Total (Current Session)" type="builtin" /> **is greater than** `200` |
   | **Condition** | Check for event types and custom event values | **Event type**: `Customer Session Closing`                                                    |
   | **Effect**    | Webhooks > **My webhook test**                | In **bodyText**, enter `Thank you for your purchase!`                                         |
   

1. Save the rule and activate the campaign.

## Trigger the rule

Let's test our setup by simulating a purchase with a high cart item value.

Use curl or a similar tool to send the following request, where:

- `YOUR_BASE_URL` is the base URL of your Talon.One instance, for example, `mycompany.talon.one`.
- `YOUR_API_KEY` is a valid Integration API key for your campaign.

```js
curl -X PUT 'https://YOUR_BASE_URL/v2/customer_sessions/session_12345' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: ApiKey-v1 YOUR_API_KEY' \
--data '{
   "customerSession": {
     "state": "closed",
     "profileId": "customer_12345",
     "cartItems": [
       {
         "name": "Fine woven scarf",
         "sku": "SCARF123",
         "quantity": 1,
         "price": 249.99
       }
     ]
   }
 }'
```

Sending this request creates a session with a cart item value greater than $200 and
immediately closes it. This triggers our rule, which in turn calls our webhook.

On Webhook.site, you should see a new request with the following content:

```json
{
  "body": "Thank you for your purchase!",
  "customer_integrationId": "customer_12345",
  "session_integrationId": "session_12345"
}
```

## Related pages

- [Create a custom effect to award minutes](/docs/dev/tutorials/create-custom-effects.md)
- [Webhooks](/docs/product/account/dev-tools/manage-webhooks.md)
