Skip to content
23 changes: 22 additions & 1 deletion packages/ui/src/utils/exportImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,37 @@ const sanitizeTool = (Tool) => {
}
}

const CHATFLOW_FIELDS_TO_PRESERVE = [
'chatbotConfig',
'category',
'speechToText',
'textToSpeech',
'followUpPrompts',
'apiConfig',
'analytic',
'isPublic',
'apikeyid',
'mcpServerConfig'
]

const sanitizeChatflow = (ChatFlow) => {
try {
return ChatFlow.map((chatFlow) => {
const sanitizeFlowData = generateExportFlowData(JSON.parse(chatFlow.flowData))
return {
const sanitized = {
id: chatFlow.id,
name: chatFlow.name,
flowData: stringify(sanitizeFlowData),
type: chatFlow.type
}

CHATFLOW_FIELDS_TO_PRESERVE.forEach((field) => {
if (chatFlow[field] != null) {
sanitized[field] = chatFlow[field]
}
})

return sanitized
})
} catch (error) {
throw new Error(`exportImport.sanitizeChatflow ${getErrorMessage(error)}`)
Expand Down
Loading