Skip to main content

Creating a webhook to Iterable

In this tutorial, let's use a webhook in Talon.One to trigger an email campaign in Iterable.

Let's imagine we want to retrieve an existing coupon code from Talon.One and pass it to Iterable. The Iterable campaign should then email the coupon code to the target user.

Talon.One requirements

Iterable requirements

  • You have set up your Iterable account.
  • You have added users to your Iterable project. Your user data includes the user's first name and a user ID. For this tutorial, we assume the corresponding fields are named firstName and userId.

Creating a triggered campaign in Iterable

To create a campaign that can be triggered from Talon.One, let's first create an email template in Iterable:

  1. In Iterable, open Content > Templates.

  2. Click New Template > Email.

  3. Enter a name and click Create template.

  4. In Details, click Edit details and enter at least a subject for the email.

  5. In Design, click Edit design. When asked, choose the WYSIWYG editor.

  6. Use the following example to create your email template:

    Hi {{firstName}},

    Thank you for your recent purchase.

    Use {{couponCode}} to get 10% off your next purchase over $20.

    To unsubscribe from these emails, click {{unsubscribeUrl}}.
tip

In the example above, we use double curly braces {{...}} for user profile and event fields and merge parameters.

When the campaign is triggered and the email template is sent, these placeholders are populated with values from Iterable and Talon.One.

Now, we can create a triggered campaign based on that template. To do so:

  1. In Iterable, open Messaging > Campaigns.
  2. Click New Campaign > Email.
  3. In Campaign name, enter a name.
  4. In Type, choose API-Triggered, and click Create campaign.
  5. In Content, click Browse templates and select the template you created.
  6. Click Done to close the template dialog.
  7. Click Review, Activate.
    The state of the campaign is now Running.
  8. Make a note of the ID of your campaign.
    The campaign ID in Iterable

Creating an API key in Iterable

  1. Click Integrations > API Keys > New API key.
  2. Enter a name and click Create API key. Save the key value for later use.

Creating a webhook in Talon.One

Using a webhook, we can now trigger the campaign we created. Talon.One provides two kinds of webhooks:

Using a webhook template

For basic integration use cases, Talon.One provides a Send coupon webhook template.

When using the template, the webhook payload is prepopulated with data expected by Iterable: campaign ID, recipient user ID, and coupon code.

To create a webhook based on the Iterable template:

  1. Open Account > Integrations > Iterable.
  2. Ensure the Connection Details section is up to date with:
    • Base URL: The base URL of the Iterable API.
    • API Key: The API key you created.
  3. Click Create Webhook > Send coupon.
  4. Enter a name and select the Applications in which the webhook should be available.

After you save the webhook, you can use it to trigger Iterable emails.

Using a custom webhook

For advanced integration use cases, you can create a custom webhook to Iterable:

note

For demonstration purposes, the instructions below replicate the Send coupon webhook template. You can use this as a starting point for creating your own custom webhook.

  1. In the Campaign Manager, click Account > Tools > Webhooks and click Create Webhook.

  2. Enter a name and select the Applications in which the webhook should be available.

  3. Add the parameters to include in the request. In this tutorial, we'll use the following parameters:

    Param typeParam name
    numberIterableCampaignID
    stringCustomerProfileID
    stringCouponCode
  4. In Request, set Verb to POST.

  5. In URL, enter https://api.iterable.com/api/email/target.

  6. In Headers, click Add and define the following HTTP header: Api-Key: YOUR_API_KEY, where YOUR_API_KEY is the API key you created.

  7. In Payload, add the request payload. In this tutorial, we'll use the following payload:

    {
    "campaignId": ${$IterableCampaignID},
    "recipientUserId": "${$CustomerProfileID}",
    "dataFields": {
    "couponCode": "${$CouponCode}"
    }
    }
    tip

    To learn more about accessing Talon.One attributes and including them in the webhook, see Using parameters in a webhook.

After you save the webhook, you can use it to trigger Iterable emails.

Triggering Iterable emails

We can now trigger Iterable emails via the Rule Builder. To do so, open your campaign and create a rule with the following logic:

  • Condition: Coupon code is valid
  • Effect: In the Webhooks section, select the webhook you created, and make the following settings:
    • In IterableCampaignId, type the ID of the Iterable campaign you created.
    • In CouponCode, select the Coupon Code (Coupon) attribute.
    • In CustomerProfileID, select the Integration ID (Customer Profile) attribute.

Now, every time the rule is valid, the effect triggers Iterable to send an email with the coupon code to the current customer.

You can trigger the rule, for example, by opening a customer session that includes a customer integration ID and a coupon code. If the integration ID matches the userId of an existing user in Iterable, an email is sent to that user.