https://discord.gg/botpress logo
How to have Bot read a PDF file uploaded by the us...
# 🤝help
c
I'm brand new to Botpress, using it for work. In my use case the user can upload either an image or a pdf to my bot after following a specific conversation path. I can easily identify the type as once an s3 link is made the final extension is either an image format or obviously pdf. Reading images is easy as there's a card for that that converts it into text. However for pdfs apart from putting it into the knowledge base I don't see a way that would be similar to the way it's done with images to use an AI Task to get the information I want. Bot asks for file -> User uploads file -> Bot stores file as s3 link -> Bot checks if file is IMG or PDF -> if PDF bot reads file (as text ?) and uses an AI Task to fill variables I want to push them into a table row. I feel like the answer is somewhere out but I only started not long ago and after searching for a bit I couldn't find anything that fit my specific use case, so asking felt better.
I've tried something like this : it does return a value but only 12345678901234 every time. As for the file itself it's your standard electrical bill with all the information on it.
Task Instruction (in English)
Copy code
txt
Read the PDF file and extract the PDL number found in the invoice. A PDL number is always a 14-digit serial number, with a few rare exceptions. On some invoices, it can be found next to the phrase 'Réf Acheminement Electricité', in the section 'Données Point de Livraison'.

Write the PDL number you find into the variable: @workflow.pdl_serial_number
The obvious choice would be to convert the PDF to pure text. But do I need an external tool for that or can I use an internal tool ? afaik node modules don't work.
l
Hey Perry welcome to Botpress 😄 I suggest you take a quick moment and have a read of our docs: https://botpress.com/docs/api-reference/files-api/how-tos/index-and-search-files The link i provided might give some useful insight If youre still having issues after give me a ping and well explore further 🫡
c
Quick question when using indexed files are they global to the bot or local to the user's conversation ? (from what I understand after a quick read they seem to be global) In my use case I do not want these files to be shared across conversation instances ?
l
When you upload and index a file, it becomes part of the bot's knowledge base and can be searched or referenced in any conversastion!
Consider storing information in Botpress Tables or session variables instead of files.
c
Okay, unfortunatly that won't do as it is user based personal information. Is there maybe a way to OCR a pdf document (I could do that directly from my react native app or through an external service). The idea is that images already do that with the image attached below. https://cdn.discordapp.com/attachments/1421121173479096350/1421142413707055178/image.png?ex=68d7f582&is=68d6a402&hm=5e9f80081493bda1f37cd718f7e859982d06c08d1894a56a83c5b19dc27bada1&
Thanks for the help though it is appreciated.
l
Through botpress there is not a way OCR for your PDFs
c
I'll look if it's a feature request if not I'll open one then :D
l
please do #feature-requests
4 Views