hundreds-forest-34951
06/19/2025, 12:27 AMprehistoric-airplane-85682
06/19/2025, 2:24 PMjs
const fileUrl = workflow.url[0] // Get the cleaned file URL
const knowledgeBaseId1 = '<your-kb-id>' // Assuming the KB1 knowledge base ID
const name = workflow.companyName
//Add the file to the knowledge base
const file = await client.uploadFile({
key: `${knowledgeBaseId1}/${name}.pdf`, // Each file needs a unique key under your bot
url: fileUrl, // This is the external URL where the file is currently located
contentType: 'application/pdf',
index: true,
tags: {
// Tags are optional but are useful for filtering files by a custom criteria you choose when using the "List Files" or "Search Files" API endpoints. You can change or remove the tags below based on your needs.
knowledgeBaseName: 'brand-pdfs',
source: 'knowledge-base',
kbId: knowledgeBaseId1,
title: workflow.companyName
},
})
Here are the docs about the API: https://botpress.com/docs/api-reference/files-api/getting-started