Skip to main content

Enriching Data in DX Graph

Creating a Data View

PUT https://io.conscia.ai/vue/_api/v1/data-views/customer_transactions
Authorization: Bearer {{apiKey}}
content-type: application/json
X-Customer-Code: {{customerCode}}

{
"dataViewConfig": {
"name": "In-store Transactions",
"timestampField": "Transaction_Date",
"dataTableId": {
"meshKey": "dev",
"dataBucketCode": "transactions",
"dataTableCode": "customer_transactions"
},
"dimensions": {
"customer_id": {
"sql": "customer_id"
},
"Transaction_Number": {
"sql": "Transaction_Number"
},
"Transaction_Date": {
"sql": "Transaction_Date"
},
"merchant_department": {
"sql": "merchant_department"
},
"article": {
"sql": "substr(article, 9)"
},
"plant_description": {
"sql": "plant_description"
}
},
"measures": {
"Product_Quantity": {
"sql": "Product_Quantity"
},
"Amount": {
"sql": "Amount"
},
"Total_Points": {
"sql": "Total_Points"
},
"Net_Amount": {
"sql": "Net_Amount"
}
}
}
}

Define Event Name

PUT https://io.conscia.ai/vue/_api/v1/event-names/customer-transactions
Authorization: Bearer {{apiKey}}
content-type: application/json
X-Customer-Code: {{customerCode}}

{
"eventNameConfig": {
"name": "Customer Transactions",
"dataViewId": {
"meshKey": "dev",
"dataViewCode": "customer_transactions"
}
}
}

Create Computed Value

PUT https://io.conscia.ai/vue/_api/v1/computed-values/storeVisitsLast6Months
Authorization: Bearer {{apiKey}}
content-type: application/json
X-Customer-Code: {{customerCode}}

{
"computedValueConfig": {
"computedValueTypeId": {
"meshKey": "dev",
"computedValueTypeCode": "aggregate"
},
"eventNameId": {
"meshKey": "dev",
"eventNameCode": "customer-transactions"
},
"params": {
"entityIdField": "customer_id",
"aggregation": "approx_distinct",
"fieldToAggregate": "Transaction_Number"
},
"conditions": {
"timeRange": {
"interval": "month",
"nbrIntervals": 6,
"alignInterval": true
}
}
}
}

Calculate the Computed Value and apply it to the customer-profile Collection in DX Graph

POST https://io.conscia.ai/vue/_api/v1/computed-values/spendByStoreLast6months/_processComputedField
Authorization: Bearer {{apiKey}}
content-type: application/json
X-Customer-Code: {{customerCode}}

{
"collectionCode": "customer-profile",
"fieldName": "storeVisitsLast6Months",
"createRecords": false
}