# Send personalized coupons via Braze using a webhook

> With a Braze integration, you can send coupon codes generated in Talon.One to specific customers through one of the available Braze messaging channels, like email, SMS, and push notification.

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

In this tutorial, we create a [webhook][webhook def] to Braze using
the **Send personalized coupon** template and set up [campaigns][campaigns def] in both platforms
to show a basic integration use case. We reward a specific Braze user
with a personalized message and a generated coupon code on their birthday.

When the campaigns in both platforms are successfully evaluated, we can expect
the following events to happen:

1. On the user's birthday, Talon.One generates a coupon code and passes it to Braze
  through the [webhook effect][webhook effect].
1. Braze displays the received coupon code in a placeholder inside a personalized message
  to the user.
1. Braze sends the message to the user containing the coupon code for redemption.

## Talon.One requirements

- You are an [admin user][admin user].
- In <Account className="icon" /> **Account** > <Integrations className="icon" /> **Integrations** > **Braze**,
  you confirmed that the **Connection Details** section is up to date with:
  - **Rest Endpoint**: An endpoint URL that corresponds to your Braze instance.
  - **API Key**: An API key generated in Braze with the required permissions.

  :::note
  - To learn about finding these values in Braze, see the [Braze docs][Braze API].
  - If you enter or modify these values, remember to click **Save**.
  :::
- You have [created a custom attribute][create custom attribute]
  to [store the customer's birthday][store customer birthday]. In this tutorial, we call this attribute <Attribute name="Customer birthday" type="custom" />.

## Braze requirements

- You know which user to reward.
  - Copy the **External User ID** of the user to reward for later use.
    :::tip
    You can look up users by opening **Audience** > **Search Users**.
    :::
- You know which [messaging channels][Braze channels] you wish to use to reach your user.
- You have configured the required settings for those channels to work,
  for example, [outbound email settings][Braze email config].
- You have an understanding of [message personalization][Braze personalize], specifically
  the `trigger_properties` object. See the [Braze docs][Braze trigger properties].

## Set up the integration

<StepsContainer>

### Create a webhook to Braze

Let's create a webhook to Braze using the **Send personalized coupon** template.

The template provides a reference to the triggered property that you can copy and paste
directly in your Braze message in later steps. When pasted, this reference acts
as a placeholder for the coupon code that is dynamically generated and sent to Braze.

:::tip
In this tutorial, we use the template for convenience. You can always
[create a webhook][webhook] without using a template.
:::

To create a webhook to Braze:

1. Open <Account className="icon" /> **Account** > <Integrations className="icon" /> **Integrations** > **Braze**.
1. Click **Create Webhook** > **Send personalized coupon**.
1. In **Name**, type a name for your webhook. In this tutorial, we name it `Send coupon code to Braze`.
1. In **Applications**, select the Applications in which the webhook must be available.
1. (Optional) Review the payload.
1. Copy the reference to the triggered property for later use in Braze.
1. Click **Save**.

### Create a Braze campaign to send the coupon

In Braze, let's [create a campaign][Braze campaign creation] to send the coupon generated in Talon.One.

To create a Braze campaign to send the coupon:

1. In Braze, click **Messaging** > **Campaigns** > **Create Campaign** > **Multichannel Campaign**.
1. In **Campaign Name**, type a name for your campaign.
1. Click **Add Messaging Channel**, and select your desired channel. In this tutorial, we select **Email**.
1. Compose the email body as desired.
   - To insert the dynamically generated coupon code,
     paste the reference to the triggered property. For example, your email message can read:

     ```text
     Happy birthday! Your very own coupon code is {{api_trigger_properties.${coupon}}}.
     ```

     :::tip
     To learn about composing the email body, see the [Braze docs][Braze email creation].
     :::
1. In the **Schedule Delivery** tab, select **API-Triggered** as the delivery type.
1. In the **API Trigger Options** section, copy the campaign ID for later use.
1. In the **Target Audiences** tab, ensure that the targeted segment includes
   the email address of the user you want to send the coupon to.
1. Enter the remaining required campaign details, and click **Launch Campaign**.

### Create a Talon.One campaign to generate the coupon

In Talon.One, let's [create a standard campaign][create campaigns] to generate a coupon code
and trigger the [webhook effect][webhook effect] to pass the coupon code value to Braze.

The campaign has a single [rule][rule] containing one condition and two effects:

#### Condition

- **Check attribute value**: <Attribute name="Customer Birthday (Customer Profile)" type="custom" /> **is on** `month` `day` <Attribute name="Current time" type="builtin" />.

#### Effects

1. **Create coupon code**: **In the current campaign**, **Recipient** is <Attribute name="Currect Customer (Friend)" type="filter" />,
   **Redemption Limit** is `1`.

   :::tip
   - To limit the discount value offered by the coupon, set a discount limit.
   - To personalize your code further, select **Use custom code pattern**.
     You can add a prefix or suffix and specify the code length and character set.
   :::

1. **Send coupon code to Braze**: **campaign_id** is `<Campaign ID>`,
   **external_user_id** is `<External User ID>`, and
   **coupon** is <Attribute name="Generated Coupon in Session" type="builtin" />.

   :::note
   In this effect, you can paste the values you copied earlier:
   - `<Campaign ID>` is the ID of your Braze campaign.
   - `<External User ID>` is the **External User ID** of the Braze user to reward.
   :::

</StepsContainer>

## Next steps

When you feel your campaign is configured to your requirements, [activate the campaign][activate campaign].
We recommend you test the integration by [updating the customer profile][update customer profile]
with the customer's birth date value.

[Braze API]: https://www.braze.com/docs/api/basics/
[Braze campaign creation]: https://www.braze.com/docs/user_guide/messaging/campaigns/creating_campaign
[Braze channels]: https://www.braze.com/docs/user_guide/channels
[Braze email config]: https://www.braze.com/docs/user_guide/administer/global/workspace_settings/email_preferences
[Braze email creation]: https://www.braze.com/docs/user_guide/channels/email/html_editor/creating_an_email_campaign/
[Braze trigger properties]: https://www.braze.com/docs/api/objects_filters/trigger_properties_object
[Braze personalize]: https://www.braze.com/docs/user_guide/messaging/design_and_edit/personalize
[create campaigns]: /docs/product/campaigns/create-and-manage-campaigns.md
[campaigns def]: /docs/product/campaigns/overview.md
[rule]: /docs/product/rules/overview.md
[webhook]: /docs/product/account/dev-tools/manage-webhooks.md#create-a-webhook
[webhook def]: /docs/product/account/dev-tools/manage-webhooks.md
[create custom attribute]: /docs/product/account/dev-tools/manage-attributes.md#create-a-custom-attribute
[store customer birthday]: /docs/product/tutorials/coupons/birthday-reward.md#store-the-customers-birthday
[webhook effect]: /docs/product/rules/effects/available-effects.md#webhooks
[activate campaign]: /docs/product/campaigns/create-and-manage-campaigns.md#activate-a-campaign
[update customer profile]: /integration-api#tag/Customer-profiles/operation/updateCustomerProfileV2
[admin user]: /docs/product/account/account-settings/manage-roles.md#admin-role
