From 64f289a98d67b686b1bc55010de4d1b23c0a4c80 Mon Sep 17 00:00:00 2001 From: Nic D Date: Wed, 25 Feb 2026 14:08:43 -0500 Subject: [PATCH] fix(chatbot): reverted testing changes, made error messages more explicit --- src/chatbot/chatbot.service.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/chatbot/chatbot.service.ts b/src/chatbot/chatbot.service.ts index 81a96b1..4f3a6f0 100644 --- a/src/chatbot/chatbot.service.ts +++ b/src/chatbot/chatbot.service.ts @@ -12,15 +12,29 @@ export class ChatbotService { async pingExternalApi(body: UserMessageDto, email: string): Promise { try { const response = await firstValueFrom(this.httpService.post( - 'https://n8nai.targo.ca/webhook/chatty-Mcbot', - { userInput: body.userInput, userId: email, sessionId: this.sessionId, pageContext: body.pageContext ?? undefined } + 'https://n8nai.targo.ca/webhook/chatty-Mcbot', + { + userInput: body.userInput, + userId: email, + sessionId: this.sessionId, + pageContext: body.pageContext ?? undefined + } )); - console.log('chatbot data received: ', response); - + if (!response.data) + return { + text: 'chatbot.error.NO_DATA_RECEIVED', + sent: false, + } + + if (!response.data[0].output) + return { + text: 'chatbot.error.NO_OUTPUT_RECEIVED', + sent: false, + } + return { - // text: data[0].output, - text: 'success', + text: response.data[0].output, sent: false, }; } catch (error) {