Skip to content

Instantly share code, notes, and snippets.

@lbrenman
Created May 12, 2020 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbrenman/cd64e7dc9af76daa8c523a695d98dd1f to your computer and use it in GitHub Desktop.
Save lbrenman/cd64e7dc9af76daa8c523a695d98dd1f to your computer and use it in GitHub Desktop.
Use Axway Integration Builder in a Sentiment Analysis Application - Part 2 (resources)
{
"id": 34149,
"name": "CRM Sentiment Notifier",
"debugLoggingExpires": "2020-05-08T04:17:25Z",
"userId": 21107,
"accountId": 18281,
"createdDate": "2020-04-07T20:42:33Z",
"steps": [{
"id": 286906,
"onSuccess": ["isNotDeleted"],
"onFailure": [],
"name": "consoleLog",
"type": "script",
"properties": {
"body": "console.log(trigger);\ndone();"
}
}, {
"id": 286999,
"onSuccess": ["prepareGetSentiment"],
"onFailure": [],
"name": "getAccount",
"type": "elementRequest",
"properties": {
"elementInstanceId": "${config.crm}",
"api": "${steps.prepareGetAccount.url}",
"method": "GET"
}
}, {
"id": 307640,
"onSuccess": ["shouldNotify"],
"onFailure": [],
"name": "getSentiment",
"type": "elementRequest",
"properties": {
"elementInstanceId": "${config.detectSentiment}",
"api": "/detectsentiment",
"query": "${steps.prepareGetSentiment.query}",
"method": "GET"
}
}, {
"id": 286996,
"onSuccess": ["prepareGetAccount"],
"onFailure": [],
"name": "isNotDeleted",
"type": "filter",
"properties": {
"body": "done(trigger.event.eventType != 'DELETED');"
}
}, {
"id": 286908,
"onSuccess": [],
"onFailure": [],
"name": "notifyTeams",
"type": "httpRequest",
"properties": {
"method": "POST",
"url": "${config.msTeamsWebhookURL}",
"body": "${steps.prepareNotifyTeams.body}"
}
}, {
"id": 286998,
"onSuccess": ["getAccount"],
"onFailure": [],
"name": "prepareGetAccount",
"type": "script",
"properties": {
"body": "let url = '/accounts/'+trigger.body.message.raw.objects[0].AccountId;\n\ndone({url:url});"
}
}, {
"id": 286916,
"onSuccess": ["getSentiment"],
"onFailure": [],
"name": "prepareGetSentiment",
"type": "script",
"properties": {
"body": "let query = {\n text: trigger.body.message.raw.objects[0].Body\n}\n\ndone({query: query});"
}
}, {
"id": 286907,
"onSuccess": ["notifyTeams"],
"onFailure": [],
"name": "prepareNotifyTeams",
"type": "script",
"properties": {
"body": "var sentiment;\nif(steps.getSentiment.response.body.Sentiment === 'NEGATIVE') {\n sentiment = 'Negative';\n} else if(steps.getSentiment.response.body.Sentiment === 'MIXED') {\n sentiment = 'Mixed';\n} else {\n sentiment = 'Unknown';\n}\n\nlet body = {\n \"@type\": \"MessageCard\",\n \"@context\": \"http://schema.org/extensions\",\n \"themeColor\": \"0076D7\",\n \"summary\": \"CRM Opportunity Note Sentiment Notifier\",\n \"sections\": [{\n \"activityTitle\": \"CRM Opportunity Note Sentiment Notifier\",\n \"activitySubtitle\": \"'\"+trigger.body.message.raw.objects[0].Body+\"'\",\n \"facts\": [{\n \"name\": \"Sentiment\",\n \"value\": sentiment\n },{\n \"name\": \"Account\",\n \"value\": \"[\"+steps.getAccount.response.body.Name+\"](\"+config.crmBaseAddress+trigger.body.message.raw.objects[0].AccountId+\")\"\n },{\n \"name\": \"Note\",\n \"value\": \"[Click to view note](\"+config.crmBaseAddress+trigger.event.objectId+\")\"\n }],\n \"markdown\": true\n }]\n}\n\ndone({body: body});"
}
}, {
"id": 308509,
"onSuccess": ["prepareNotifyTeams"],
"onFailure": [],
"name": "shouldNotify",
"type": "filter",
"properties": {
"body": "done(steps.getSentiment.response.body.Sentiment === 'NEGATIVE' || steps.getSentiment.response.body.Sentiment === 'MIXED');"
}
}],
"triggers": [{
"id": 30344,
"onSuccess": ["isNotDeleted"],
"onFailure": [],
"type": "event",
"async": true,
"name": "trigger",
"properties": {
"elementInstanceId": "${config.crm}"
}
}],
"engine": "v3",
"active": true,
"debugLoggingEnabled": true,
"singleThreaded": false,
"configuration": [{
"id": 64000,
"key": "crm",
"name": "crm",
"type": "elementInstance",
"required": true
}, {
"id": 64024,
"key": "crmBaseAddress",
"name": "crmBaseAddress",
"type": "value",
"required": true
}, {
"id": 65393,
"key": "detectSentiment",
"name": "detectSentiment",
"type": "elementInstance",
"required": true
}, {
"id": 64001,
"key": "msTeamsWebhookURL",
"name": "msTeamsWebhookURL",
"type": "value",
"required": true
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment