-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwelcome.html
More file actions
111 lines (92 loc) · 4.22 KB
/
welcome.html
File metadata and controls
111 lines (92 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Benvenuto</title>
<style>
body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #f4f6f8; margin: 0; }
.box { background: #fff; padding: 24px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); text-align: center; }
h1 { margin: 0 0 10px; }
.email { color: #444; margin-bottom: 16px; }
a.button { display: inline-block; padding: 10px 14px; background: #0969da; color: #fff; border-radius: 6px; text-decoration: none; cursor: pointer; }
a.button:hover { background: #0758b7; }
a.button.disabled { background: #ccc; cursor: not-allowed; }
</style>
</head>
<body>
<div class="box">
<h1 id="welcome-message">Benvenuto!</h1>
<p class="email" id="email-line"></p>
<a id="btn-open-chat" class="button disabled">Caricamento Chat...</a>
<div style="margin-top: 20px; border-top: 1px solid #eee; padding-top: 15px;">
<button onclick="logout()" style="background: none; border: none; color: #dc3545; cursor: pointer; text-decoration: underline; font-size: 14px;">
Logout
</button>
</div>
</div>
<script>
const name = localStorage.getItem('name');
const email = localStorage.getItem('email');
const displayName = name || 'Utente';
document.getElementById('welcome-message').innerText = `Benvenuto, ${displayName}!`;
if (email) {
document.getElementById('email-line').innerText = `Email: ${email}`;
} else {
document.getElementById('email-line').innerText = `Email non disponibile`;
}
const btnChat = document.getElementById('btn-open-chat');
btnChat.onclick = function() {
if (btnChat.classList.contains('disabled')) {
console.warn("Chat non ancora pronta.");
return;
}
console.log("Tentativo di apertura chat...");
embeddedservice_bootstrap.utilAPI.launchChat()
.catch((e) => console.error("Errore apertura chat:", e));
};
</script>
<script type='text/javascript'>
function initEmbeddedMessaging() {
console.log("--> INIZIO INIT SALESFORCE <--");
try {
const userEmail = localStorage.getItem('email') || '';
console.log("1. Email recuperata:", userEmail);
// --- SEZIONE SETTINGS ---
embeddedservice_bootstrap.settings.language = 'it';
// BLOCCO SCRITTURA UTENTE (Correttamente posizionato qui!)
embeddedservice_bootstrap.settings.enableUserInputForConversationWithBot = false;
// --- EVENT LISTENER ---
window.addEventListener("onEmbeddedMessagingReady", () => {
console.log("2. EVENTO RICEVUTO: Messaging Ready!");
try {
embeddedservice_bootstrap.prechatAPI.setHiddenPrechatFields({
"Login_Email_Consulente": userEmail
});
console.log("3. Parametri hidden impostati.");
} catch (e) {
console.error("Errore nel settare i campi hidden:", e);
}
// Abilitiamo il bottone
const btn = document.getElementById('btn-open-chat');
btn.innerText = "Parla con l'Agente";
btn.classList.remove('disabled');
});
// --- INIT ---
embeddedservice_bootstrap.init(
'00DfZ000000Aod3',
'Case_Support_Agent_With_variable',
'https://chogangroup--devai1.sandbox.my.site.com/ESWCaseSupportAgentTes1764164304917',
{
scrt2URL: 'https://chogangroup--devai1.sandbox.my.salesforce-scrt.com'
}
);
} catch (err) {
console.error('Eccezione nello script di init: ', err);
}
};
</script>
<script type='text/javascript' src='https://chogangroup--devai1.sandbox.my.site.com/ESWCaseSupportAgentTes1764164304917/assets/js/bootstrap.min.js' onload='initEmbeddedMessaging()'></script>
<script src="script.js"></script>
</body>
</html>