33< head >
44 < meta charset ="UTF-8 " />
55 < meta name ="viewport " content ="width=device-width, initial-scale=1 " />
6- < title > Benvenuto - Demo </ title >
6+ < title > Demo Salesforce - Auto Load </ title >
77 < style >
88 body { font-family : Arial, sans-serif; display : flex; justify-content : center; align-items : center; min-height : 100vh ; background : # ffffff ; margin : 0 ; }
99 .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 ; }
1010 h1 { margin : 0 0 20px ; font-size : 24px ; text-align : center; color : # 333 ; }
1111 .info-row { margin-bottom : 10px ; font-size : 16px ; color : # 555 ; border-bottom : 1px solid # f0f0f0 ; padding-bottom : 5px ; }
1212 .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; }
1713 </ style >
1814</ head >
1915< body >
16+
2017 < div class ="box ">
2118 < h1 > Dati Utente</ h1 >
2219
2320 < div class ="info-row "> < strong > name:</ strong > < span id ="disp-name "> </ span > </ div >
2421 < div class ="info-row "> < strong > userType:</ strong > < span id ="disp-type "> </ span > </ div >
2522 < div class ="info-row "> < strong > nationality:</ strong > < span id ="disp-nat "> </ span > </ div >
2623 < 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 >
2924
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 >
25+ < p style ="text-align:center; color:#999; font-size:12px; margin-top:20px; ">
26+ Chogan
27+ </ p >
3528 </ div >
3629
3730 < script >
38- // Definiamo le variabili
31+ // --- Variabili Hardcodate ---
3932 const name = "Mario Rossi" ;
4033 const userType = "consultant" ;
4134 const nationality = "IT" ;
4235 const userId = "12345" ;
4336
44- // Show Data
37+ // Mostra i dati a video
4538 document . getElementById ( 'disp-name' ) . innerText = name ;
4639 document . getElementById ( 'disp-type' ) . innerText = userType ;
4740 document . getElementById ( 'disp-nat' ) . innerText = nationality ;
4841 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- } ;
5942 </ script >
6043
6144 < script type ='text/javascript '>
6245 function initEmbeddedMessaging ( ) {
63- console . log ( "--> INIZIO INIT SALESFORCE (Nuovo Ambiente) <--" ) ;
46+ console . log ( "--> INIT SALESFORCE <--" ) ;
6447 try {
65- // --- SETTINGS ---
66- // definiamo la lingua del sito
48+ // Settings Lingua e Input
6749 embeddedservice_bootstrap . settings . language = 'it' ;
68- // Disabilita input utente Mentre agente scrive se necessario
6950 embeddedservice_bootstrap . settings . enableUserInputForConversationWithBot = false ;
7051
71- // --- EVENT LISTENER
52+ // Quando la chat è pronta (caricata), imposta i campi e basta.
7253 window . addEventListener ( "onEmbeddedMessagingReady" , ( ) => {
73- console . log ( "2. EVENTO RICEVUTO: Messaging Ready! " ) ;
54+ console . log ( "Messaging Ready: Imposto i campi nascosti... " ) ;
7455
7556 try {
76- // --- PASSAGGIO PARAMETRI HIDDEN ---
77- // Qui passiamo le variabili definite
7857 embeddedservice_bootstrap . prechatAPI . setHiddenPrechatFields ( {
7958 "name" : name ,
8059 "userType" : userType ,
8160 "nationality" : nationality ,
8261 "userId" : userId
8362 } ) ;
84-
85- console . log ( "3. Parametri Hidden impostati correttamente: " , { name, userType, nationality, userId } ) ;
63+ console . log ( "Parametri Hidden OK:" , { name, userType, nationality, userId } ) ;
8664 } catch ( e ) {
87- console . error ( "Errore nel settare i campi hidden:" , e ) ;
65+ console . error ( "Errore campi hidden:" , e ) ;
8866 }
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' ) ;
9467 } ) ;
9568
96- // --- SNIPPET INIT ---
69+ // Init Snippet
9770 embeddedservice_bootstrap . init (
9871 '00DUA000003hFV7' ,
9972 'ai_chogangroupspa_com' ,
@@ -104,7 +77,7 @@ <h1>Dati Utente</h1>
10477 ) ;
10578
10679 } catch ( err ) {
107- console . error ( 'Error loading Embedded Messaging: ' , err ) ;
80+ console . error ( 'Errore Init: ' , err ) ;
10881 }
10982 } ;
11083 </ script >
0 commit comments