Skip to content

Profiled Recipes

NearIT allows to target precise user clusters with recipes. This can be done by setting up the operation plugin to use evaluate_segment action.

Data sources

You can build up your targets using three data-sources:

  • user data set by mobile app using SDK
  • user data set by API (read more)
  • user behavior directly detected by NearIT SDK (i.e. the user has been in a place)

Quick example: profiled push notification

This example shows how to send a notification immediately only to users that have:

  • age between 20 and 40
  • have snowboarding or basketball as favorite sport.

You can express your target using the operation_bundle attribute by listing all the conditions that should be evaluated for your user.

POST https://api.nearit.com/recipes

{
  "data": {
    "type": "recipes",
    "attributes": {
      "owner_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "app_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "name": "profiled push",
      "state_event": "finalize",
      "notification_translations": {
        "en": {
          "body": "Hello World"
        },
        "it": {
          "body": "Ciao Mondo"
        }
      },
      "default_language": "en",
      "operation_plugin_id": "congrego",
      "operation_action_id": "evaluate_segment",
      "operation_bundle": {
        "owner_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "app_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "conditions": [
          {
            "key": "age",
            "predicate": "between",
            "value": {
              "left": 20,
              "right": 40
            }
          },
          {
            "key": "favourite_sport",
            "predicate": "in",
            "value": [
                "snowboard",
                "basket"
            ]
          }
        ]
      },
      "reaction_plugin_id": "simple-notification",
      "reaction_action_id": "simple_notification",
      "reaction_bundle_id": null,
      "pulse_plugin_id": "push-machine",
      "pulse_action_id": "send_push",
      "pulse_bundle": {
        "owner_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
        "app_id" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      }
    }
  }
}

Condition structure

As you see in the example, every condition requires 3 attributes:

  • key identifies the user data
  • predicate defines the condition to evaluate
  • value define the value or the set of values to be evaluated

Not every user data supports the same predicates, they can vary based on the data type:

Data type Supported predicates
Number between, not_between, gt, gteq, lt, lteq, in, not_in
Date between, not_between, contains, not_in, gt, lt
String in, not_in, contains
Boolean eq
List in, not_in

Based on the predicate, the value field can contain a single value, an array, an object:

Predicate Description Value field
eq Is equal to Single value
gt Is greater than Single value
lt Is less than Single value
gteq Is greater than or equal to Single value
lteq Is less than or equal to Single value
in Is equal to Array of possible values
not_in Is not equal to Array of possible values
contains Is partially equal to Single value
between Is between Object containing "left" and "right" attributes
not_between Is not between Object containing "left" and "right" attributes