Execute Code & external data retrieval
# 🤝help
h
Hello guys, our chatbot is slowing down when we store a lot of documents in it (and it doesn't carry PDF files > 10MB).⚠️ I have come up with a solution of saving the PDF files in Supabase and then request them from there using the execute code card. Well I have no dev experience and teaching myself code through ChatGPT and have been at it for the past 3hours and its not coming through.🌠 The goal is for user to type in a prompt like 'Download Accounting Paper 2 Nov 2022' and we must be able to extract the {subject} {paper number} {month & year} from the user input and use that to search for the requested file in Supabase. Can anyone please check my flow & code and see if its the issue or there is something else🙋🏿‍♂️
f
You should start out by fixing all of the text that has a red underline. Then work on from there
h
Okay i am currently working on the code I will let you know how it goes, thanks.
f
Perfect
h
Hey @fresh-fireman-491, happy new week! I am still working on the code. Just needed to ask if Botpress can't recognize that bp in bp.event in the code below how can I work around that
f
Hey there, thank you and like wise! What are you trying to accomplish by using bp.events?
h
I am trying to send the document I have retrieved in Supabase to the user The "bp.event.replyToEvent" is supposed to be the one that delivers the file to the user but Botpress doesn't recognize probably because I got some of this code from ChatGPT It's supposed to be global variable from Botpress or something like that but its not so I was asking what other variable can we use there instead of bp
f
I haven't seen bp.xx before but it could be a thing. I have also never sent a file from the execute code card before. Which integrations are you planning on using? Maybe @famous-jewelry-85388 or @acceptable-kangaroo-64719 knows how to send a file from an execute code card?
h
This is supposed to be the explanation but maybe its calling out old variables for Botpress because i also can't find the bp.xx even when I search the documents.
a
Hey @hundreds-battery-97158 that code is for our other product, Botpress #1112845893931110402
In cloud, if you want to use code to send the user a message, you'll have to populate variables and then use the variables in a message card
but for files, that is not a feature in Botpres cloud- yet!
the team is working on exposing an API for files that integrates with the knowledge bases. Really cool stuff, but it's not quite ready yet
h
I have pdf files stored in Supabase and I want a user to send a request like "Download Chemistry Paper 2 June 2023" then that pdf file is extracted from my Supabase storage and sent to user as pdf files
Hey @acceptable-kangaroo-64719
f
If its not a lot of pdf files you could just make separate nodes and then store the files on them with the file card.
h
if I populate variables and use them in a send file message but click {x} instead of dragging the file will i be able to achieve this?
We tried this before but facing a number of issues, first of all yes the documents are a lot (> 100) and also some are over 20MB in size and Botpress can not upload a file over 10MB plus also adding nodes for chatbots was slowing down our bot so badly
a
you could try storing the files on an s3 or another cloud storage instance, then have a mapping of files<>urls in a supabase (or botpress) table
h
Hey not really dev experiienced, trying to learn more about your above suggestion. I have a question, will this allow me to send the files as pdfs to user or they will be sent as urls and they will have to open the urls themselves to access the files?
f
You will have it as a URL from S3 but the File card can take urls so the user will get the pdff and not the URL
h
Good morning, okay lemme see if I can learn how to implement this and will let you know how it goes
Hello guys, finally got the chance to work on the chatbot this past weekend and went this option of storing the documents and mapping the urls to a table in Botpress and it worked out.
Now just have to work on prompting the find records query so that it can find all documents because its currently coming up with no results if your query is not in the same format as the file title. But this is great progress already and I am grateful
Thank you @fresh-fireman-491 and @acceptable-kangaroo-64719 🎇
f
You are very welcome!
n
@hundreds-battery-97158 can you share your bot. We are looking to build something similar and do not want to waste time and winding up with a slow bot. 🙂
b
Hello, i have experience in uploading pdf to supabase If you need me, DM. Thanks.
4 Views