ChatBot - A funcionar com a estrutura mas com erros na tradução
This commit is contained in:
parent
38b3d1f089
commit
c9ff11b62a
@ -29,10 +29,15 @@ export class AppComponent {
|
||||
|
||||
enviarMensagem() {
|
||||
if (!this.userMessage.trim()) return;
|
||||
this.chatHistory.push({ sender: 'user', text: this.userMessage });
|
||||
const mensagem = this.userMessage;
|
||||
this.chatHistory.push({ sender: 'user', text: mensagem });
|
||||
this.userMessage = '';
|
||||
setTimeout(() => {
|
||||
this.chatHistory.push({ sender: 'bot', text: 'Resposta do bot!' });
|
||||
}, 300);
|
||||
this.chatService.sendMessage(mensagem).subscribe({
|
||||
next: (res: any) => {
|
||||
this.chatHistory.push({ sender: 'bot', text: res.reply || 'Sem resposta do bot.' });
|
||||
},
|
||||
error: () => {
|
||||
this.chatHistory.push({ sender: 'bot', text: 'Erro ao contactar o servidor.' });
|
||||
}
|
||||
});
|
||||
}}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user