This commit is contained in:
Oliver
2025-10-04 16:48:57 -03:00
parent 3d263f7c4e
commit a6bea0e6c8

View File

@@ -170,12 +170,12 @@ Please note: it does not cover general Odoo usage or functional questions.
const uuid = params.get("uuid"); const uuid = params.get("uuid");
// Generate UUID once per page load // Generate UUID once per page load
function generateUUID(){ function generateChatID(){
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
); );
} }
const CLIENT_UUID = generateUUID(); const chatId = generateChatID();
function formatTime(date){ function formatTime(date){
return date.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}); return date.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
@@ -221,7 +221,7 @@ Please note: it does not cover general Odoo usage or functional questions.
if(!text) return; if(!text) return;
// show user message // show user message
if(text.toLowerCase().startsWith('/ticket')){ if(text.toLowerCase().startsWith('/ticket')){
text = `/ticket ${uuid}`; // Add UUID after /ticket text = `/ticket UUID:${uuid} chatId: ${chatId}`; // Add UUID after /ticket
} }
appendMessage(text, 'me'); appendMessage(text, 'me');
input.value = ''; input.value = '';
@@ -240,7 +240,7 @@ Please note: it does not cover general Odoo usage or functional questions.
try{ try{
// Post to webhook - expecting a JSON response. Adapt to your backend. // Post to webhook - expecting a JSON response. Adapt to your backend.
const payload = {text: text, uuid: CLIENT_UUID}; const payload = {text: text, uuid: uuid, chatid: chatId};
const res = await fetch(WEBHOOK, { const res = await fetch(WEBHOOK, {
method: 'POST', method: 'POST',
headers: { headers: {