commit b508d0c78a356421c3eb5905c8a58f3766d9d212 Author: crickm Date: Sun Aug 18 16:45:56 2024 -0400 Téléverser les fichiers vers "/" diff --git a/Alchemer_Survey_Results_Export___HTML_format___PROD_RC3___IN_DEV___Adding_Answer_Scores___w_Pinned_data.json b/Alchemer_Survey_Results_Export___HTML_format___PROD_RC3___IN_DEV___Adding_Answer_Scores___w_Pinned_data.json new file mode 100644 index 0000000..e6b9a48 --- /dev/null +++ b/Alchemer_Survey_Results_Export___HTML_format___PROD_RC3___IN_DEV___Adding_Answer_Scores___w_Pinned_data.json @@ -0,0 +1,1766 @@ +{ + "name": "Alchemer Survey Results Export - HTML format - PROD RC3 - IN DEV - Adding Answer Scores - w Pinned data", + "nodes": [ + { + "parameters": {}, + "id": "2f68d37d-e578-4698-84bc-aa1f5f6fe30c", + "name": "Start", + "type": "n8n-nodes-base.start", + "typeVersion": 1, + "position": [ + -1460, + 1420 + ] + }, + { + "parameters": { + "keepOnlySet": true, + "values": { + "string": [ + { + "name": "surveyresults_surveyquestions", + "value": "={{$json[\"data\"]}}" + } + ] + }, + "options": { + "dotNotation": true + } + }, + "name": "surveyquestions_Set _OnlyPullData_Node", + "type": "n8n-nodes-base.set", + "typeVersion": 1, + "position": [ + 2880, + 1240 + ], + "id": "0fe4e1ed-881e-45f5-a69d-1be4d6c3f706" + }, + { + "parameters": { + "content": "## Get Survey Questions and Answers - Automated\n", + "height": 80, + "width": 546.7136856878723 + }, + "id": "330e6a51-4caa-4132-a543-d6d4b1368b94", + "name": "Note2", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 2680, + 1160 + ] + }, + { + "parameters": { + "content": "## Version : PROD RC1\n**Date : 3/13/2024\n**By : Christian Morneau", + "width": 323.9703981264638 + }, + "id": "b71a738c-7732-4435-89cc-142edf7d1db8", + "name": "Sticky Note12", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -440, + 600 + ] + }, + { + "parameters": { + "content": "## *** ALCHEMER Survey Results Export In HTML Format Integration***\n", + "height": 80, + "width": 700.245372256413 + }, + "id": "e78c8393-7930-40c3-a7e2-3127ac0fe869", + "name": "Note5", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -440, + 500 + ] + }, + { + "parameters": { + "keepOnlySet": true, + "values": { + "string": [ + { + "name": "surveyresults", + "value": "={{$json[\"data\"]}}" + } + ] + }, + "options": { + "dotNotation": true + } + }, + "name": "Set _OnlyPullData_Node", + "type": "n8n-nodes-base.set", + "typeVersion": 1, + "position": [ + 1820, + 1420 + ], + "id": "7239f43d-65c2-433a-8c9c-7a3336d5c260" + }, + { + "parameters": { + "workflowId": "0n6ouQvBQxi616Vn", + "options": {} + }, + "id": "bad2dd4b-6931-47f1-8095-c2c8d3524c15", + "name": "Execute Workflow - Set ALCHEMER Credentials", + "type": "n8n-nodes-base.executeWorkflow", + "typeVersion": 1, + "position": [ + 120, + 1420 + ], + "executeOnce": true + }, + { + "parameters": { + "content": "## GET CRD", + "height": 91.1662763466042 + }, + "id": "10c43d7a-cff9-4ce6-872b-8278652a2906", + "name": "Sticky Note5", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 300, + 1340 + ] + }, + { + "parameters": { + "content": "## Read LRD", + "height": 85.5831381733021, + "width": 757.4311304051469 + }, + "id": "4c81af7c-b0d7-49ae-8219-6f76dd4e5a32", + "name": "Sticky Note2", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 600, + 1340 + ] + }, + { + "parameters": { + "setAllData": false, + "options": {} + }, + "name": "Move Binary Data", + "type": "n8n-nodes-base.moveBinaryData", + "position": [ + 760, + 1420 + ], + "typeVersion": 1, + "id": "32c19f37-e409-4cff-8e11-30ae9397ec7d" + }, + { + "parameters": { + "content": "## Update LRD on successful run", + "height": 108.52325581395354, + "width": 513.7536576126105 + }, + "id": "33d6fe0f-6868-4570-a076-223ec4a419c7", + "name": "Sticky Note9", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 6840, + 1280 + ] + }, + { + "parameters": { + "content": "## Set Credentials", + "height": 91.1662763466042, + "width": 150 + }, + "id": "2cf8aeda-eb66-464a-a961-f632e5bae25a", + "name": "Sticky Note", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 100, + 1340 + ] + }, + { + "parameters": { + "functionCode": "let results = {surveyResults:[]}\n\n//Boucle à travers tous les éléments d'entrée (qui ont des valeurs de tableau dans le champ id)\nfor (item of items) {\n //Boucle sur le nombre d'éléments dans le tableau de référence pour l'élément actuel\n arr = item.json \n for (surveyresult of arr.surveyresults) {\n \n // On pousse les informations dans nos résultats\n results.surveyResults.push({ \n id: surveyresult.id,\n })\n }\n}\nreturn results;" + }, + "name": "Build Surveys Array", + "type": "n8n-nodes-base.function", + "typeVersion": 1, + "position": [ + 2020, + 1420 + ], + "id": "77f2905d-4514-4b68-b6a7-52ef0ddba8e1" + }, + { + "parameters": { + "options": { + "reset": false + } + }, + "id": "f6798c0a-33d8-4b0a-a981-4928420115ee", + "name": "Loop Over Items", + "type": "n8n-nodes-base.splitInBatches", + "typeVersion": 3, + "position": [ + 2460, + 1420 + ] + }, + { + "parameters": { + "content": "## Get Surveys", + "height": 85.5831381733021, + "width": 694.7895949058848 + }, + "id": "e58581b4-cb13-4173-aa19-f80193c4d707", + "name": "Sticky Note3", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 1640, + 1320 + ] + }, + { + "parameters": { + "authentication": "genericCredentialType", + "url": "=https://api.alchemer-ca.com/head/survey/{{ $json.id }}/surveyquestion", + "options": {}, + "queryParametersUi": { + "parameter": [ + { + "name": "=api_token", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token\"] }}" + }, + { + "name": "=api_token_secret", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token_secret\"] }}" + } + ] + } + }, + "name": "Get Survey/surveyquestions", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 2, + "position": [ + 2680, + 1240 + ], + "id": "fcdbc38e-c4c0-43f3-baca-2d49aa2e897b" + }, + { + "parameters": { + "authentication": "genericCredentialType", + "url": "=https://api.alchemer-ca.com/head/survey/{{ $('Loop Over Items').item.json.id }}", + "options": {}, + "queryParametersUi": { + "parameter": [ + { + "name": "=api_token", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token\"] }}" + }, + { + "name": "=api_token_secret", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token_secret\"] }}" + } + ] + } + }, + "name": "Get Survey Details", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 2, + "position": [ + 3340, + 1240 + ], + "id": "17e5d382-247b-4499-85fe-0e4081a63611" + }, + { + "parameters": { + "authentication": "genericCredentialType", + "url": "=https://api.alchemer-ca.com/head/survey/{{ $json.data.id }}/surveycampaign?filter[field][0]=name&filter[operator][0]==&filter[value][0]={{ $json.data.title }}", + "options": {}, + "queryParametersUi": { + "parameter": [ + { + "name": "=api_token", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token\"] }}" + }, + { + "name": "=api_token_secret", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token_secret\"] }}" + } + ] + } + }, + "name": "Get Survey/surveyCampaign", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 2, + "position": [ + 3560, + 1240 + ], + "id": "8e0e10d7-a6c7-4a4a-aa6d-a399a2faa4d7" + }, + { + "parameters": { + "content": "## Get Survey Contacts - Automated\n", + "height": 80, + "width": 822.4056452232218 + }, + "id": "d25fb03e-e7a8-41b4-8dbe-71428cf11943", + "name": "Note7", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 3340, + 1160 + ] + }, + { + "parameters": {}, + "id": "ca661c77-0498-4bd0-b874-4202d405a1e0", + "name": "No Operation, do nothing1", + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [ + 3800, + 1500 + ] + }, + { + "parameters": { + "content": "## Get Survey Results - Automated\n", + "height": 80, + "width": 350.43991917490064 + }, + "id": "af4286fe-a4a0-47ab-9f05-93b86239df94", + "name": "Note3", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 4320, + 1140 + ] + }, + { + "parameters": { + "content": "## Merge and export individual Surveys Results\n", + "height": 80, + "width": 548.5313385273793 + }, + "id": "4f454632-a1e1-4483-9fb8-fdb497eca844", + "name": "Note8", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 4800, + 1140 + ] + }, + { + "parameters": { + "authentication": "genericCredentialType", + "url": "=https://api.alchemer-ca.com/v5/survey/{{ $('Get Survey Details').item.json.data.id }}/surveycampaign/{{ $json.data[0].id }}/surveycontact", + "options": {}, + "queryParametersUi": { + "parameter": [ + { + "name": "=api_token", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token\"] }}" + }, + { + "name": "=api_token_secret", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token_secret\"] }}" + } + ] + } + }, + "name": "Get Survey/surveyCampaign/surveyContact", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 2, + "position": [ + 3800, + 1240 + ], + "id": "d3a4f77e-d110-480f-bff5-3cc6b003ada5", + "onError": "continueErrorOutput" + }, + { + "parameters": { + "keepOnlySet": true, + "values": { + "string": [ + { + "name": "listeSurveyContacts", + "value": "={{$json[\"data\"]}}" + } + ] + }, + "options": { + "dotNotation": true + } + }, + "name": "surveycampaign/surveycontact Set _OnlyPullData_Node3", + "type": "n8n-nodes-base.set", + "typeVersion": 1, + "position": [ + 4060, + 1220 + ], + "id": "ceabb128-2cf6-4fca-b16e-1f8cf311369d" + }, + { + "parameters": { + "jsCode": "let results = { listeSurveyQuestion: [] };\n\nfor (const item of $input.all()) {\n arr = item.json;\n for (surveyresult_surveyquestion of arr.surveyresults_surveyquestions) {\n // Extract options for the current question\n let options = [];\n for (const option of surveyresult_surveyquestion.options) {\n options.push({\n id: surveyresult_surveyquestion.id + '_' + option.id,\n title: option.title.English,\n value: option.value,\n });\n }\n\n // Push the question and associated options into the results\n results.listeSurveyQuestion.push({\n id: surveyresult_surveyquestion.id,\n subType: surveyresult_surveyquestion._subtype,\n title: surveyresult_surveyquestion.title.English,\n options: options,\n });\n }\n}\n\nreturn results;\n" + }, + "id": "a1aa4a0d-62ed-4fe9-a74b-fdecaeb19506", + "name": "Build Survey Answers Array", + "type": "n8n-nodes-base.code", + "typeVersion": 1, + "position": [ + 3120, + 1240 + ] + }, + { + "parameters": { + "keepOnlySet": true, + "values": { + "string": [ + { + "name": "surveyresults", + "value": "={{$json[\"data\"]}}" + } + ] + }, + "options": { + "dotNotation": true + } + }, + "name": "surveyresults_Set _OnlyPullData_Node1", + "type": "n8n-nodes-base.set", + "typeVersion": 1, + "position": [ + 4560, + 1220 + ], + "id": "e5b2bffc-d47b-4bff-83c6-d6ba9df15707" + }, + { + "parameters": { + "keepOnlySet": true, + "values": { + "string": [ + { + "name": "data", + "value": "={{ $json[\"data\"] }}" + } + ] + }, + "options": { + "dotNotation": false + } + }, + "id": "f9cc23d1-2199-427c-8be5-c9eec261915f", + "name": "Get LRD", + "type": "n8n-nodes-base.set", + "typeVersion": 1, + "position": [ + 920, + 1420 + ] + }, + { + "parameters": { + "filePath": "/n8n_lrds/ALCHEMER_SurveyResults_HTML_Export_LRD.csv" + }, + "name": "ReadBinaryFile", + "type": "n8n-nodes-base.readBinaryFile", + "position": [ + 600, + 1420 + ], + "typeVersion": 1, + "id": "ab53fcf1-edcd-4782-91f5-60350529c31b", + "alwaysOutputData": true + }, + { + "parameters": { + "fileName": "=/n8n_lrds/ALCHEMER_SurveyResults_HTML_Export_LRD.csv", + "dataPropertyName": "fileBinary", + "options": { + "append": false + } + }, + "name": "Write Binary File1", + "type": "n8n-nodes-base.writeBinaryFile", + "typeVersion": 1, + "position": [ + 7260, + 1400 + ], + "notesInFlow": true, + "id": "519fe945-8520-4d07-aa03-2a0b9f891448", + "notes": "Writes binary file to your HDD" + }, + { + "parameters": { + "authentication": "genericCredentialType", + "url": "=https://api.alchemer-ca.com/v5/survey/{{ $('Get Survey Details').item.json.data.id }}/surveyresponse ", + "options": {}, + "queryParametersUi": { + "parameter": [ + { + "name": "=api_token", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token\"] }}" + }, + { + "name": "=api_token_secret", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token_secret\"] }}" + } + ] + } + }, + "name": "Get Survey Results", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 2, + "position": [ + 4320, + 1220 + ], + "id": "7ebc80a4-6972-45be-b3b4-9c70460cb422" + }, + { + "parameters": { + "jsCode": "//const input = $input.all();\nconst input = $node[\"Build Surveys Array\"].json.surveyResults;\nreturn input;" + }, + "id": "eca1babe-ad45-4622-8e7e-9be1b66d0685", + "name": "Getting the SurveysResults output and put them in a list with only IDs", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 2220, + 1420 + ] + }, + { + "parameters": { + "jsCode": "let results = [];\n\n// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n arr = item.json;\n\n const surveyQuestionsAndAnswers = $node[\"Build Survey Answers Array\"].json.listeSurveyQuestion;\n const surveyResults = $node[\"surveyresults_Set _OnlyPullData_Node1\"].json.surveyresults;\n const surveyDetails = $node[\"Get Survey Details\"].json.data;\n\n //\n // Functions allowing to pick metadata from the surveyQuestionsAndAnswers node, which had questions and associated answers data\n //\n const questionsAndAnswers = [];\n const index = {}; // Index object for searching by ID\n\n surveyQuestionsAndAnswers.forEach((question) => {\n const questionObj = {\n id: question.id,\n type: question.subType,\n title: question.title,\n answers: [],\n };\n\n question.options.forEach((answer) => {\n const answerObj = {\n id: answer.id,\n title: answer.title,\n value: answer.value,\n };\n\n questionObj.answers.push(answerObj);\n index[answer.id] = answerObj; // Add answer object to index\n });\n\n questionsAndAnswers.push(questionObj);\n index[question.id] = questionObj; // Add question object to index\n });\n\n // Search by question ID\n const searchByQuestionId = (id) => {\n return index[id] || null;\n };\n\n const searchByAnswerId = (id) => {\n const result = [];\n for (const question of questionsAndAnswers) {\n const answer = question.answers.find((answer) => answer.id === id);\n if (answer) {\n result.push(answer);\n }\n }\n return result.length > 0 ? result : null;\n };\n\n\n\n\n //\n // Starting loop on input data payload\n //\n\n for (const item of surveyResults) {\n //Boucle sur le nombre d'éléments dans le tableau de référence pour l'élément actuel\n arr = item.json;\n\n for (surveyResult of surveyResults) {\n var sguid;\n var nbAsset = 0; // Nombre de proprietes qui contiennent le mot Asset de surveyResult\n var nbRequired = 0; // Nombre de proprietes qui contiennent le mot result de surveyResult\n var Score = 0; // Score du sondage\n var surveyData = []; // Array to store questions and associated answers\n\n\n // Counting Assets in Survey Results \n // Recursive function to count occurrences of \"answer\": \"Asset\"\n function countOccurrences(data, answer) {\n let count = 0;\n for (const key in data) {\n if (typeof data[key] === \"object\") {\n count += countOccurrences(data[key], answer);\n } else if (key === \"answer\" && data[key] === answer) {\n count++;\n }\n }\n return count;\n }\n\n // Count occurrences of \"answer\": \"Asset\"\n nbAsset = countOccurrences(surveyResult.survey_data, \"Asset\");\n // Count occurrences of \"answer\": \"Required\"\n nbRequired = countOccurrences(surveyResult.survey_data, \"Required\");\n\n\n //\n // Setting guid ifnull logic\n //\n if (surveyResult && surveyResult.url_variables && surveyResult.url_variables.sguid && surveyResult.url_variables.sguid.value) {\n sguid = surveyResult.url_variables.sguid.value;\n } else {\n // Log a message indicating that the value is undefined and proceed with default behavior\n console.warn(\"Value of surveyResult or its nested properties is undefined. Default behavior will be applied.\");\n // Proceed with default behavior or set default value for sguid\n // For example, you can set sguid to an empty string:\n sguid = \"\";\n }\n\n //\n //contact metadata export \n //\n var contactId = surveyResult.contact_id;\n\n ///ATTENTION C'EST ICI QUE L'ON CONNECTE LE PIPELINE CONTACT\n //On extrait le array d'objet(liste d'objet) des survey questions qui se trouve dans un autre node\n var surveyContacts =\n $node[\"surveycampaign/surveycontact Set _OnlyPullData_Node3\"].json\n .listeSurveyContacts;\n //On va rechercher le contact associe on contact_id pour le id de question\n var surveyContact = surveyContacts.find(\n (surveyContact) => surveyContact.id == contactId\n );\n\n //On vérifie si on a trouver un contact, sinon on retourne \"N/A - contact not found.\"\n if (surveyContact !== undefined) {\n contactName = surveyContact.first_name + \" \" + surveyContact.last_name;\n contactName = surveyContact.first_name + \" \" + surveyContact.last_name;\n contactEmail = surveyContact.email_address;\n contactFirstName = surveyContact.first_name;\n contactLastName = surveyContact.last_name;\n contactcustomField1 = surveyContact.customfield1;\n } else {\n contactName = \"N/A - Title not found.\";\n }\n\n\n\n // Isoler le score dans le resultat et l'associer à la variable Score\n for (const questionId in surveyResult.survey_data) {\n const question = surveyResult.survey_data[questionId];\n\n if (question.type === \"QUIZSCORE\") {\n Score = question.answer;\n continue;\n } else {\n const questionIdValue = question.id;\n const questionData = {\n question: searchByQuestionId(questionIdValue),\n selectedAnswers: []\n };\n\n const answerID = questionIdValue + \"_\" + question.answer_id;\n const optionsIds = [];\n\n if (question.answer_id) {\n const answer = searchByAnswerId(answerID);\n if (typeof answer === 'object') {\n questionData.selectedAnswers.push(answer);\n }\n }\n\n if (question.type == \"TEXTBOX\") {\n const answer = question.answer;\n questionData.selectedAnswers.push(answer);\n }\n\n if (question.options) {\n for (const optionId in question.options) {\n const answer = question.options[optionId].id;\n answerNo = questionIdValue + '_' + answer;\n const optionAnswer = searchByAnswerId(answerNo);\n if (typeof optionAnswer === 'object') {\n questionData.selectedAnswers.push(optionAnswer);\n }\n }\n }\n\n surveyData.push(questionData);\n }\n }\n\n\n // Obtaining the Requisition ID\n\n const regex = /^\\d+/;\n const surveyTitle = surveyDetails.title;\n const match = surveyTitle.match(regex);\n const reqId = match ? match[0] : null;\n\n \n console.log(surveyData);\n //return(surveyData);\n //results.push(surveyData);\n\n jsonDeSortie = {\n json: {\n Id: surveyResult.id,\n ContactId: surveyResult.contact_id,\n Contact: contactName,\n Sguid: sguid,\n Datesubmitted: surveyResult.date_submitted,\n Datestarted: surveyResult.date_started,\n Status: surveyResult.status,\n NbAsset: nbAsset,\n NbRequired: nbRequired,\n Score: Score,\n reqID: reqId,\n surveyTitle: surveyTitle,\n },\n };\n\n jsonDeSortie.json[\"Survey Questions and Answers\"] = surveyData;\n results.push(jsonDeSortie);\n\n }\n return (results);\n }\n\n}" + }, + "id": "91b288a2-16d5-4435-acc3-5f4ca128f32d", + "name": "Transform JSON2 - V13 - With V5", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 4800, + 1220 + ], + "onError": "continueRegularOutput" + }, + { + "parameters": { + "jsCode": "let output = []; // Initialize an array to hold the output for all items\n\nfunction generateCSV(entry, payload) {\n // Check if entry or entry.question is null\n if (!entry || !entry.question) {\n console.log('Skipping an entry due to missing data:', entry);\n return null; // Skip this entry\n }\n\n let questionType;\n \n /*if{entry.question.type === 'radio'\n const questionType = 'Single Selection';\n } else if {\n const questionType = 'Single Selection';\n \n } */\n\n switch (entry.question.type) {\n case 'radio':\n questionType = \"Single Selection\";\n break;\n case 'checkbox':\n questionType = \"Multiple Selection\";\n break;\n case 'textbox':\n questionType = \"Text\"; \n break; \n default:\n questionType = entry.question.type;\n}\n \n const questionId = entry.question.id;\n const questionTitle = entry.question.title ? entry.question.title.replace(/<[^>]*>/g, '') : ''; // Strip HTML tags from the question title\n\n // Join question answers into a single string, handle null or missing answers\n const questionAnswers = entry.question.answers && entry.question.answers.length > 0 ? entry.question.answers.map(answer => `${answer.id}: ${answer.title} (${answer.value})`).join(' ') : 'No predefined answers';\n\n // Process selected answers\n let selectedAnswers = '';\n if (entry.selectedAnswers && entry.selectedAnswers.length > 0) {\n // Check if the first element of selectedAnswers is a string (text response) or an object (predefined answer)\n if (typeof entry.selectedAnswers[0] === 'string') {\n // Handle text responses\n selectedAnswers = entry.selectedAnswers.join(', ');\n } else {\n // Handle object-based predefined answers\n selectedAnswers = entry.selectedAnswers.flat().map(answer => answer ? `${answer.id}: ${answer.title} (${answer.value})` : 'Missing answer').join(' ');\n }\n } else {\n selectedAnswers = 'No selected answer'; // Default text if no answers are selected\n }\n\n // Construct the CSV row object\n return {\n Id: payload.Id,\n ContactId: payload.ContactId,\n Contact: payload.Contact,\n Sguid: payload.Sguid,\n Datesubmitted: payload.Datesubmitted,\n Datestarted: payload.Datestarted,\n Status: payload.Status,\n NbAsset: payload.NbAsset,\n NbRequired: payload.NbRequired,\n Score: payload.Score,\n ReqId: payload.reqID,\n SurveyTitle: payload.surveyTitle,\n QuestionId: questionId,\n QuestionType: questionType,\n QuestionTitle: questionTitle,\n QuestionAnswers: questionAnswers,\n SelectedAnswers: selectedAnswers\n };\n}\n\nitems.forEach(item => {\n const payload = item.json; // Extract the payload from each item\n if (payload[\"Survey Questions and Answers\"]) {\n payload[\"Survey Questions and Answers\"].forEach(entry => {\n const csvRow = generateCSV(entry, payload);\n if (csvRow) { // Only add the row if it's not null\n output.push({ json: csvRow }); // Add the generated CSV row to the output array\n }\n });\n }\n});\n\nreturn output; // Return the output to be used by the next node\n" + }, + "id": "7b31d875-8319-4612-a8e9-bc4c6f4949f3", + "name": "Convert surveyAnswers to CSV1", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 5020, + 1220 + ] + }, + { + "parameters": {}, + "id": "f35be545-9d2a-4531-8123-e24dd0ee2cc4", + "name": "No Operation, do nothing", + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [ + 5500, + 1520 + ] + }, + { + "parameters": { + "content": "## Generate and Write HTML file\n", + "height": 80, + "width": 331.93837195405035 + }, + "id": "b83d2b1e-7eb8-402d-8320-215ee29d430f", + "name": "Note", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 5500, + 1140 + ] + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict" + }, + "conditions": [ + { + "id": "db7fe0b8-b651-4d26-b9a4-81a3642289a6", + "leftValue": true, + "rightValue": "N/A - Title not found.", + "operator": { + "type": "boolean", + "operation": "exists", + "singleValue": true + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "id": "c2bee9ed-e2df-4405-894d-b2914b731120", + "name": "If", + "type": "n8n-nodes-base.if", + "typeVersion": 2, + "position": [ + 5500, + 1220 + ], + "onError": "continueRegularOutput" + }, + { + "parameters": { + "jsCode": "return [\n {\n \"result_ok\": true,\n \"total_count\": 3859,\n \"page\": 1,\n \"total_pages\": 386,\n \"results_per_page\": 10,\n \"data\": [\n {\n \"id\": \"50238520\",\n \"team\": \"178\",\n \"type\": \"Standard Survey\",\n \"status\": \"Launched\",\n \"created_on\": \"2024-01-09 20:30:02\",\n \"modified_on\": \"2024-01-09 20:30:04\",\n \"title\": \"38171-50746943-Loyalty and Retention Representative-Survey\",\n \"statistics\": {\n \"Complete\": 3\n },\n \"links\": {\n \"edit\": \"https://app.alchemer-ca.com/projects/editor?id=50238520\",\n \"publish\": \"https://app.alchemer-ca.com/distribute/share?id=50238520\",\n \"default\": \"https://survey.alchemer-ca.com/s3/50238520/38171-50746943-Loyalty-and-Retention-Representative-Survey\"\n }\n },\n \n {\n \"id\": \"50235153\",\n \"team\": \"178\",\n \"type\": \"Standard Survey\",\n \"status\": \"Launched\",\n \"created_on\": \"2023-12-15 19:00:01\",\n \"modified_on\": \"2023-12-15 19:00:03\",\n \"title\": \"38171-50746943-Loyalty and Retention Representative-Survey\",\n \"statistics\": {\n \"Complete\": 11\n },\n \"links\": {\n \"edit\": \"https://app.alchemer-ca.com/projects/editor?id=50235153\",\n \"publish\": \"https://app.alchemer-ca.com/distribute/share?id=50235153\",\n \"default\": \"https://survey.alchemer-ca.com/s3/50235153/38171-50746943-Loyalty-and-Retention-Representative-Survey\"\n }\n},\n \n{\n\"id\": \n\"50237457\",\n\"team\": \n\"178\",\n\"type\": \n\"Standard Survey\",\n\"status\": \n\"Launched\",\n\"created_on\": \n\"2024-01-03 17:00:02\",\n\"modified_on\": \n\"2024-01-03 17:00:04\",\n\"title\": \n\"38221-52868878-Service Professional-Survey\",\n\"statistics\": \n{\n\"Complete\": \n2\n},\n\"links\": \n{\n\"edit\": \n\"https://app.alchemer-ca.com/projects/editor?id=50237457\",\n\"publish\": \n\"https://app.alchemer-ca.com/distribute/share?id=50237457\",\n\"default\": \n\"https://survey.alchemer-ca.com/s3/50237457/38221-52868878-Service-Professional-Survey\"\n}\n}\n ]\n }\n]" + }, + "id": "84b2c32d-91c3-4c72-9ddb-d561f77d640e", + "name": "Get Surveys Payload Hard Coded2", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 1640, + 1620 + ] + }, + { + "parameters": { + "fileSelector": "/n8n_files/IBU_JobCode_Mappings_11_16_2023.csv", + "options": {} + }, + "id": "7451fccf-36e6-468f-bd03-9370d1d5c86e", + "name": "Read/Write Files from Disk", + "type": "n8n-nodes-base.readWriteFile", + "typeVersion": 1, + "position": [ + -1180, + 1420 + ] + }, + { + "parameters": { + "content": "## Read JobCode Mappings from HR Data Mart and transform to JSON", + "height": 98.56500048149258, + "width": 448.4953787249474 + }, + "id": "6902befa-f719-4186-be2d-1ced24fc31f0", + "name": "Sticky Note6", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -1180, + 1320 + ] + }, + { + "parameters": { + "options": {} + }, + "id": "48536a1a-e5b0-4dce-8eb6-0c132fdcd040", + "name": "Extract JobCode Mappings From File", + "type": "n8n-nodes-base.extractFromFile", + "typeVersion": 1, + "position": [ + -1020, + 1420 + ], + "alwaysOutputData": false + }, + { + "parameters": { + "jsCode": "const results = [];\nfor (const item of items) {\n // Assuming each item has a `data` array you want to consolidate\n results.push(item.json);\n}\nreturn [{json: {allMappings: results}}];" + }, + "id": "99e07736-107e-42a0-b995-7949c586a50c", + "name": "ConsolidateJobCodeMappings", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + -860, + 1420 + ] + }, + { + "parameters": { + "operation": "toFile", + "fileFormat": "csv", + "binaryPropertyName": "fileBinary", + "options": { + "fileName": "ALCHEMER_SurveyResults_Export_LRD.csv", + "headerRow": false + } + }, + "id": "4324668f-63fe-4724-9854-f7645793bfa7", + "name": "Spreadsheet File1", + "type": "n8n-nodes-base.spreadsheetFile", + "typeVersion": 1, + "position": [ + 7060, + 1400 + ] + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "43f7ee35-9637-40f7-8cb9-4656289b5c61", + "name": "data", + "value": "={{DateTime.now().toFormat(\"yyyy-MM-dd HH:mm:ss\")}}", + "type": "string" + } + ] + }, + "options": {} + }, + "id": "12f8ad16-3d62-4634-a476-06eb97a774df", + "name": "Get CRD1", + "type": "n8n-nodes-base.set", + "typeVersion": 3.3, + "position": [ + 360, + 1420 + ] + }, + { + "parameters": { + "jsCode": "let CRD = [];\nCRD = $node[\"Get CRD1\"].json[\"data\"];\n\n// Wrap CRD in an object if it's not already one\nreturn [{json: { data: CRD }}];\n" + }, + "id": "88f7312c-ffcd-402f-b6db-06d2391b3b6f", + "name": "Update LRD with CRD - Code Version", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 6840, + 1400 + ] + }, + { + "parameters": { + "jsCode": "let results = [];\n\nconst getLrd = $node[\"Get LRD\"].json[\"data\"];\n\n// Parse the original date string to a Date object\nconst originalDate = new Date(getLrd);\n\n// Substract 16 days to the original date\noriginalDate.setDate(originalDate.getDate() - 16);\n\n// Format the new date back to the desired string format\n// Note: This is a simplistic way to format dates and might need adjustments for your exact needs\nconst formattedDate = originalDate.toISOString().replace(/T/, ' ').replace(/\\..+/, '');\n\nresults.push({formattedDate: formattedDate});\n\nreturn results;\n" + }, + "id": "730bdc4c-554f-4ec8-8db4-972d16a14b3f", + "name": "Set LRD to pick Surveys that were created 16 days ago - Should be closed now", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 1080, + 1420 + ] + }, + { + "parameters": { + "fields": { + "values": [ + { + "name": "formattedDate", + "stringValue": "={{ DateTime.fromFormat($json[\"formattedDate\"], \"yyyy-MM-dd hh:mm:ss\").toFormat('yyyy-MM-dd+hh:mm:ss') }}" + } + ] + }, + "options": {} + }, + "id": "e493dbbb-752a-4b01-9b75-8b0866d5e922", + "name": "Format LRD to Alchemer Query Format1", + "type": "n8n-nodes-base.set", + "typeVersion": 3.2, + "position": [ + 1260, + 1420 + ] + }, + { + "parameters": { + "authentication": "genericCredentialType", + "url": "=https://api.alchemer-ca.com/v5/survey?filter[field][0]=date_created&filter[operator][0]=>=&filter[value][0]={{ $json[\"formattedDate\"] }}", + "options": {}, + "queryParametersUi": { + "parameter": [ + { + "name": "=api_token", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token\"] }}" + }, + { + "name": "=api_token_secret", + "value": "={{ $('Execute Workflow - Set ALCHEMER Credentials').item.json[\"api_token_secret\"] }}" + } + ] + } + }, + "name": "Get Surveys", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 2, + "position": [ + 1640, + 1420 + ], + "id": "58790699-35e7-4772-a100-4c9a10884e78" + }, + { + "parameters": { + "jsCode": "// Assuming the input to this node is directly from the node that outputs `htmlContent`\nconst htmlContent = $input.all()[0].json.htmlContent; // Access the `htmlContent` from the input\n\n// Getting Filename Metadata\nconst surveyDetails = $node[\"Get Survey Details\"];\nconst surveyTitle = surveyDetails.json.data.title_ml.English;\nconst surveyId = surveyDetails.json.data.id;\nconst fileName = surveyTitle + '_AlchemerSurveyId_' + surveyId;\n\n// Convert the HTML string to binary data\nconst binaryData = Buffer.from(htmlContent, 'utf8');\n\n// Return the binary data with a specific file name for writing to disk\nreturn [{\n json: {\n // This part can contain any additional JSON data you wish to pass along\n },\n binary: {\n data: { // Ensure this key matches what your Write Binary File node expects\n data: binaryData.toString('base64'),\n mimeType: 'text/html',\n fileName: 'index.html',\n }\n }\n}];\n" + }, + "id": "a8ce73dd-dbcf-495c-b47b-44129b8ee021", + "name": "Convert HTML to Binary", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 5740, + 1200 + ], + "onError": "continueRegularOutput" + }, + { + "parameters": { + "jsCode": "// Obtain JobCode mappings to include in the Survey Results Header\nconst jobcodeMappings = $node[\"ConsolidateJobCodeMappings\"].json.allMappings;\n//console.log(jobcodeDetails);\n\n// Function to find job code details from JobCode Mappings Node\nfunction findJobCodeDetails(jobCode) {\n // Normalize input to handle potential formatting issues\n const normalizedJobCode = jobCode.trim();\n\n // Find the job code in the mappings, accounting for hidden characters in property names\n const jobDetails = jobcodeMappings.find((job) => {\n // Normalize keys in job object and find one that ends with \"JobCode\"\n const jobCodeKey = Object.keys(job).find((key) =>\n key.trim().endsWith(\"JobCode\")\n );\n if (!jobCodeKey) return false; // If no such key is found, skip this job\n\n // Compare the job code values after trimming\n return job[jobCodeKey].trim() === normalizedJobCode;\n });\n\n if (!jobDetails) {\n return { error: `JobCode ${jobCode} not found` };\n }\n\n // Return the specific details for the found job code\n return {\n NBREQUIREMENTS: jobDetails.NBREQUIREMENTS,\n NBASSET: jobDetails.NBASSET,\n MatrixIdentifier: jobDetails.MatrixIdentifier,\n };\n}\n\n//const jobCode = \"50700319\";\n// Use the function to get the details\n//const result = findJobCodeDetails(jobCode);\n\n// This function assumes that `items` is an array of objects where each object contains\n// both the survey/contact information and question information.\n\n// Step 1: Group questions by a unique identifier, e.g., ContactId or Sguid\nlet groupedByContactId = {};\nitems.forEach((item) => {\n const key = item.json.ContactId; // Use ContactId or another unique field as the key\n if (!groupedByContactId[key]) {\n groupedByContactId[key] = {\n surveyInfo: item.json,\n questions: [],\n };\n }\n groupedByContactId[key].questions.push(item.json);\n});\n\n// Step 2: Generate HTML for each group\nlet htmlContent = \"\";\nObject.keys(groupedByContactId).forEach((key) => {\n const group = groupedByContactId[key];\n\n const surveyJobCode = group.surveyInfo.SurveyTitle;\n console.log(surveyJobCode);\n\n const regex = /-(\\d+)-?([A-Za-z]+)?/;\n\n // Use the regex to execute a search on the input string\n const matches = surveyJobCode.match(regex);\n\n // `matches[1]` will contain the first capturing group, which is the job code\n let jobCode = null;\n if (matches && matches.length > 1) {\n jobCode = matches[1];\n }\n\n console.log(jobCode);\n const jobCodeMapping = findJobCodeDetails(jobCode);\n console.log(jobCodeMapping);\n\n let headerContent = `\n

${group.surveyInfo.SurveyTitle}

\n

\n

Candidate Name: ${group.surveyInfo.Contact}

\n

Requisition ID: ${group.surveyInfo.ReqId}

\n

Date Started: ${group.surveyInfo.Datestarted}

\n

Date Submitted: ${group.surveyInfo.Datesubmitted}

\n

Status: ${group.surveyInfo.Status}

\n

\n

Matrix Code: ${jobCodeMapping.MatrixIdentifier}

\n

Number of Assets: ${group.surveyInfo.NbAsset} / ${jobCodeMapping.NBASSET}

\n

Number Required: ${group.surveyInfo.NbRequired} / ${jobCodeMapping.NBREQUIREMENTS}

\n

Score: ${group.surveyInfo.Score}

\n \n

Results

`;\n\n// Add the image element\nconst imageUrl = 'https://images.ctfassets.net/fikanzmkdlqn/24Npa1YcWK80UQw5IZQunH/d7d7f2a3f487f82f1f56dcafcf3cdc86/TELUS_Logo.svg';\nheaderContent += ``;\n\n\n // Initialize an array to hold HTML for each question row within the current group\n let htmlRows = [];\n group.questions.forEach((question) => {\n // Process question details here as before\n const {\n QuestionId,\n QuestionType,\n QuestionTitle,\n QuestionAnswers,\n SelectedAnswers,\n } = question;\n const formattedAnswers = QuestionAnswers.replace(/ /g, \"
\");\n const formattedSelectedAnswers = SelectedAnswers.replace(/ /g, \"
\");\n\n let row = `\n ${QuestionType}\n ${QuestionId}\n ${QuestionTitle}\n ${formattedAnswers}\n ${formattedSelectedAnswers}\n `;\n htmlRows.push(row);\n });\n\n // Append the header and the table for the current group to the overall HTML content\n htmlContent += `${headerContent}\n \n \n \n \n \n \n \n \n \n \n ${htmlRows.join(\"\")}\n \n
Question TypeQuestion IdQuestion TitleQuestion AnswersSelected Answer

`; // Added a horizontal rule for separation between groups\n});\n\n// Output the complete HTML content\nreturn [{ json: { htmlContent } }];\n" + }, + "id": "e4fb07d4-688f-46ac-b826-70d1cddd4c0b", + "name": "Generate HTML Format Survey Results - Code4", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 5240, + 1220 + ], + "onError": "continueRegularOutput" + }, + { + "parameters": { + "method": "POST", + "url": "https://demo.gotenberg.dev/forms/chromium/convert/html", + "sendBody": true, + "contentType": "multipart-form-data", + "bodyParameters": { + "parameters": [ + { + "parameterType": "formBinaryData", + "name": "files", + "inputDataFieldName": "=data" + } + ] + }, + "options": {} + }, + "id": "da429508-967e-4a8d-a628-1b5b746f4d8c", + "name": "HTTP Request - PDF Conversion POST", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.1, + "position": [ + 6020, + 1200 + ] + }, + { + "parameters": { + "jsCode": "// Getting Filename Metadata\nconst surveyDetails = $node[\"Get Survey Details\"];\nconst surveyTitle = surveyDetails.json.data.title_ml.English;\nconst surveyId = surveyDetails.json.data.id;\nconst fileName = surveyTitle + '_AlchemerSurveyId_' + surveyId;\n\n$input.item.binary.data.fileName = fileName + '.pdf';\n \nreturn $input.item;" + }, + "id": "9da94f59-b297-470c-b0f2-e432f4629750", + "name": "Change file extension to PDF", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 6240, + 1200 + ] + }, + { + "parameters": { + "fileName": "=/n8n_outbound/{{ $binary.data.fileName }}", + "dataPropertyName": "=data", + "options": { + "append": false + } + }, + "id": "ac9db0be-7c57-4289-a4bd-be18e8d4580d", + "name": "Write Binary File2", + "type": "n8n-nodes-base.writeBinaryFile", + "typeVersion": 1, + "position": [ + 6480, + 1200 + ], + "onError": "continueRegularOutput" + }, + { + "parameters": { + "content": "## Convert HTML to PDF and rename\n", + "height": 80, + "width": 549.5842642687602 + }, + "id": "caf5c7e1-0c5b-43b4-8f4c-dc3547dc8a9f", + "name": "Note1", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 6020, + 1120 + ] + }, + { + "parameters": { + "content": "## Read JobCode Score Mappings from ALCHEMER and transform to JSON", + "height": 98.56500048149258, + "width": 448.4953787249474 + }, + "id": "8b2d7d84-73ae-47b2-ac5e-9ddec0c687df", + "name": "Sticky Note7", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -600, + 1320 + ] + }, + { + "parameters": { + "fileSelector": "/n8n_files/JobCode_AnswerScore_Mapping.csv", + "options": {} + }, + "id": "4d35399b-2d9d-4691-9976-470ec6be9b57", + "name": "Read/Write Files from Disk1", + "type": "n8n-nodes-base.readWriteFile", + "typeVersion": 1, + "position": [ + -600, + 1420 + ] + }, + { + "parameters": { + "options": {} + }, + "id": "484c3fff-fc73-4d4f-98d2-f641a2f5ff1a", + "name": "Extract JobCode Mappings From File1", + "type": "n8n-nodes-base.extractFromFile", + "typeVersion": 1, + "position": [ + -440, + 1420 + ], + "alwaysOutputData": false + }, + { + "parameters": { + "jsCode": "const results = [];\nfor (const item of items) {\n // Assuming each item has a `data` array you want to consolidate\n results.push(item.json);\n}\nreturn [{json: {allMappings: results}}];" + }, + "id": "783b233d-f245-4bae-a1a3-10a29820ab90", + "name": "ConsolidateJobCodeMappings1", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + -260, + 1420 + ] + }, + { + "parameters": { + "fileName": "=/n8n_outbound/{{ $binary.data.fileName }}.html", + "dataPropertyName": "=data", + "options": { + "append": false + } + }, + "id": "c868d9ff-7d4d-4105-a2cf-6975b5aab502", + "name": "Write Binary File", + "type": "n8n-nodes-base.writeBinaryFile", + "typeVersion": 1, + "position": [ + 6460, + 920 + ], + "onError": "continueRegularOutput" + }, + { + "parameters": { + "jsCode": "// Assuming the input to this node is directly from the node that outputs `htmlContent`\nconst htmlContent = $input.all()[0].json.htmlContent; // Access the `htmlContent` from the input\n\n// Getting Filename Metadata\nconst surveyDetails = $node[\"Get Survey Details\"];\nconst surveyTitle = surveyDetails.json.data.title_ml.English;\nconst surveyId = surveyDetails.json.data.id;\nconst fileName = surveyTitle + '_AlchemerSurveyId_' + surveyId;\n\n// Convert the HTML string to binary data\nconst binaryData = Buffer.from(htmlContent, 'utf8');\n\n// Return the binary data with a specific file name for writing to disk\nreturn [{\n json: {\n // This part can contain any additional JSON data you wish to pass along\n },\n binary: {\n data: { // Ensure this key matches what your Write Binary File node expects\n data: binaryData.toString('base64'),\n mimeType: 'text/html',\n fileName: fileName,\n }\n }\n}];\n" + }, + "id": "b7ebbde2-4ecd-4f46-a3a5-45abf1e1fc28", + "name": "Convert HTML to Binary1", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 6255, + 920 + ], + "onError": "continueRegularOutput" + }, + { + "parameters": { + "content": "## Generate and Write HTML file\n", + "height": 80, + "width": 527.9516626428136 + }, + "id": "9d53710c-eebe-4122-abe7-d3c5886f9f49", + "name": "Note4", + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + 6020, + 860 + ] + } + ], + "pinData": { + "Getting the SurveysResults output and put them in a list with only IDs": [ + { + "json": { + "id": "50245530" + } + } + ], + "Convert surveyAnswers to CSV1": [ + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 2, + "QuestionType": "Single Selection", + "QuestionTitle": "Do you have customer service experience?", + "QuestionAnswers": "2_10001: Yes (Required) 2_10002: No (No)", + "SelectedAnswers": "2_10001: Yes (Required)" + } + }, + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 3, + "QuestionType": "Single Selection", + "QuestionTitle": "How many years of customer service experience do you have? (Face to face or over the phone to solve customer problems in a professional, friendly and efficient manner)", + "QuestionAnswers": "3_10003: None (None) 3_10004: Less than 1 year (Asset) 3_10005: 1 year, less than 2 (Asset) 3_10006: 2 years, less than 3 (Asset) 3_10007: 3 years, less than 4 (Asset) 3_10008: 4 years, less than 5 (Asset) 3_10009: 5+ years (Asset)", + "SelectedAnswers": "3_10009: 5+ years (Asset)" + } + }, + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 4, + "QuestionType": "Single Selection", + "QuestionTitle": "Please indicate the amount of customer SALES experience you have had. (Face to face or over the phone to present CUSTOMER/CLIENT SOLUTIONS in a professional, friendly and efficient manner).", + "QuestionAnswers": "4_10010: No Experience (No Experience) 4_10011: Under 6 months experience (Asset) 4_10012: 6 months - 1 year (Asset) 4_10013: 1 - 2 years (Asset) 4_10014: 2 - 5 years (Asset) 4_10015: 5+ years (Asset)", + "SelectedAnswers": "4_10015: 5+ years (Asset)" + } + }, + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 5, + "QuestionType": "Multiple Selection", + "QuestionTitle": "From the list below please indicate which of the following areas you have working knowledge of.", + "QuestionAnswers": "5_10016: Automated provisioning, ticketing, testing, and dispatch systems (Asset) 5_10017: Health and Safety practices (Asset) 5_10018: Knowledge of products and services for business and residential customers (Asset) 5_10019: Installation, maintenance or testing / analysis of TELUS products & services (hardware and software) (Asset) 5_10020: Routers, modems, line drivers, hubs, switches (Asset) 5_10021: NONE of the above (NONE of the above)", + "SelectedAnswers": "5_10016: Automated provisioning, ticketing, testing, and dispatch systems (Asset) 5_10017: Health and Safety practices (Asset) 5_10018: Knowledge of products and services for business and residential customers (Asset) 5_10019: Installation, maintenance or testing / analysis of TELUS products & services (hardware and software) (Asset) 5_10020: Routers, modems, line drivers, hubs, switches (Asset)" + } + }, + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 6, + "QuestionType": "Multiple Selection", + "QuestionTitle": "In which of the following areas do you have prior experience?", + "QuestionAnswers": "6_10022: Use of hand tools (Asset) 6_10023: Use of test equipment (Asset) 6_10024: Health and safety practices (Asset) 6_10025: NONE of the above (NONE of the above)", + "SelectedAnswers": "6_10022: Use of hand tools (Asset) 6_10023: Use of test equipment (Asset) 6_10024: Health and safety practices (Asset)" + } + }, + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 7, + "QuestionType": "Multiple Selection", + "QuestionTitle": "With which of the following services do you have a working knowledge of?", + "QuestionAnswers": "7_10026: Residential Consumer products (Asset) 7_10027: TELUS Security & Automation Services (Asset) 7_10028: TELUS Business Products (Asset) 7_10029: Mobility or Wireless Products including SmartHub, WSHIA, Smartphones, etc.) (Asset) 7_10030: Outside plant infrastructure (Asset)", + "SelectedAnswers": "7_10026: Residential Consumer products (Asset) 7_10027: TELUS Security & Automation Services (Asset) 7_10028: TELUS Business Products (Asset) 7_10029: Mobility or Wireless Products including SmartHub, WSHIA, Smartphones, etc.) (Asset) 7_10030: Outside plant infrastructure (Asset)" + } + }, + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 8, + "QuestionType": "Single Selection", + "QuestionTitle": "Do you currently hold a valid class 5 Driver’s license?", + "QuestionAnswers": "8_10031: Yes (Required) 8_10032: No (No)", + "SelectedAnswers": "8_10031: Yes (Required)" + } + }, + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 9, + "QuestionType": "Single Selection", + "QuestionTitle": "This position requires normal colour vision to work with colour-coded wiring and/or coloured design documents. Are you able to meet this requirement?\n(Note: if you have a form of colour blindness, please ensure you contact the hiring manager prior to the posting close date).", + "QuestionAnswers": "9_10033: Yes (Required) 9_10034: No (No)", + "SelectedAnswers": "9_10033: Yes (Required)" + } + }, + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 10, + "QuestionType": "Single Selection", + "QuestionTitle": "Are you fluent in speaking English?", + "QuestionAnswers": "10_10035: Yes (Required) 10_10036: No (No)", + "SelectedAnswers": "10_10035: Yes (Required)" + } + }, + { + "json": { + "Id": "1", + "ContactId": "645644343", + "Contact": "Test Candidate 1", + "Sguid": "ergerg4534453543ger", + "Datesubmitted": "2024-02-26 03:26:10 GMT", + "Datestarted": "2024-02-26 03:20:49 GMT", + "Status": "Complete", + "NbAsset": 20, + "NbRequired": 14, + "Score": "100", + "ReqId": "39209", + "SurveyTitle": "34434-123456678-Service Professional-Survey", + "QuestionId": 11, + "QuestionType": "Multiple Selection", + "QuestionTitle": "From the list below, indicate the work-related conditions you are willing to accept as part of the job.", + "QuestionAnswers": "11_10037: Working with minimal supervision (Required) 11_10038: Working in a team-based environment (Required) 11_10039: Working in physically demanding conditions and extreme weather (Required) 11_10040: Driving in various weather conditions (Required) 11_10041: Working under time constraints/pressure (Required) 11_10042: Working in a measured and monitored environment (Required) 11_10043: Adapting/adjusting to changing working conditions (Required) 11_10044: Working different job assignments when required (Required) 11_10045: NONE of the above (NONE of the above)", + "SelectedAnswers": "11_10037: Working with minimal supervision (Required) 11_10038: Working in a team-based environment (Required) 11_10039: Working in physically demanding conditions and extreme weather (Required) 11_10040: Driving in various weather conditions (Required) 11_10041: Working under time constraints/pressure (Required) 11_10042: Working in a measured and monitored environment (Required) 11_10043: Adapting/adjusting to changing working conditions (Required) 11_10044: Working different job assignments when required (Required)" + } + } + ] + }, + "connections": { + "Start": { + "main": [ + [ + { + "node": "Read/Write Files from Disk", + "type": "main", + "index": 0 + } + ] + ] + }, + "Execute Workflow - Set ALCHEMER Credentials": { + "main": [ + [ + { + "node": "Get CRD1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Move Binary Data": { + "main": [ + [ + { + "node": "Get LRD", + "type": "main", + "index": 0 + } + ] + ] + }, + "Set _OnlyPullData_Node": { + "main": [ + [ + { + "node": "Build Surveys Array", + "type": "main", + "index": 0 + } + ] + ] + }, + "Build Surveys Array": { + "main": [ + [ + { + "node": "Getting the SurveysResults output and put them in a list with only IDs", + "type": "main", + "index": 0 + } + ] + ] + }, + "Loop Over Items": { + "main": [ + [ + { + "node": "Update LRD with CRD - Code Version", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Get Survey/surveyquestions", + "type": "main", + "index": 0 + } + ] + ] + }, + "surveyquestions_Set _OnlyPullData_Node": { + "main": [ + [ + { + "node": "Build Survey Answers Array", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Survey/surveyquestions": { + "main": [ + [ + { + "node": "surveyquestions_Set _OnlyPullData_Node", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Survey Details": { + "main": [ + [ + { + "node": "Get Survey/surveyCampaign", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Survey/surveyCampaign": { + "main": [ + [ + { + "node": "Get Survey/surveyCampaign/surveyContact", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Survey/surveyCampaign/surveyContact": { + "main": [ + [ + { + "node": "surveycampaign/surveycontact Set _OnlyPullData_Node3", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "No Operation, do nothing1", + "type": "main", + "index": 0 + } + ] + ] + }, + "surveycampaign/surveycontact Set _OnlyPullData_Node3": { + "main": [ + [ + { + "node": "Get Survey Results", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get LRD": { + "main": [ + [ + { + "node": "Set LRD to pick Surveys that were created 16 days ago - Should be closed now", + "type": "main", + "index": 0 + } + ] + ] + }, + "ReadBinaryFile": { + "main": [ + [ + { + "node": "Move Binary Data", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Survey Results": { + "main": [ + [ + { + "node": "surveyresults_Set _OnlyPullData_Node1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Getting the SurveysResults output and put them in a list with only IDs": { + "main": [ + [ + { + "node": "Loop Over Items", + "type": "main", + "index": 0 + } + ] + ] + }, + "surveyresults_Set _OnlyPullData_Node1": { + "main": [ + [ + { + "node": "Transform JSON2 - V13 - With V5", + "type": "main", + "index": 0 + } + ] + ] + }, + "Transform JSON2 - V13 - With V5": { + "main": [ + [ + { + "node": "Loop Over Items", + "type": "main", + "index": 0 + }, + { + "node": "Convert surveyAnswers to CSV1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert surveyAnswers to CSV1": { + "main": [ + [ + { + "node": "Generate HTML Format Survey Results - Code4", + "type": "main", + "index": 0 + } + ] + ] + }, + "No Operation, do nothing1": { + "main": [ + [ + { + "node": "Loop Over Items", + "type": "main", + "index": 0 + } + ] + ] + }, + "If": { + "main": [ + [ + { + "node": "Convert HTML to Binary", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "No Operation, do nothing", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Surveys Payload Hard Coded2": { + "main": [ + [ + { + "node": "Set _OnlyPullData_Node", + "type": "main", + "index": 0 + } + ] + ] + }, + "Read/Write Files from Disk": { + "main": [ + [ + { + "node": "Extract JobCode Mappings From File", + "type": "main", + "index": 0 + } + ] + ] + }, + "Extract JobCode Mappings From File": { + "main": [ + [ + { + "node": "ConsolidateJobCodeMappings", + "type": "main", + "index": 0 + } + ] + ] + }, + "ConsolidateJobCodeMappings": { + "main": [ + [ + { + "node": "Read/Write Files from Disk1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Spreadsheet File1": { + "main": [ + [ + { + "node": "Write Binary File1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get CRD1": { + "main": [ + [ + { + "node": "ReadBinaryFile", + "type": "main", + "index": 0 + } + ] + ] + }, + "Update LRD with CRD - Code Version": { + "main": [ + [ + { + "node": "Spreadsheet File1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Set LRD to pick Surveys that were created 16 days ago - Should be closed now": { + "main": [ + [ + { + "node": "Format LRD to Alchemer Query Format1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Surveys": { + "main": [ + [ + { + "node": "Set _OnlyPullData_Node", + "type": "main", + "index": 0 + } + ] + ] + }, + "Format LRD to Alchemer Query Format1": { + "main": [ + [ + { + "node": "Get Surveys Payload Hard Coded2", + "type": "main", + "index": 0 + } + ] + ] + }, + "Generate HTML Format Survey Results - Code4": { + "main": [ + [ + { + "node": "If", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP Request - PDF Conversion POST": { + "main": [ + [ + { + "node": "Change file extension to PDF", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert HTML to Binary": { + "main": [ + [ + { + "node": "Convert HTML to Binary1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Change file extension to PDF": { + "main": [ + [ + { + "node": "Write Binary File2", + "type": "main", + "index": 0 + } + ] + ] + }, + "Write Binary File2": { + "main": [ + [ + { + "node": "Loop Over Items", + "type": "main", + "index": 0 + } + ] + ] + }, + "Read/Write Files from Disk1": { + "main": [ + [ + { + "node": "Extract JobCode Mappings From File1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Extract JobCode Mappings From File1": { + "main": [ + [ + { + "node": "ConsolidateJobCodeMappings1", + "type": "main", + "index": 0 + } + ] + ] + }, + "ConsolidateJobCodeMappings1": { + "main": [ + [ + { + "node": "Execute Workflow - Set ALCHEMER Credentials", + "type": "main", + "index": 0 + } + ] + ] + }, + "Build Survey Answers Array": { + "main": [ + [ + { + "node": "Get Survey Details", + "type": "main", + "index": 0 + } + ] + ] + }, + "Convert HTML to Binary1": { + "main": [ + [ + { + "node": "Write Binary File", + "type": "main", + "index": 0 + } + ] + ] + }, + "Write Binary File": { + "main": [ + [ + { + "node": "Loop Over Items", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + }, + "versionId": "419b3c4b-f952-4496-a848-0ff2e5d81727", + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "b99a2cdf4a75ce5760ec5f4ad5815e2e26fe5e5252567e8dd6478c1848d22248" + }, + "id": "P0m7s3fD6SNgatAR", + "tags": [ + { + "createdAt": "2023-09-25T20:05:02.411Z", + "updatedAt": "2023-09-25T20:05:02.411Z", + "id": "cxKKJoYEUMWMZxE2", + "name": "ALCHEMER" + } + ] +} \ No newline at end of file