Skip to content

Instantly share code, notes, and snippets.

@lbrenman
Created May 12, 2020 15:28
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/cbd344945b7df432f4f56ab0c0872570 to your computer and use it in GitHub Desktop.
Save lbrenman/cbd344945b7df432f4f56ab0c0872570 to your computer and use it in GitHub Desktop.
Use Axway Integration Builder in a Sentiment Analysis Application - Part 1 (resources)
{
"id": 34678,
"name": "NPS Sentiment Notifier",
"debugLoggingExpires": "2020-04-23T23:31:13Z",
"userId": 21107,
"accountId": 18281,
"createdDate": "2020-04-21T17:35:19Z",
"steps": [{
"id": 298556,
"onSuccess": ["shouldProcess"],
"onFailure": [],
"name": "consoleLog",
"type": "script",
"properties": {
"body": "console.log(\"Trigger: \");\nconsole.log(trigger);\nconsole.log(\"/n/n\");\n\nconsole.log(\"Form ID: \");\nconsole.log(trigger.args.form_response.form_id);\nconsole.log(\"/n/n\");\n\nconsole.log(\"Answers: \");\nconsole.log(trigger.args.form_response.answers);\nconsole.log(\"/n/n\");\n\nconsole.log(\"Questions: \");\nconsole.log(trigger.args.form_response.definition.fields);\nconsole.log(\"/n/n\");"
}
}, {
"id": 299446,
"onSuccess": ["shouldNotify"],
"onFailure": [],
"name": "getSentiment",
"type": "httpRequest",
"properties": {
"method": "GET",
"url": "${steps.prepareGetSentiment.url}",
"headers": "${steps.prepareGetSentiment.headers}"
}
}, {
"id": 299449,
"onSuccess": [],
"onFailure": [],
"name": "notifyTeams",
"type": "httpRequest",
"properties": {
"method": "POST",
"body": "${steps.prepareNotifyTeams.body}",
"url": "${config.msTeamsWebhookURL}"
}
}, {
"id": 299443,
"onSuccess": ["getSentiment"],
"onFailure": [],
"name": "prepareGetSentiment",
"type": "script",
"properties": {
"body": "let answers = trigger.args.form_response.answers;\n\nlet obj = answers.find(obj => obj.field.id == config.sentimentFieldId);\n\n// console.log(obj.text);\n\n\nlet url = 'https://f19ef0e79137b3c057500c614fc24c0007c9d967.cloudapp-enterprise.appcelerator.com/api/detectsentiment?text='+encodeURIComponent(obj.text);\n\nconsole.log('url='+url);\n\nlet headers = {\n APIKey: 'dB/yIurHU2SJcd2Qtz6WQZvgoZ40ZA/8'\n}\n\n\ndone({url:url, headers:headers});"
}
}, {
"id": 299448,
"onSuccess": ["notifyTeams"],
"onFailure": [],
"name": "prepareNotifyTeams",
"type": "script",
"properties": {
"body": "let body = {\n text: steps.getSentiment.response.body.Sentiment+\" sentiment detected!!!\"\n}\n\ndone({body: body});"
}
}, {
"id": 299447,
"onSuccess": ["prepareNotifyTeams"],
"onFailure": [],
"name": "shouldNotify",
"type": "filter",
"properties": {
"body": "done(true);"
}
}, {
"id": 298938,
"onSuccess": ["prepareGetSentiment"],
"onFailure": [],
"name": "shouldProcess",
"type": "filter",
"properties": {
"body": "let form_id = trigger.args.form_response.form_id;\n\nlet answers = trigger.args.form_response.answers;\n\nlet fields = trigger.args.form_response.definition.fields;\n\nlet obj = answers.find(obj => obj.field.id == config.sentimentFieldId);\n\n// console.log(form_id);\n// console.log(obj);\n// console.log((form_id === config.formId));\n// console.log((form_id === config.formId) && ( obj && obj !== \"null\" && obj !== \"undefined\" ));\n\n// if correct poll and answer exists\ndone((form_id === config.formId) && ( obj && obj !== \"null\" && obj !== \"undefined\" ));"
}
}],
"triggers": [{
"id": 30844,
"onSuccess": ["shouldProcess"],
"onFailure": [],
"type": "manual",
"async": true,
"name": "trigger",
"properties": {}
}],
"engine": "v3",
"active": true,
"debugLoggingEnabled": true,
"singleThreaded": false,
"configuration": [{
"id": 65273,
"key": "formId",
"name": "formId",
"type": "value",
"required": true
}, {
"id": 65151,
"key": "msTeamsWebhookURL",
"name": "msTeamsWebhookURL",
"type": "value",
"required": true
}, {
"id": 65153,
"key": "sentimentFieldId",
"name": "sentimentFieldId",
"type": "value",
"required": true
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment