mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08: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:
parent
0c179e4e51
commit
024be62693
|
@ -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(),
|
||||
};
|
||||
|
|
|
@ -13,5 +13,6 @@ export interface LoadPreviousSessionResponse {
|
|||
}
|
||||
|
||||
export interface SendMessageResponse {
|
||||
output: string;
|
||||
output?: string;
|
||||
text?: string;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue