@developpement/tp-chatbot-widget 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/chatbot.js +16 -4
package/package.json
CHANGED
package/src/chatbot.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const CLIENT_THEMES = {
|
|
5
|
-
flix: { primary: '#
|
|
5
|
+
flix: { primary: '#5cc500', name: 'Flix Corporate', position: 'left' },
|
|
6
6
|
sncf: { primary: '#1a6b5a', name: 'SNCF', position: 'right' },
|
|
7
7
|
};
|
|
8
8
|
const DEFAULT_THEME = { primary: '#7b1fa2', name: 'Support', position: 'right' };
|
|
@@ -477,7 +477,11 @@
|
|
|
477
477
|
if (agent_bar) agent_bar.style.display = 'none';
|
|
478
478
|
|
|
479
479
|
this.conversation_id = await this.createConversation();
|
|
480
|
-
this.
|
|
480
|
+
const client_name = this.client_id === 'flix' ? 'Flix Corporate' : this.client_id === 'sncf' ? 'SNCF' : this.client_id;
|
|
481
|
+
this.addMessage(
|
|
482
|
+
'assistant',
|
|
483
|
+
`Bonjour ${this.user_info?.first_name || ''} ! 👋 Je m'appelle Maria, votre assistante virtuelle ${client_name}. Comment puis-je vous aider aujourd'hui ?`
|
|
484
|
+
);
|
|
481
485
|
this.polling_interval = setInterval(() => this.pollMessages(), 3000);
|
|
482
486
|
}
|
|
483
487
|
|
|
@@ -551,7 +555,11 @@
|
|
|
551
555
|
const close_bar = this.querySelector('#tp-close-bar');
|
|
552
556
|
if (close_bar) close_bar.style.display = 'block';
|
|
553
557
|
|
|
554
|
-
this.
|
|
558
|
+
const client_name = this.client_id === 'flix' ? 'Flix Corporate' : this.client_id === 'sncf' ? 'SNCF' : this.client_id;
|
|
559
|
+
this.addMessage(
|
|
560
|
+
'assistant',
|
|
561
|
+
`Bonjour ${first_name} ! 👋 Je m'appelle Maria, votre assistante virtuelle ${client_name}. Comment puis-je vous aider aujourd'hui ?`
|
|
562
|
+
);
|
|
555
563
|
this.polling_interval = setInterval(() => this.pollMessages(), 3000);
|
|
556
564
|
}
|
|
557
565
|
|
|
@@ -737,7 +745,7 @@
|
|
|
737
745
|
const user_msg_count = this.messages.filter(m => m.role === 'user').length;
|
|
738
746
|
const agent_bar = this.querySelector('#tp-agent-bar');
|
|
739
747
|
if (agent_bar && !this.agent_requested && !this.agent_mode) {
|
|
740
|
-
if (source === 'fallback' || user_msg_count >= 5) {
|
|
748
|
+
if (source === 'fallback' || source === 'clarification' || source === 'no_match' || user_msg_count >= 5) {
|
|
741
749
|
agent_bar.style.display = 'block';
|
|
742
750
|
}
|
|
743
751
|
}
|
|
@@ -830,6 +838,10 @@
|
|
|
830
838
|
const typing_el = this.querySelector('#tp-agent-typing');
|
|
831
839
|
if (typing_el) typing_el.remove();
|
|
832
840
|
this.addMessage('agent', msg.content);
|
|
841
|
+
} else if (msg.role === 'assistant') {
|
|
842
|
+
this.addMessage('assistant', msg.content);
|
|
843
|
+
} else if (msg.role === 'system') {
|
|
844
|
+
this.addMessage('system', msg.content);
|
|
833
845
|
}
|
|
834
846
|
});
|
|
835
847
|
this.last_message_count = server_messages.length;
|