Hey everyone, today we're going to talk about how you can automatically extract data from documents within Make.com. Now for a lot of people who've used ChatGPT and Claude and those sorts of tools before, they might assume that extracting data from documents or using documents in your AI workflows is very straightforward. But unfortunately, within Make.com, it's not that easy.
So when you open up documents in Make.com, so I'm talking about PDF files,.exe files, those sorts of things in Make.com, you actually only get access to the binary representation of those files. So that's the machine code, the one and zeros that make up those sorts of documents. You don't actually get access to the underlying text within those documents. So as an example here, I have a PDF attachment. You can see here, application PDF.
And you can see the data here is sort of this binary buffer type format, rather than the actual text within the PDF. So this is what the PDF looks like. So if you have this sort of representation of the data, it's not going to be able to process it. A very common question I get when I'm talking to different people is, oh how come when I put it into ChatGPT I don't need to do that?
The reason for that is because ChatGPT is an application, it's not the underlying large language model and OpenAI within ChatGPT is doing all those steps for you that takes your file extracts the text out of the file before passing it into the AI model. The other very common question I get around this is people who are using the Assistant API within OpenAI. So this is what I'm talking about here, message a Assistant, and you've got sort of upload a file here. So that works, but that locks you into the OpenAI ecosystem.
And the other thing here is... When you upload a file and you use it with an assistant, usually you're using it with the data retrieval or the file search, and that is a very specific way of using that file, right? You're not passing the entire contents of the PDF into the assistant, it's really more of a RAG pipeline.
At a high level, no one actually knows exactly what OpenAI does, but at a high level, they take your PDF, they turn your PDF into lots of small chunks, and then every time you ask your assistant a question, it will do a search for the relevant chunks. So your whole PDF may not be passed into the assistant every single time. Anyways, that's just all around why we need to do this stuff. The broader question or the better question to ask is what is the value of doing something like this, right?
So this is really more of a fundamental skill or building block skill that you can use in a lot of different builds. So the example we're going to go through today is really around, let's say you get a lot of PDF invoices. So as an example, this is an invoice I received from one of my hosting providers. Maybe you get a lot of these and you just want to put all of that data into a spreadsheet. Maybe you want to categorize those invoices somehow just for your own tax returns or for your own accounting purposes.
That might be one use case, and that's what we're going to cover today in our build. But there's so many other ways you could use this skill, right? So for example, maybe you work with lots of different agents, lots of different professionals, and they might send you PDF reports.
And maybe what you need to do is synthesize those reports, analyze those reports, or transform those reports into something else. In those cases, you will need to deal with PDF documents or just Docx Word documents. So with what you're going to learn today, you can now deal with those and then transform those into whatever you need. So this is something that comes up a lot in my client work as well.
So if you follow along, I'm sure you're going to learn something new today. And it's going to be something that is going to come up a lot in your automations in make.com. And once you learn this, you're going to sort of think to yourself, how did you survive without this before? Cool.
So, let's go through the build that we're doing today. So it starts with a webhook. We take the document, transform it, and then we sort of extract the data into a spreadsheet.
What we're doing is sort of taking this PDF invoice that I received from a hosting provider, I'm sending it into make.com to trigger the automation. All these steps happen to extract the data and eventually it comes into this spreadsheet where all of my expenses will go. So right now it's very simple. I've just got three columns, cost, description, and date. You can obviously add additional columns because we're using AI in this automation.
You can, for example, add a category column or yeah, basically it's up to you how you want to prompt the AI, but we're going to keep it simple here and this is sort of what we're building towards. So the example we're going through is actually quite simple, right? So the first step is really to get the file into make.com. So what I mean by that is getting this this data representation right within make.com so generally within make when you have a file you'll represent it in this way you'll have file name file size mime type and you'll have the underlying data so we need some way to get the data of that file into make.com so what i'm using here is the custom mail hook and the way i get this into make.com is basically i send a email where this pdf is an attachment and i send that to this email address here which is my mail hook within make.com So once I and that I have the file within make.com.
What I need to do is convert that file from this binary representation. here, which is this data, into the text representation, right? So for that, I'm using Dumpling AI. So Dumpling AI is my product.
You can use other products out there like CloudConvert, all that sort of stuff. I obviously think Dumpling AI is the easiest to use. So with Dumpling AI, what you need to do is you need to select the convert a document to text method.
So if you go into Dumpling AI, there is this convert a document to text method. Once you open that up, there's two input methods. You can use URL or base64 because I've got the file via a email attachment I need to use base64 and this is how I pass in the file. So within make.com if you click into the a here which is the different functions of the make.com there is a base64 function and what this will do is it will turn the data that we have from the email attachment and turn it into a base 64 representation.
So that's what you need to do and just press okay. And basically what will happen is after this module runs, you get the actual inputs or you get the text in the PDF, right? So this is just all the stuff within that PDF that we previously didn't have access to. From here, it's relatively straightforward. It's just a standard AI automation.
So I'm using a GPT-4 completion here, so ChatGPT module. Once you've got it all set up, It's pretty simple. Come in, choose the model I'm using, GPT-4-0. For my system prompt, I'm keeping it super simple.
I'm just telling it to extract the columns of data that I want to put into my spreadsheets. And I'm just saying extract it as JSON. So I'm saying cost, description, and date.
And if you're extracting as JSON, make sure you don't forget to come down here to your response format and turn that to JSON object. And to view this response format, you will need to show advanced settings. And then down here in the user message, I'm just passing in the text that I...
got from Dumpling AI. And once I have this output from O, which is this text string, I will need to use the parseJson module within make.com and what that will do is just turn this string into variables that I can reference. So now I have cost as a variable, description as a variable, date as a variable, and finally all I'm doing is passing that into Google Sheets.
So I'm just putting in cost, description, and date and that just pushes it straight into this spreadsheet and from here you can sort of have your automation be running like on a daily basis or something like that every day all the emails that you've sent to this email will sort of pull in the pdfs and then do the extractions into your spreadsheet and then at the end of the week end of the month you can do your analysis there but as i mentioned at the beginning this is really more just to show you the skill around how you deal with documents so pdfs and word documents within make.com once you've got that You really want to be creative in how you apply it. So as I mentioned before, maybe you have a lot of PDFs and you want to repurpose it into another format, or you just need to analyze it, or you want to extract data from PDFs. You can now do all that with what you've learned today.
So that's it for this video. If you have any questions, feedback, thoughts, just leave a comment below and I'll try my best to get back to you. If you need help with AI automation in your business, there'll be a link in the description. I help businesses grow and scale with AI automation generally on the...
marketing and sales side of things so if that sounds interesting to you just reach out more than happy to help but with that i'm gonna wrap up and i will see you in my next video