19th Nov 2020

Marketplace integration

This guide is for online marketplaces such as food delivery services. It shows how Talon.One can be used to provide loyalty programs and discounts. There are two steps to using Talon.One:

  1. Notify our API of assorted customer activities.
  2. Handle the effects returned by our API.

The decision of which effects to return for a given customer activity is controlled by the Talon.One rule engine.

1. Send activity notifications

The easiest way to get started is with one of our SDKs. After the SDK has been installed & configured you will use the following API calls:

Below we show example API calls for different customer activities: viewing restaurants, updating an order, and entering a promotional code.

1.1. User views merchant menu

Track a custom viewedRestaurants event with a restaurants attribute whenever a user views a restaurant listing:

talon.trackEvent("session1234", "viewedRestaurants", { restaurants: "12|53|56|" })

This allows campaigns to offer promotions specific to the restaurant(s) the user is currently viewing. For example, a response may contain the following effect:

["offerDiscount", "Dinner for 2 at Sadhu? 10% off for you!"]

1.2. User updates their order

Send a session update with the current cart items whenever a user updates their order:

talon.updateCustomerSession("session1234", {
  attributes: {
    restaurantId: 53
  cartItems: [{
    sku: "1245-palak-paneer",
    name: "Palak Paneer",
    quantity: 2,
    cost: 8.50,
    attributes: {
      category: 'Indian'

This allows campaigns in the rule engine to trigger effects based on the cart contents. E.g. we could create a campaign that adds a discount when a user orders two items with a category attribute of "Indian":

["setDiscount", "10% off at Sadhu", 1.70]

1.3. User enters a promo code

Send a session update whenever a user enters a promo code:

talon.updateCustomerSession("session-1234", { coupon: 'christmas-snacks-4XA7E' })

The Talon.One rule engine will validate the code, and return either an acceptCoupon effect (and any other effects that were triggered), or a rejectCoupon effect indicating that the coupon was not valid.

Successful validation:

["acceptCoupon", "christmas-snacks-4XA7E"]
["setDiscount", "$5 Christmas Discount", 5]

Unsuccessful validation:

["rejectCoupon", "christmas-snaks-4XA7E"]

2. Handle effects

The rule engine will send back discounts and other actions to take in the form of effects. These are handled in your integration by registering effect handlers:

talon.handleEffect('setDiscount', function (context, label, amount) {
   context.order.addOrReplaceDiscount(label, amount)

3. References

  • See Handling effects for more information on the types of effects the Rule Engine might return and their arguments.
  • See Data Model overview for more information on what information you can use in your campaigns to conditionally trigger effects.
Still need help? Get in touch!
Last updated on 19th Nov 2020

Was this article helpful?

Thank you! You have already voted

If you’d like a member of our support team to respond to you, please send a note to support@talon.one