https://discord.gg/botpress logo
Trying to save a client uploaded file to the knowl...
# 🤝help
l
I'm almost completely new to botpress, as well as javascript. My goal is to have the client upload a PDF, and the bot puts it in a certain folder in our knowledgebase that it can then reference information from. I was able to get the autonomous node to go into a secondary workflow where it asked for the file (file card), then executes this code. Unfortunately it gives says there was an error executing the action. checking the logs it says the status code was 404, but doesn't say which part it couldn't find. To debug I reduced the workflow down to 1 node with 2 cards. 1 gets the file, the other executes the code. Linking the 2 cards and errors below Is this the best way to let the client upload a file to the knowledgebase? And if so, how do I fix this error. Thank you https://cdn.discordapp.com/attachments/1366863664556150815/1366863664853942283/image.png?ex=68127e7c&is=68112cfc&hm=4cfbb669206b184613711e560480ef3035ed213eb2c462d5e0edf76bcbeb8549& https://cdn.discordapp.com/attachments/1366863664556150815/1366863665520709643/image.png?ex=68127e7c&is=68112cfc&hm=fe844b3edb3a0525899612317d625306ee767a39d146ca1ac9e3da9ff45b7b43& https://cdn.discordapp.com/attachments/1366863664556150815/1366863665810247760/image.png?ex=68127e7d&is=68112cfd&hm=8ad5a5cebd96bef918a3537db006093645b9513395c25138a5cae5a650706e5a& https://cdn.discordapp.com/attachments/1366863664556150815/1366863666107912313/image.png?ex=68127e7d&is=68112cfd&hm=0122d579b52c8622a1716de23ae8363960545e2c63eb9ba5bbbb4548fc10fb82&
p
Have you looked into calling the FilesAPI within your execute code card? Here's the documentation: https://botpress.com/docs/api-reference/files-api/getting-started
l
I haven't, i'm like 1 or 2 steps above this all being Greek to me. I see the page attached to the one you linked that would in theory help create the botpress token, but i'm not seeing much after that towards what i'd actually need to do to get it to index the file
@prehistoric-airplane-85682 Hey, I dont know if you've had any more luck than I have here. I tried following the documentation for indexing the file, but it resulted in just indexing the URL to the file (not the file itself) I've also noticed that when uploading the file I get something akin to https//files.bpcontent.cloud/2025/04/30/... " which is not actually a link as there is no " : " after the " https ".
I also tried using one of the earlier suggested codes and hard coding in the answers, and it appears it did not work. I cant find a full list of the functions and what they do/need. I only see examples on the documentation site and cant find one exactly fitting for this situation
p
So update, I was going with the standard node approach because they are easier to control. I successfully indexed a file but failed to query it afterwards.
I am actively exploring alternate solutions and finding areas of improvement to communicate with the product team.
Actually, my approach is now working!!
l
awesome! downloading and trying it now
@prehistoric-airplane-85682 I recreated the bot from the bpz and unfortunately was not able to replicate your success. The first time I tired it never transitioned to the "standard2" node. The second time it did, but stayed on the "upload and register" part of the standard2 node for the rest of the conversation. It doesnt look like the file ever made it to the knowledgebase. Are you able to tell me your process? I see the CVWP animals pdf currently in the KB (assuming that's what you uploaded) https://cdn.discordapp.com/attachments/1366863664556150815/1367244212940046469/image.png?ex=6813e0e6&is=68128f66&hm=9e45ac2898a43684e1b3674a5376225cff1e28d3a55e8446dfd0dfe4d4842c8c& https://cdn.discordapp.com/attachments/1366863664556150815/1367244213242167349/image.png?ex=6813e0e6&is=68128f66&hm=e49e69131af19c2ef5fcd50ed19f9be29ed21f436ab852e937460315b766ed5f&
in the files this showed up shortly after. I guess it tried but failed? my 2nd attempt doesnt show a fail after, possibly just not yet https://cdn.discordapp.com/attachments/1366863664556150815/1367245185511063704/image.png?ex=6813e1ce&is=6812904e&hm=7f6284b85b47bf9e1343948b9d94ba80015d60433bbd4349faa899a269dd30cd&
IT WORKED! I tried it using the same PDF you uploaded and it worked. Next step is finding out why my PDF didnt work. Thank you! I'll let you know if I cant figure out the difference in the PDFs
p
I believe that's because the first file you should send is the pdf for my bot, I should have mentioned but it's a workflow that should be integrated within your existing bot.
I'm glad you made it work!! Maybe the size of the file is a factor but I haven't heard of any such criteria for the files API.
l
@prehistoric-airplane-85682 While we were able to get it to work last night, for some reason today it does not want to work. What's even more interesting is the bot will just kind of stop and await user response. I have the instructions in the autonomous node including "-Transition to File_Node when the user uploads a file". It worked reliably yesterday and I dont think there has been a single change since then, now it's always failing at that same spot. Do you offhand know if there is a best practice for getting the autonomous node to transition to another node in a situation like this? https://cdn.discordapp.com/attachments/1366863664556150815/1367550802192760932/image.png?ex=6814fe6f&is=6813acef&hm=53c123649f1655701c7aec48f52f479c8a94ae1e79b94a3f2883520238e098cc& https://cdn.discordapp.com/attachments/1366863664556150815/1367550802637488138/image.png?ex=6814fe6f&is=6813acef&hm=cb8ffcf90019fc15dced308960e62d4833b5bd6b3fad732f4250ae8dd009cb93&
p
You could try with the {{event.preview}} variable which refers to the last user message?
A picture of the logs, specifically of them when it doesn't answer might also be useful for my understanding as well a the instructions provided to the AN. In general, the least use cases an AN has the better it is at doing its job.
2 Views