1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-09-11 13:15:28 +03:00

fix(editor): Fix an issue with an empty chat response if not in output property (#8913)

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
oleg 2024-03-18 11:27:33 +01:00 committed by GitHub
parent 0c179e4e51
commit 024be62693
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -45,9 +45,19 @@ export const ChatPlugin: Plugin<ChatOptions> = {
options,
);
let textMessage = sendMessageResponse.output ?? sendMessageResponse.text ?? '';
if (textMessage === '' && Object.keys(sendMessageResponse).length > 0) {
try {
textMessage = JSON.stringify(sendMessageResponse, null, 2);
} catch (e) {
// Failed to stringify the object so fallback to empty string
}
}
const receivedMessage: ChatMessage = {
id: uuidv4(),
text: sendMessageResponse.output,
text: textMessage,
sender: 'bot',
createdAt: new Date().toISOString(),
};

View File

@ -13,5 +13,6 @@ export interface LoadPreviousSessionResponse {
}
export interface SendMessageResponse {
output: string;
output?: string;
text?: string;
}