Created
September 14, 2022 06:11
-
-
Save agehlot/23ef465a0d9039105686b5dda3d831bd to your computer and use it in GitHub Desktop.
Sitecore CDP-DecisionModel: Exported decision model that can be used to auto identify the gender and age on the basis of provided picture url.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" xmlns:camunda="http://camunda.org/schema/1.0/dmn" namespace="http://camunda.org/schema/1.0/dmn" name="definitions" id="definitions"><decision id="dc3fa009-22ec-40ca-b90d-c487b619b5e8" name="MS Face API"><extensionElements><biodi:bounds x="650" y="336" width="200" height="73.3"/><biodi:edge source="cd7869b0-f5d6-4cff-a2d3-400946bf0e67"/></extensionElements><variable id="variable1578383b-93dc-4ba9-a451-a7b166722ff8" typeRef="map" name="msFaceApi"/><informationRequirement><requiredDecision href="#cd7869b0-f5d6-4cff-a2d3-400946bf0e67"/></informationRequirement><literalExpression expressionLanguage="web-service" id="literal1578383b-93dc-4ba9-a451-a7b166722ff8"><text><![CDATA[{"clientKey":"psfu6uh05hsr9c34rptlr06dn864cqrx","href":"https://api-eu-west-1-production.boxever.com/v2/connections/75a6ed8e-331e-49ad-bac5-13ec081ea729","ref":"75a6ed8e-331e-49ad-bac5-13ec081ea729","name":"MS Face API","description":"Microsoft Cognitive Services - Face API","modifiedByRef":"64e36864-8797-4e5e-93f4-a20c6e86d910","modifiedAt":"2021-10-15T11:57:40.724Z","revision":1,"archived":false,"auth":{"authType":"NONE"},"request":{"requestType":"POST","connectionUrl":"https://westeurope.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender&recognitionModel=recognition_04&returnRecognitionModel=false&detectionModel=detection_01&faceIdTimeToLive=86400","requestBody":"{\r\n \"url\": \"${url}\"\r\n}"},"inputMappings":[{"label":"url","key":"url","type":"String","exampleValue":"https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/cc842df289370076e6d1b85bd0013a5818cb233544ac816c652c222c06fd212f-1555941563.jpg?crop=0.6665413533834587xw:1xh;center,top&resize=480:*","mapping":"url"}],"outputMappings":[{"label":"Result","outputReference":"result","type":"Array"},{"label":"Message","outputReference":"message","type":"String"}],"customHeaders":[{"name":"Accept","value":"application/json"},{"name":"Accept-Encoding","value":"gzip"},{"name":"Content-Type","value":"application/json"},{"name":"Ocp-Apim-Subscription-Key","value":"b5fad733e9f9447ca0f34c3a4cf8fcea"}],"urlParameters":[],"systemType":"AI","connectionTimeout":5000,"socketTimeout":5000,"icon":"fad fa-mind-share"}]]></text></literalExpression></decision><decision id="edcf5a1a-07f8-48e9-b8e9-a4258952217e" name="Suggest Offer "><extensionElements><biodi:bounds x="650" y="56" width="200" height="73.3"/><biodi:edge source="ca20cc2e-4839-418a-9cba-85f906cd3b06"/><biodi:edge source="ede4d9f5-6d35-4809-ba30-066e491fc363"/></extensionElements><informationRequirement><requiredDecision href="#ca20cc2e-4839-418a-9cba-85f906cd3b06"/></informationRequirement><authorityRequirement><requiredAuthority href="#ede4d9f5-6d35-4809-ba30-066e491fc363"/></authorityRequirement><decisionTable hitPolicy="UNIQUE"><input id="integer880e69f5-c32c-433c-8d77-3bb689316fab" label="Age" camunda:inputVariable=""><inputExpression typeRef="integer"><text>result.age</text></inputExpression></input><input id="string28e61c3b-8c5c-470b-865e-cbecf6375886" label="Gender" camunda:inputVariable=""><inputExpression typeRef="string"><text>result.gender</text></inputExpression><inputValues id="string9677c404-ebcb-419b-9110-12f7e8cfb271"><text>"male","female","unknown"</text></inputValues></input><output id="string1f9d78cb-9982-4e81-b10c-cf05fbb86e5a" label="Offer" name="face api offer" typeRef="com.boxever.offer" biodi:offerTemplateRef="536b150f-769d-4673-bafe-8c3baacb5d9c"/><rule id="DecisionTable1_0"><description><![CDATA[offer for young woman]]></description><inputEntry id="inputf89dceef-db4f-4c53-9a95-adbbc81c73b7"><text>[20..25]</text></inputEntry><inputEntry id="input33b0366f-55b6-45fd-b8dc-c6c8ebd012af"><text><![CDATA["female"]]></text></inputEntry><outputEntry id="outputae005067-cd20-493e-b64b-39374e44e27d"><text><![CDATA["fcde595f-fd78-41db-8b0e-23b5af1f1185"]]></text></outputEntry></rule><rule id="DecisionTable1_1"><description><![CDATA[offer for retiree]]></description><inputEntry id="inputfd2a1c13-e9a7-4221-8698-a4cbbcec320a"><text><![CDATA[> 60]]></text></inputEntry><inputEntry id="input1fbce2cc-b932-4aa6-8008-08a86b3c6b72"><text><![CDATA[not("unknown")]]></text></inputEntry><outputEntry id="outputabd3f53d-68fe-4fd9-b520-6f9b18d22ba5"><text><![CDATA["24ccce1c-7c8a-4e27-a7a2-cd6932f0e52b"]]></text></outputEntry></rule></decisionTable></decision><inputData id="e02c9714-d3cb-4685-a194-dedc664e66da" name="Guest"><extensionElements><biodi:bounds x="650" y="610" width="200" height="73.3"/></extensionElements></inputData><knowledgeSource id="ede4d9f5-6d35-4809-ba30-066e491fc363" name="Offers"><extensionElements><biodi:bounds x="964" y="56" width="200" height="73.3"/></extensionElements></knowledgeSource><decision id="cd7869b0-f5d6-4cff-a2d3-400946bf0e67" name="Extract photo "><extensionElements><biodi:bounds x="650" y="468" width="200" height="73.3"/><biodi:edge source="e02c9714-d3cb-4685-a194-dedc664e66da"/></extensionElements><variable id="variable1634298081581" typeRef="string" name="url"/><informationRequirement><requiredInput href="#e02c9714-d3cb-4685-a194-dedc664e66da"/></informationRequirement><literalExpression id="literal1634298081581" expressionLanguage="javascript"><text><![CDATA[(function () { | |
for (var i = 0; i < guest.dataExtensions.length; i++) { | |
if (guest.dataExtensions[i].key === 'picture' ) { | |
var picture = guest.dataExtensions[i].values; | |
return picture.url; | |
} | |
} | |
throw new Error('Stop execution'); | |
})();]]></text></literalExpression></decision><decision id="ca20cc2e-4839-418a-9cba-85f906cd3b06" name="Parse AI result "><extensionElements><biodi:bounds x="650" y="187" width="200" height="73.3"/><biodi:edge source="dc3fa009-22ec-40ca-b90d-c487b619b5e8"/></extensionElements><variable id="variable1634298110342" typeRef="map" name="result"/><informationRequirement><requiredDecision href="#dc3fa009-22ec-40ca-b90d-c487b619b5e8"/></informationRequirement><literalExpression id="literal1634298110342" expressionLanguage="javascript"><text><![CDATA[(function () { | |
var result = {age:0, gender: "unknown"}; | |
if(msFaceApi.result!=null && msFaceApi.result.length === 1 && msFaceApi.result[0].faceAttributes!=null){ | |
print(msFaceApi.result[0].faceAttributes); | |
result.age = msFaceApi.result[0].faceAttributes.age; | |
result.gender = msFaceApi.result[0].faceAttributes.gender; | |
} | |
return result; | |
})();]]></text></literalExpression></decision></definitions> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment