https://discord.gg/botpress logo
Train My bot through API
# 🤝help
c
Hi everyone! I’m using Botpress Cloud (Free plan), and I want to train my bot using content from my own API or website. I saw that we can manually add websites and files in the Knowledge Base UI — but is there a way to add website content or upload documents using the API instead? I tried using the /v1/files or /v1/knowledge-base endpoints but got a 405 method not allowed error. Is this expected for free users? Or is there another supported way to programmatically update the knowledge base (via API or script)? Would love any guidance or official confirmation 🙏 Thanks!
e
No you're able
to make api calls with the free tier
go into the https://botpress.com/docs/home and search there extensively also their webchat on that page can help you alot
c
i cant see there could you please clarify me that i use api which is present in botpress official docs to upsert file
p
You can use the Files API to add files to files and also your knowledge base but the knowledge base API does not exist as of now. Here's a piece of code I used to achieve this in a workflow which you could modify to use externally:
Copy code
js
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
  },
})
c
ohh thank you
one thing also that when i create bot from api so i got my bot id and all reponse but like if i want embed my widget in my page so how i do that like user came create bot then it will come in my page
p
Can you clarify your question?
3 Views