Skip to main content

First request

Integration landscape

Any integration uses at least the Integration API to send business data to the Campaign Manager's Rule Engine. The Rule Engine is where all promotion rules are processed.

The Rule Engine determines which rule(s) should be applied based on the data it receives. For every rule whose conditions are met, the engine returns the rule effect(s) to the integration layer. For example the coupon code is valid or apply a discount.

landscape

To learn more about the Campaign Manager and the Rule Engine, see the end-user Help Center.

Example scenario

Let's imagine a company selling bikes through an ecommerce app. The usual workflow is:

  1. A shopper does something significant in the ecommerce application, for example, creates a cart or enters a coupon code before checkout. Talon.One calls this an event.

  2. The integration layer between the ecommerce app and Talon.One sends the details of the event. For example, the coupon code entered by the shopper, such as XMAS-2021-25.

  3. Talon.One's Rule Engine checks if the event applies to one of the rules created by the marketers and replies with an effect. Let's imagine we have the following rule: If coupon code is valid, apply a 25% discount.

    In this case the effect looks like:

     "effects": [
    {
    "campaignId": 377,
    "rulesetId": 1096,
    "ruleIndex": 0,
    "ruleName": "25% off",
    "effectType": "setDiscount",
    "triggeredByCoupon": 97534,
    "props": {
    "name": "25% off",
    "value": 66.25
    }
  4. On the ecommerce application side, apply the returned effect. In this case, we must apply a discount on the customer's cart.

There are many types of effects, see the complete list in API effects.

Sending your first request in 5 steps

  1. Create an Application in the Campaign Manager.

  2. Create your API key:

    1. Open your Application.
    2. Click Settings > Developer Settings > Create API key.
  3. Create a rule in your Application:

    • Condition: Coupon code is valid.
    • Effects: Set a discount of 25% on the session total.
  4. Let's create a session inside Talon.One and add cart items and a coupon to it. To do so, install an SDK or use curl to send the following request:

    curl --request PUT 'https://myapp.europe-west1.talon.one/v2/customer_sessions/mysession' \
    --header 'Authorization: ApiKey-v1 <your_api_key>' \
    --header 'Content-Type: application/json' \
    --data-raw '{
    "customerSession": {
    "cartItems": [
    {
    "name": "Mountain Bike",
    "sku": "SKU1234",
    "quantity": 1,
    "price": 140,
    "category": "bikes",
    "weight": 10,
    "position": 0,
    },
    ],
    },
    "couponCodes": ["XMAS-2021-25"],
    "responseContent": [
    "customerSession",
    "customerProfile",
    "triggeredCampaigns",
    "coupons"
    ]
    }'

    That's it! We just updated a customer session called mysession inside Talon.One. This session is anonymous because we didn't link it to a customer profile. It contains one cart item and one coupon code.

  5. Talon.One's response looks like:

    {
    "coupons": [
    {
    "id": 29734,
    "created": "2021-04-26T13:56:39.914646Z",
    "campaignId": 3737,
    "value": "XMAS-2021-25",
    "usageLimit": 1000,
    "usageCounter": 0,
    "attributes": {},
    "reservation": true,
    "batchId": "bmhknlwf"
    }
    ],
    "customerProfile": null,
    "customerSession": {
    // ...
    },
    "effects": [
    {
    "campaignId": 3737,
    "rulesetId": 10896,
    "ruleIndex": 0,
    "ruleName": "25% off",
    "effectType": "acceptCoupon",
    "triggeredByCoupon": 2971534,
    "props": {
    "value": "XMAS-2021-25"
    }
    },
    {
    "campaignId": 3737,
    "rulesetId": 10896,
    "ruleIndex": 0,
    "ruleName": "25% off",
    "effectType": "setDiscount",
    "triggeredByCoupon": 2971534,
    "props": {
    "name": "25% off",
    "value": 35.00
    }
    }
    ],
    "triggeredCampaigns": [
    {
    // ...
    }
    ]
    }

    The important part of the response is the effects array. In this case, the coupon code trigger 2 effects: acceptCoupon and setDiscount. setDiscount shows the effective discount amount in the value field (35).

The rest of the workflow takes place in your own application, in order to apply the effects that Talon.One returned. For example, removing $35 from the customer's cart total value.

Next steps

You can start reading about the various entities used in the Campaign Manager or see more practical examples in the Tutorials section.