ChatBot - A funcionar com a estrutura mas com erros na tradução

This commit is contained in:
Ricardo Cunha 2025-06-12 14:30:22 +01:00
parent 38b3d1f089
commit c9ff11b62a

View File

@ -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.' });
}
});
}}