Transcript for:
Automatisierung der Rechnungserfassung mit Make.com

Hey, in this video, I'm going to share how I constructed a make.com automation script that extracts receipts and invoices that are sent to my inbox. And you can use this actually to just take photos of receipts that you buy for a company, send them to your email, and it will automatically extract these. So let me get my face. bit out of the way it looks like this but let's take a look at gmail first i set this up with gmail so you can see here i sent an email just saying receipt or receipt computer and in here we see we have an image of a receipt where i bought a computer for my company and up here i just forwarded a an invoice from go high level with two pdfs so this is what we got to work and i have some other ones earlier here let's see we pull this into our database i'm using ai tables you can use air tables ai tables google sheets doesn't really matter um as long as you have Fields to put it into. And I have segmented it into product. So it tells me what product it is. The seller. The date. Reference number is for myself. For my bookkeeping. Then I added in an account selector. So it automatically selects which account the money was pulled from. I sometimes use my private account to buy business stuff. And that needs to be. separated so I know where it goes. Then options here unchecked that is a manual process for bookkeeping. Then adds the price ex VAT. That's because I'm in Europe. So we have VAT to its attacks and it adds the currency and then I convert it into an approximate DKK, which is Danish crowns. I upload all the attachments here in this field as you can see pulls in the pdf i then add the email subject and which email it came from just for good measurement let's go into make and see what we are doing first thing is to pull your emails and i've set this up with a gmail note please note that You can set it up with, for example, a specific accounting email if you don't want to scrape everything and when you set this up, remember not to set the folder to all email and then you need to select come on. You don't want to select this one. I just scanned my entire inbox from 2023 on this setting. The problem with that is you will also get all spam, all sent emails, like you will get everything. So please select inbox and save yourself a lot of operations. And I just scan everything. Then we set the maximum results to 50. Okay. Then you can right click and choose where to start and then set a specific date. So if you're setting this up, the system. I'll put a link to the automation below. You can set it to start back in, for example, December 1st, 2022 and click OK. Then it will start from and pull in from the whole year of 2023 and beyond. If you're like me and you haven't pulled out all your receipts yet, then you might want to do this. and save yourself the hassle i am not going to do this i'm going to set my starting date from today then say 8 00 a.m let's just leave that there we can see it run afterwards then we're gonna look at the receipt all the information we're actually gonna look at the email subject line, the sender name, the sender address, and if the attachments have any names. And we're going to categorize this, whether it is a receipt or an invoice that we need to track or put into our accounting system. So we got a prompt here, bookkeeper, you are tasked with categorizing. You can read all that in the script. Please categorize the following email. Then we add in the email. temperature set low, we specify that it should only output a zero or a one. So only output a zero if this email is not a receipt or a one if it is. What this does is we set up a filter. Yes, this receipt. So the answer, if that is equal to one, it goes this way. Then I added a label. So I will. label all my emails with invoice bookkeeping. Then we have a set variable here. That is because we can read from the statements, for example, the last four digits of a credit card. So I know that the company information, my company card has these four digits. And if it has these four digits, then I used my. Private account, big no-no, but I sometimes do that. Then we do an iterator on the attachments. So if we got any attachments, especially PDFs or images. Whoops, this one should be is image. I'll get to that. So here we say is PDF if the MIME type. equals to application PDF, then it means that it is a PDF and we'll put it through Google Cloud Vision. In order to use Google Cloud Vision, you need to set up your Google Cloud account. You need to set up a, I can't remember, a space or something and then add in the Google Cloud Vision API and then add your API key in here in new connection in order to get. access to it. There are probably videos on that. I won't go into this, but we will select the run text detection OCR with a file and iterate the results. So if we got multiple, we'll just do it, but we'll, we, we iterate over here in this iterator instead. So you can do T I F F or PDF, and we are filtering by PDF. We then get the We then aggregate the text. So if we have multiple PDFs, it will just add it in one long text file here. If this is not a PDF, if it's an image, it will skip this iterator and it will do it in this iterator. So if MIME type contains image because this can be PDF, JPEG, not PDF, PNG, sorry, and JPEG or the apple one which i can't remember so we just need to know that the mime type contains image then we'll put it through google cloud run text detection ocr with an image again we'll just aggregate the text and now comes the fun part because this is a gpg4 node that will aggregate or it will pull output all the information that we put into this into a array output. So we're saying, please use this template. We want to output product name, seller name, price X VAT, currency date and then a date format that is correct and an account bank. Or that's just an example. you only output the field the field template and nothing else you never add a json wrapper it does that sometimes but we took care of that then i add all the um like if product name is not available then use an a not available and currency if account information is not available just set it to empty then we go ahead and add the account information so that is my company information credit card that facing goes there Then we write, take the information, put it into, we just restate that this is what we're going to do. Then we add in email subject, sender name, address, email string. And we cap that at 2000 characters because if it really is a receipt, then we want to like, shouldn't be more than 2000. Then we add the PDF. file here and cap that at 5000 characters and again add the image text and cap that at 5000 characters there shouldn't be more text than 5000 characters in an image for a receipt max output token thousand that's fine then we just parse this output here because this is not json yet it's just a string output so we parse the string output into a JSON format and remove like this JSON wrapper, because even though we said it should remove the JSON wrapper, it doesn't always do that. And here comes a part where you will probably use something else. If you're going to set up this system, I'm using a table. So we create a record and it puts it into this bookkeeping receipts, receipts. for product product name seller seller name you can see that now we get this structured data from our json wrapper and product name seller name date reference number no account um instead of having to choose here we can then say map just do a cancel so i don't overwrite that come on and thinking come on there we go won't do that again options um unchecked because it's we want everything that comes in to be unchecked or yeah we haven't looked at it yet price exvat currency then we add the node more or less the same as we put in to the through the ai email subject and from is that great Then I need to get my A.I. table key in order to run these HTTP notes. We're going to do an iterator for all the attachments inside the email. We're going to upload a file to my A.I. table. We're going to create an array for each type. So if we have multiple PDFs or multiple image files, it will just create an array of this. And we're going to separate by a comma, which means that it outputs this as a correct array. We're then going to add the files. So it's a two-step process for AITable. You need to upload the files and you need to add the files to the correct record. So we'll do that. We'll get the key here. We get the record from that create record over here. Then the field attachments is going to be this text aggregator that we put in here. And the field is the attachment field. It's literally this one attachments what we're referencing here. And that's it. So this will. go ahead and pull in the receipts. I let's turn this. No, let's save. Let's do a run once. See what it does, because we set it earlier to today in the morning. Now I'm going to pull 50 emails in and then let's see what we're going to. We got an error. Why did we get an error? Inbox. Simple email. No, let's just try again. See if that was just a random error. I hope not. Or I hope it is because it was. I need to pause the video. It might be that I just need to select the inbox from. the root folder instead of having all inboxes. So I'm selecting folder and then inbox over here. I think was set incorrectly. Then choose where to start just to be certain. So we'll do 0800AM. Let's see if we can get this to run now. and it's going to pull in there we go so it did something here let's just look see what we got for output message so that was the boost space let's just sort filter here we go So that was these three and it found that it was a bank account because it read that. And let's just see here for let's see what number four is message. No output. That was my computer. from 2023 let's see up here yeah so this one was this email here you can see my beautiful image of this receipt got pulled in looking like this and it caught that This was paid privately because down here in this field, you can actually see that the card equals to 2518, which is my private credit card. And then it noted like the price without VAT as well. Put that in here. So let's see. Six. What did we get here? Choices output go high level. That was the two high level accounts or that was this one, I think. Yeah. So this one had two receipts or two. It has an invoice and another PDF. So here we got invoice and receipt. So we put that in here and here and you can see that it picked up the 2383 and set that to bank. So I now scanned my entire inbox from 2023, including spam, because I didn't choose the correct folder in my Gmail. node here. So I will say that please do that. And also when you select, I also put in the whole email like down here. I added in the entire message. So like text content here. So I scanned like all emails, all spam. for the whole year of 2023 so i burned like many million tokens on this let's just say that so don't do that um don't put in the entire message use this script instead so i hope this was useful um it certainly is for me because now i can have all my receipts and follow along with my bookkeeping because i'm also the accountant my company at the moment And this saves me a lot of time digging through emails, finding the right receipts, just keeping track of everything. So I hope it was useful and you can download the scripts in the description. Until the next video. Bye.