|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="it"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 6 | + <title>Benvenuto - Demo </title> |
| 7 | + <style> |
| 8 | + body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #ffffff; margin: 0; } |
| 9 | + .box { background: #fff; padding: 24px; border: 1px solid #eee; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.05); text-align: left; width: 350px; } |
| 10 | + h1 { margin: 0 0 20px; font-size: 24px; text-align: center; color: #333; } |
| 11 | + .info-row { margin-bottom: 10px; font-size: 16px; color: #555; border-bottom: 1px solid #f0f0f0; padding-bottom: 5px; } |
| 12 | + .info-row strong { color: #000; display: inline-block; width: 100px; } |
| 13 | + |
| 14 | + a.button { display: block; text-align: center; margin-top: 20px; padding: 12px 14px; background: #0969da; color: #fff; border-radius: 6px; text-decoration: none; cursor: pointer; } |
| 15 | + a.button:hover { background: #0758b7; } |
| 16 | + a.button.disabled { background: #ccc; cursor: not-allowed; } |
| 17 | + </style> |
| 18 | +</head> |
| 19 | +<body> |
| 20 | + <div class="box"> |
| 21 | + <h1>Dati Utente</h1> |
| 22 | + |
| 23 | + <div class="info-row"><strong>name:</strong> <span id="disp-name"></span></div> |
| 24 | + <div class="info-row"><strong>userType:</strong> <span id="disp-type"></span></div> |
| 25 | + <div class="info-row"><strong>nationality:</strong> <span id="disp-nat"></span></div> |
| 26 | + <div class="info-row"><strong>userId:</strong> <span id="disp-id"></span></div> |
| 27 | + |
| 28 | + <a id="btn-open-chat" class="button disabled">Inizializzazione Chat...</a> |
| 29 | + |
| 30 | + <div style="margin-top: 20px; text-align: center;"> |
| 31 | + <button onclick="console.log('Logout cliccato (nessuna azione)')" style="background: none; border: none; color: #dc3545; cursor: pointer; text-decoration: underline; font-size: 14px;"> |
| 32 | + Logout |
| 33 | + </button> |
| 34 | + </div> |
| 35 | + </div> |
| 36 | + |
| 37 | + <script> |
| 38 | + // Definiamo le variabili |
| 39 | + const name = "Mario Rossi"; |
| 40 | + const userType = "consultant"; |
| 41 | + const nationality = "IT"; |
| 42 | + const userId = "12345"; |
| 43 | + |
| 44 | + // Show Data |
| 45 | + document.getElementById('disp-name').innerText = name; |
| 46 | + document.getElementById('disp-type').innerText = userType; |
| 47 | + document.getElementById('disp-nat').innerText = nationality; |
| 48 | + document.getElementById('disp-id').innerText = userId; |
| 49 | + |
| 50 | + // Gestione click bottone chat |
| 51 | + const btnChat = document.getElementById('btn-open-chat'); |
| 52 | + btnChat.onclick = function() { |
| 53 | + if (btnChat.classList.contains('disabled')) return; |
| 54 | + console.log("Tentativo apertura chat manuale..."); |
| 55 | + // Utilizziamo l'API di utilità per aprire la chat |
| 56 | + embeddedservice_bootstrap.utilAPI.launchChat() |
| 57 | + .catch((e) => console.error("Errore apertura chat:", e)); |
| 58 | + }; |
| 59 | + </script> |
| 60 | + |
| 61 | + <script type='text/javascript'> |
| 62 | + function initEmbeddedMessaging() { |
| 63 | + console.log("--> INIZIO INIT SALESFORCE (Nuovo Ambiente) <--"); |
| 64 | + try { |
| 65 | + // --- SETTINGS --- |
| 66 | + // definiamo la lingua del sito |
| 67 | + embeddedservice_bootstrap.settings.language = 'it'; |
| 68 | + // Disabilita input utente Mentre agente scrive se necessario |
| 69 | + embeddedservice_bootstrap.settings.enableUserInputForConversationWithBot = false; |
| 70 | + |
| 71 | + // --- EVENT LISTENER |
| 72 | + window.addEventListener("onEmbeddedMessagingReady", () => { |
| 73 | + console.log("2. EVENTO RICEVUTO: Messaging Ready!"); |
| 74 | + |
| 75 | + try { |
| 76 | + // --- PASSAGGIO PARAMETRI HIDDEN --- |
| 77 | + // Qui passiamo le variabili definite |
| 78 | + embeddedservice_bootstrap.prechatAPI.setHiddenPrechatFields({ |
| 79 | + "name": name, |
| 80 | + "userType": userType, |
| 81 | + "nationality": nationality, |
| 82 | + "userId": userId |
| 83 | + }); |
| 84 | + |
| 85 | + console.log("3. Parametri Hidden impostati correttamente: ", { name, userType, nationality, userId }); |
| 86 | + } catch (e) { |
| 87 | + console.error("Errore nel settare i campi hidden:", e); |
| 88 | + } |
| 89 | + |
| 90 | + // Abilitiamo il bottone grafico |
| 91 | + const btn = document.getElementById('btn-open-chat'); |
| 92 | + btn.innerText = "Parla con l'Agente"; |
| 93 | + btn.classList.remove('disabled'); |
| 94 | + }); |
| 95 | + |
| 96 | + // --- SNIPPET INIT --- |
| 97 | + embeddedservice_bootstrap.init( |
| 98 | + '00DUA000003hFV7', |
| 99 | + 'ai_chogangroupspa_com', |
| 100 | + 'https://chogangroup--devai2.sandbox.my.site.com/ESWaichogangroupspacom1764335835157', |
| 101 | + { |
| 102 | + scrt2URL: 'https://chogangroup--devai2.sandbox.my.salesforce-scrt.com' |
| 103 | + } |
| 104 | + ); |
| 105 | + |
| 106 | + } catch (err) { |
| 107 | + console.error('Error loading Embedded Messaging: ', err); |
| 108 | + } |
| 109 | + }; |
| 110 | + </script> |
| 111 | + |
| 112 | + <script type='text/javascript' src='https://chogangroup--devai2.sandbox.my.site.com/ESWaichogangroupspacom1764335835157/assets/js/bootstrap.min.js' onload='initEmbeddedMessaging()'></script> |
| 113 | + |
| 114 | +</body> |
| 115 | +</html> |
0 commit comments