Create a Business Object
In this tutorial, you will create a Business Object in PubNub Illuminate, add and map data fields to a message payload, add two metrics, and activate the Business Object to start capturing data.
What you will build
By the end of this tutorial, you will have an active Business Object called "Game engagement experiment". It captures four values from each published message: chat message count, guild name, purchase item, and purchase value. It computes two metrics over 30-minute windows: total chat message count per guild and total purchase value per item.
The example payload this Business Object reads from has this shape.
{
"chatMessage": 1,
"guildName": "Rockin Guild",
"purchasedItem": "Wood Fort",
"purchaseValue": "5"
}
Numeric strings
purchaseValue is a string in the payload ("5"), but the corresponding data field uses the Number type. Illuminate converts numeric strings to numbers automatically during ingestion.
Once active, you can use these metrics in a Decision or display them on a Dashboard.
Before you start
To follow this tutorial, confirm you have:
- A PubNub account with at least one app and keyset. If you do not have one, create one in the Admin Portal.
- Access to Illuminate. Illuminate includes a two-week free trial. Open the Admin Portal, click Illuminate in the sidebar, and confirm you can see Business Objects.
For field types, mapping categories, JSON path rules, and activation behavior, see Business Objects.
Create the Business Object
- In the Admin Portal, go to Illuminate > Business Objects.
- Click Create Business Object.
- Enter
Game engagement experimentas the name. Add an optional description. - Click Choose Apps & Keysets and assign at least one app and keyset.
- Click Save.
Illuminate creates the Business Object and opens the details view. The default fields are already mapped, so you do not need to map them. See Pre-mapped fields for their names and JSON paths.
Add data fields
Next, add four fields to capture the values from your payload.
- Click + Add field. Enter
Messagesas the field name, selectNumberas the type, and click Save. - Click + Add field. Enter
Purchase Valueas the field name, selectNumberas the type, and click Save. - Click + Add field. Enter
Guild Nameas the field name, selectStringas the type, and click Save. - Click + Add field. Enter
Purchase Itemas the field name, selectStringas the type, and click Save.
Each new field shows "Unmapped" until you complete the next step.
Map data fields
Mapping tells Illuminate where to find each field value in the message payload. Each field row has a Map button. Clicking it opens a three-field form: Category, Subcategory, and JSON path. Clicking Map in the form saves the mapping.
- Click Map next to
Messages. - Set Category to
message. - Set Subcategory to
body. - Enter
chatMessagein JSON path. - Click Map to save.
The field now shows "Mapped". Repeat for the remaining three fields using these values:
Purchase Value: Categorymessage, Subcategorybody, JSON pathpurchaseValueGuild Name: Categorymessage, Subcategorybody, JSON pathguildNamePurchase Item: Categorymessage, Subcategorybody, JSON pathpurchasedItem
After mapping all four, all nine fields show "Mapped" (the four you added plus the five defaults). If any field still shows "Unmapped", click its Map button and complete the mapping.
Add metrics
A metric aggregates field values over a time window. You will add two metrics to the Business Object.
Message sum
- In the Metrics section, click + Create metric.
- Enter
Message sumas the metric name. - Set Function to
Sum. - Set Measure to
Messages. - Set Period to
30 minutes. - Set Dimension to
Guild Name. - Leave Filter blank.
- Click Create.
Total purchased value
- Click + Create metric.
- Enter
Total purchased valueas the metric name. - Set Function to
Sum. - Set Measure to
Purchase Value. - Set Period to
30 minutes. - Set Dimension to
Purchase Item. - Leave Filter blank.
- Click Create.
Your Business Object now has two metrics.
Activate
Activation starts data capture. Before activating, confirm all four custom fields show "Mapped" and at least one app and keyset is assigned.
- Click Activate.
Illuminate begins capturing incoming message data and computing metrics. You can add more metrics after activation, but you cannot add new data fields.
What you built
You created "Game engagement experiment", a Business Object that captures chat message counts, purchase values, guild names, and purchase items from published message payloads. You mapped all four custom fields to the message.body category, added a Sum metric for chat message count per guild and a Sum metric for purchase value per item (each over 30 minutes), and activated the Business Object. Illuminate now computes these metrics as messages arrive. Use them in a Decision or view them on a Dashboard.