Free javascript Hosting


plugthem-voc-kiosk-v1-0-dev.js

Uploaded on Nov 30 2021 01:17 by resparza

/*!
* VocKioskJS Interactions Creator v1.0-dev
* (c) 2015-2021 plugThem SA
* License: https://plugthem.social/
* Contact: info@plugthem.social
* Account: Salud S.A.
*/

//let env = "https://saludsa.voc"; // DEV LOCAL
let env = "https://pruebas2-saludsa.voc.cx"; // TEST STAGE
let url_api = env + "/api/voc/hits/interaction/createByEdr";
let token = "uqI9g0NpB9HRQrTA3DCsyqsNopzrl4OKyqffXdq8ZSvRdPAJoocwZzf1JJJnW8WbCCgCucOQQRkb8qmP"; // masilva
let survey_uuid = "2762cacb-4994-406d-890f-3660c191fd1f"; // Survey for Kioskos

function vocInteraction(customer_id, ext_ticket_id = null, employee_name = null){
var interaction_data = {
"survey_uuid": survey_uuid,
"contact": {
"external_data_ref": customer_id
},
"custom_data": {
"numero_de_ticket": ext_ticket_id,
"nombre_del_agente": employee_name
}
};
fetch(url_api, {
method: "POST",
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer ' + token
},
body: JSON.stringify(interaction_data)
})
.then(function(response) {
//console.log(response.status); // Will show you the status
if (!response.ok) {
throw new Error("HTTP status " + response.status);
}
return response.json();
})
.then(function(voc_data) {
//console.log(voc_data);
if(voc_data.url){
window.open(voc_data.url, "_blank", "location=no,menubar=no,titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,top=100,left=500,width=500,height=700");
}
})
.catch(function(error) {
console.log("VOC request error", error);
});
}

Back to list