Automated PDF Analysis: Using ChatGPT & Zapier For Any Industry | Tutorial β
Let's build with Zapier and AI (100+ videos)π
2023-10-20
Transcript β
[00:00] welcome back to corbon AI where I'm showing you daily how to start leveraging artificial intelligence in your personal and your business life and this is a popular demand video that has been requested a ton on this channel if you're coming from one of my PDF videos this is going to be the perfect video that's going to align right with your paino I'm going to show you how to create a system that will automatically Cipher and get relevant data that you care about with the PDFs you work for in your personal or your business life particular I've been getting a lot of requests in you know dealing with either longer form PDFs or PDFs that you want
[00:30] specific outputs for and I've been kind of giving the response of building out a zap your workflow using open AI API and essentially getting specific outputs based on what you care about what I've realized is there is a ton of people that are requesting this from me so I'm going to go ahead and just build out a full-on tutorial in this video so me sure make sure if I can speak to leave a like for the value you're about to receive as we're going to go ahead and dive into a very complex topic but it's going to allow you to expediate a lot of your processes all right so with that being said of course you're going to need a zap your account and the flow we're going to build out today is we're
[01:01] going to do something very simple we're going to have it so when you add a file specifically a PDF file to a Google drive folder it's going to go ahead and do the entire process that you may have typically done in chat gbt's front end when it came to you know the different plugins of ask your PDF you know AI PDF let's go ahead and just do it all automatically because typically when we are Consulting with PDFs we're already going to be asking the same amount of questions especially depending on your industry you're already looking for specific keywords in a PDF you're going to learn how to do all that today's video to start off here we're going to
[01:32] start with this example legal PDF here and in this context for this video we're going to make out an Automation in the specific context of legal documents now this can be applied to anything this could be applied to you know you know real estate client leads whatever it may be you're going to learn how to automatically deal with PDFs now no longer do you have to Cipher through studies no longer you have to Cipher through anything let's go and learn how to do that all right so let's goad and begin we're going to go ahead and come over to our zapier account here we're going to create a new zap now sadly the zap I'm going to create today I cannot
[02:02] give uh I cannot share but I'm going to give all the code that is relevantly available what I talk about in the uh comment down below so you can go ahead and copy it directly into your account so I'm going to go ahead and rename this to uh PDF task we let's go and start here so we're going to start with a very simple trigger here we're going to do a trigger of Google Drive now this could be Dropbox this could be whatever Cloud function you use we just use Google Drive here we're going to do the event of adding a new file to folder um let's go and let this load real quick okay so we're going to come over here
[02:33] we're going to say new file and folder this helps it so that basically you can designate a specific folder within your Cloud function or sorry not Cloud function I'm think of sasses within your back end where you once you drag your PDF in there it will only be triggered based off that so for us we're going to go to our courses account here and we're hit continue here so under this logic you would essentially designate a folder within your Google Drive that is meant for this specific automation for us we're going to use an example fold here called PDF task we're going to continue here we're going to test this trigger one thing I want to point out here is sometimes you run into errors with
[03:04] authorization what I suggest you to do so make sure no one has access to your underline link is I suggest you to make it so that when it comes to sharing we're going to go ahead and choose anyone with the link as an editor this going to allow the API to get access to specific content found within that PDF so for us we're going to go ahead and find the specific file that we were just dealing with I'm going to hit title here uh not that okay so we're doing with legal example PDF as you see right here and just to run through it real quick this is is a big document so you're going to learn how to basically parse big documents like this this is a 27
[03:35] page uh mock it's not a real legal document well it's real in the sense of like the contents and the structuring it's just not an actual legal document that's been used but this is 27 pages so you're going to learn how to parse large documents like this which is I think is a huge pain Point found within Chad gbt's frontend and stuff of this nature one thing I want to point out as well is zappier is a free softer in the beginning open AI is going to cost you Pennies on the dollar when it comes to doing this artificial intelligence and lastly what I'm about to show you uh basically someone could start a artificial intelligence integrated SAS
[04:06] that charges you a lot more money for what you're about to see here so this is a really really optimized way to approach these kind of work process so I'm going to go ahead and hit continue with select a record here now one thing about Chad gbt sorry with zapier is the first issue you'll run into is not being able to get the underline contents found within that PDF this is because uh zapier doesn't allow you to access certain data in certain file uh formats you'd have to use some type of third party service so what we're going to do here is that the first step we're going
[04:37] to do here is we're going to actually convert that PDF into a Google doc so we can actually access the data that is found within that PDF so we going to do upload file we going continue here and continue here and we're going to choose our folder so we're going to use our same folder here we're going to do PDF task we're going to choose our file which will be file exists but not shown we're going to convert the document we're going to say true we're going to give it a new name we're going to say say uh legal You' give it this is going to be the consistent name that incurs every single time so for our context we're just going to do legal
[05:07] test uh Doc and if you need to have it so that maybe you're doing a bunch of different documents you want to keep it so that it isn't a fixed text here let's actually go ahead and name it just you know legal example.pdf this will make sure that the it's Unique and you know exactly what you're targeting here so I'm going to say legal example.pdf uh doc okay and then we're going to hit no file extension we're hit test this step and this will automatically convert our Google our PDF to Google doc and what's
[05:38] great about this tutorial is at the end of it I'm going to actually run through this automation again and we're going to actually just do it with a whole new Google or whole new PDF so you can see it live you can see you can see everything associated with it so coming over here as you see we got our legal example uh right up there there right above there I click on here now it's a Google dot so same contents but we're in Google doc mode therefore we are now able to actually access the data or the text found in this Google doc we're going to have to do some code here so we're going to do JavaScript oh or we're
[06:09] just going to do code and we're going to go ahead and say run JavaScript continue here and we're going to go ahead and add some relevant information here so we're going to go ahead and provide the input variable the data that we're testing here so it's going to be text and then we're going to go ahead come to upload file it's going to be file text here so what zapier does is that it has the data but it doesn't show it which obviously isn't going to help us in our context so we're going to do file text and then I'm going to go ahead and paste this code this is going to be in the
[06:39] comments down below essentially what this code is doing is it's fetching the underlying data associated with that new file and then we are just splitting it or not splitting it but we're just getting we're outputting the text found within that Google doc this number right here is going to be your most important number so that number right there indicates how many words you're going to Output therefore knowing your industry knowing the typical PDFs you work with understand what a healthy number would be in your context so for us if I come
[07:09] over here I hit command a command C and go to like something like word counter and command V it I know I'm dealing with a document that's 15,000 words so whatever your industry is go a little above it so for this context I'm G just do 20,000 but if you're dealing with bigger documents you're going to want to go ahead and increase that number right there from here though I'm going to hit continue I'm going to test this step and this should give us the entire output found within that Google doc and what's amazing about code and what you learn is that it like from a surface level you're
[07:40] like that's so many words like how would it be able to do that but in reality it can output that many words that fast it's just the the data associated with that many words is like not even megabytes it's so little we're talking about kilo kilobytes okay so from here though now that we've outputed the entire Associated the documents which looks crazy but as an AI model we're able to read that we're going to go ahead and teach you how to deal with really large documents because alternatively someone might suggest to take that entire output and push it towards a gbt prompt which is possible
[08:10] but the problem is that then you re uh you incur issues of dealing with too much data in a prompt therefore the outputs aren't good or the outputs are too take too long so we're going to add another code block here now in theory if you're dealing with very small documents you can skip this part but this is for people that deal with very large documents so we're going to just go ahead and call this chunk and we're going to go ahead and do uh just say entire text output okay and then for chunk we're going to do JavaScript again and we're
[08:42] going to go ahead and use some code here and the purpose of this code is we're going to go ahead and chunk by a very specific uh amount of word count so we're going to do our input data here of text our text is going to be this entire output which is called results and then from here I'm going to go and paste in the code block we created here and let's go and explain it a little bit so couple things first thing is this is going to identify uh how much data we're associating with each quote unquote chunk so for us we're associating 5,000
[09:14] words you'll see what this means when I do the test here um actually let me to do the test and I'll explain the code so this makes a lot more sense I'm going to go ahead and test that real quick so you can kind of see what the output looks like okay so we have chunk one 5,000 words come down come down then we have chunk two 5,000 words and this this is um chronological this isn't a repeat so 5,000 words and then coming down here we got chunk three and then just to confirm that if you come all the way down here the last page has information about contacting and as you see here if you're an account administrator this you know
[09:45] this has stuff to do with you know the very end of that document specifically this formula safety for.com come all the way down here we will see that we are dealing with the end of the document and that URL is from the there so we went ahead and chunked this entire legal document into specific chunks here which is good this allows us to handle larger amounts of data and not run into air so let me go and explain that code a little bit more here so you can understand intuitively what's occurring here so we're dealing with identifying our chunk
[10:16] limit or our word count associated with each data block my experience I would have say the max you would want to go for each data point is 5,000 this can be increased if you choose to do so it's just you don't want to too much in one data point Point as that's going to lead to worse outputs for the AI you're about to see later the next thing we're doing here is we can kind of skip through this it's not too important for you to really understand is we're identifying each specific chunk with a unique identifier so as you see here we have ID one id2 and the reason we're doing this as you'll see later is that allows us to
[10:47] call upon specific chunks with specific use cases so as you see here for chunk one we have ID one here come all the way down here for chunk two we have id2 so that's going to come useful later on and and then finally you want to identify how many chunks that are typically found within your underlying PDFs you work with therefore if the typical PDF you're working with is you know 10,000 to 20,000 words if I was dealing with a PDF that was 20,000 words and I typically deal with PDS of 20,000 words you would add another chunk here all you would do
[11:18] is do command C uh not that command V and then you would just name it chunk four and three and you're good to go for us though we don't have to worry about that because ours is only around 15,000 words therefore the output we have here is sufficient for what we want to occur here so now this is where the fund begins so I'm going to show you two major ways we can kind of look at the data found here and analyze it this going to be in the specific context of a legal contract so whatever your industry
[11:49] is you would kind of just Rector the AI for whatever that is and the prompts I'm about to show you are probably not like 100% perfect but enough for you to kind of understand the direction you want to go go so from here let's just go ahead and show you uh one way to approach this let's assume that we didn't need to chunk it or we did need to chunk it but we only needed a certain you know contents found with the PDF we can do a Chad DVT block here and we can go ahead and do an event of conversation he continue continue if you're brand new to zapier and AI I
[12:20] suggest you to check out I'm going to go ahead and Link like one of our major videos when it comes to integrating opening I zap here at the end at the very end here or maybe I'll link it up there that's just going to give you an idea of like how do I even integrate Chad gbt into zap here you can watch that and then come back here but from here we're going to go ahead and do a user message here we're going to say based on this legal contract we're getting context uh compress it to the main points now this is going to be whatever you want what I
[12:50] suggest you to do is this though so you're going to compress it to the main points and then I'm going hit period here I'm going to say uh legal contract and then you're about to see how we utilize 3.5 and four in unison here so we're going to say chunk one and we're go ahead and hit gbt 3.5 we're going to go ahead and up this model to 16k this is going to allow us to deal with larger amounts of data here and we're going to go ahead and make sure we have uh a memory key here memory Keys ensure consistent outputs add scale so we like the output how it looks like
[13:20] that can ensure the next time I add a document it will look the same so we're going to go ahead and compress this data even further to its main points now whatever industry is maybe you want to compress it to very specific things found within the contract or very specific things found within the type of PDFs you deal with that's kind of where you would Proctor it there so we have that relevant information so if I scroll down here we will see that we have the reply if I can find it all right here we go so it takes those 5,000 words and it compresses it into this paragraph So this contract is for the use of a mobile
[13:52] app that restricts you use while moving specifically while operating a mob motor vehicle users are not allowed to tamper with or disable apps motion restrictions function so took 5,000 words compress it to that if you want specific data points then the way You' kind of restructure this is um compress it to these guidelines and then I'm going to go ahead and just put a period here and then what I would do here is I'll put guidelines um state of jurisdiction like
[14:26] stuff like this and then I'll just do this and then this and then it would kind of go like that for now though we kind of have it sufficient to where we want it you know giveing me a compressed contract that's all I care about so from here though what I suggest you to do is that's fine if you if that's perfect output of what you're looking for maybe the key points is all you care about then you can kind of skip this part but if you want to get a little bit more complex what I suggest you to do here is add another chat gbt block with this chat gbt block we are going to go ahead and do an event of
[14:56] conversation again and we're going to go ahead and and do a model of gbt 4 so gbt 4 think of it as the more human level way of interpretation while gbt 3.5 is kind of like here's some data organize it so with this we're going to say based on the summary of the first part of this legal contract period here put contract semicolon parenthesis we'll do the
[15:26] output here make sure I'm inside these parentheses and the reason I do parenthesis you might be asking yourself is that it allows the prompt to understand that that is a single data point within its prompt it doesn't overlap into later conversation I you know have here we're just going to go ahead and just say something simple here like U give me a one sentence summary now that's very simple if you if you actually wanted something very specific you can ask it in that context just do sum GT4 and you can even you know grab upon
[15:56] other stuff for whatever your specific industry is but for now I can hit test that step and essentially from there i' be get a one- sentence summary and what we just did there was we took 5,000 words we can press it into a paragraph and then on top of that we com press it even further into a single sentence a little long but for uh short enough this contract outlines the terms of use of the mobile app and then gives us a you know more maybe articulate summary you know this stuff you can go here where we're going to say uh our
[16:27] jurisdiction is California I mean this doesn't make sense as a lawyer don't I'm not a lawyer so I'm just going with what I know so I'm going to go ahead and continue I'm going to make sure I'm refresh the memory key if you don't like an output refresh the memory key so I add five here I'm retest this step I'm not sure if that's going to change the output a lot but maybe knowing context that we're dealing with a certain state for this contract is better and maybe you get something crazy there so um okay so it just adds a little bit more context so that is stage one or that's like approach one now you might be saying to yourself okay that's great that's great
[16:58] if if you're dealing with smaller sized uh PDFs if you're dealing with larger sized PDFs let's go ahead and figure out how to solve for that we're going to add something here called a paths block and this is why I brought up the IDS earlier in that output because this is where the IDS come into play so from here we're going to do something really cool this gives you real perspective on um essentially how crazy code is I'm going to go ahead and just grab these and just drag them down here because they should be over here for now anywayss going hit
[17:28] cancel here like this okay so as we know from this document it was over 15,000 words so we got three different chunks in this context and we got id1 id2 ID3 the way we can do this is we can do uh first or just say chunk one so in your specific context maybe there is a certain type of PDF that you deal with on repeat so is it a research PDF is it some type of briefing for a client is it a legal contract whatever ever may be
[17:59] these PDFs typically have similar structuring across the line and if they don't then you would just create a whole another automation that are specialized for a different structured PDF so in this PDF though let's assume that every legal contract comes in has similar structuring which we can safely assume in the sense of when I say structuring I mean like in the beginning like are we talking about uh client a is recognized as web Cafe Ai and client B is Rec like that kind of stuff right so from here here's what so cool we can go ahead and
[18:30] use our way of that ID that unique identifier to make sure we're going down the right path one thing I want to point out here is that when you see chunk one that doesn't show up in zap your's automation that's only you as a user can see chunk one so that text of Chunk one will never be seen by the user or Sorry by the Automation and why that's important is that that means that I can't just do simply contains chunk one because the actual text that's associated with it doesn't have chunk one in it that's just for you as a a
[19:00] user what it does have though is those unique identifiers so has that ID one okay that's cool so we going do ID onecore and then watch this it's going to say green perfect so even though I gave it 5,000 words it was able to find within like two seconds and recognize that oh okay this is chunk one because we have id1 now to prove this is correct if I go to chunk two which has id2 hit continue here it's going to show me yellow because it doesn't contain id1
[19:32] really cool stuff here so knowing this we can do that we can go ahead and proceed like this so we got chunk one here and logically we can make this chunk two and all we have to do is text contains id2 one thing I want to point out though is that the reason this is unique and specific to the formatting of your PDF is you would only use this in the context that maybe typically in a PD PDF document you only care about the first 5,000 words therefore this allows us to
[20:04] kind of filter out the rest of the output and maybe in some context you only care about the middle part of a section or the end part of a section this is kind of allows you to filter it out so in reality you don't have to go the extra step here of adding paths you could in theory just do a simple filter block plus this works on Lower plans so maybe in the context of a lot of PDFs you work with you only care or only want to use an automation for the beginning half of it you would kind of proceed like this you know chunk one in the same kind of logic here knowing this if I
[20:35] want to go ahead and kind of do an entire summarization of this PDF so let's say everything is good and I want to actually just only specifically look at the entire PDF we can go ahead and do that this way I'm going go ahead and rename this to section one we name this to section one sum or we's say gbt 4 summary and then from here all you want to do is copy and pace so I would
[21:07] duplicate kind of proceed like this and this is very specific to if you have very large documents it is always better to kind of have it all in one kind of section or one you know as limited amount of gbt prompts as possible but in theory all I would do from here is go ahead and do go section two uh you know part two of the contract and then instead of Chunk one we would do chunk two here and kind of proceed with our structuring from there so a lot of times
[21:37] maybe if there is a legal document you add you would kind of you know run through each and every single chunk and then you would just find specific stuff you care about and kind of output that way so knowing the process to dealing with longer documents now let's go ahead and just pretend in our specific use case we only care about the beginning section and we can kind of proceed like that knowing this what we can do Post AI you know AI looking at your PDF is a bunch of stuff so either one you can send it to your Gmail two we could send it to a slack Channel um Let Me Go
[22:09] and show you real quick on Gmail Gmail is very simple so Gmail would just be you know you choose an event uh maybe send email with email here I'm going to do my courses account here and then from here let me go ahead and just make my life easy copy that and hit two and then we can go ahead and just take our body here and with the you know maybe the gbt for summary is what we care about grab that and we can go ahead and do our subject and the subject we can actually use the underlying title here so maybe the title would have had a better title than legal example we're going to hit
[22:40] continue here and test this step so this will send it to myself therefore when I drag that PDF I automatically get an email to myself okay and this email right here is from a past tutorial we did we show you how to make automatic lead PDFs based off a whole meeting and conversation will automatically create whole thing pretty cool stuff there but as you see here we got the email we got the specific sentence associated with that email so just to show you on a service level how this works let's go and proceed like this we're going to go and publish I'm going to go ahead and add a new legal document here and we're
[23:11] going to get a new email so it's published it's live it's good to go we got PDF task here let me go ahead and come over to my desktop I got another random free legal template PDF that I just added right now for a consultancy agent agreement so let's goe and check it out live here so if I come over here come over to history it might not show up right away um so we're going to wait a little bit so the reason it doesn't show up right away just so you can have more insight on why is they do a thing called polling in the back end of these automations so some stuff is instant and
[23:42] some stuff is a pull a pull in this context is it's checking every five minutes whether there is a new Google drive or new file in your Google Drive so don't get worried if you look and you're like where is it it's because that's just how the automation Works you're going to get pulled every five minutes so pretty soon here we'll see an automation running now as we wait for that as I said before the end conversion event in this context will be an email in theory we create a whole another Google doc for it there's a a bunch of stuff we can do but for this tutorial we expect an email here with the specific name of free cons consultancy template
[24:13] and you know hyphen doc so let's see okay so it's working as you see here you can actually watch it live so hit play here you come over here success success success success success look how fast code works it's amazing um it's going is going if you see waiting that's fine this just means it's processing it we should be expecting email here one thing I want to point out here as I'm not going to do it live but a lot of people if you wonder how to calculate the underlying cost associated with this you can use something that we have here uh called the automation calculator if you
[24:44] want to go ahead and come to web cafes software.com you can click one of the shop items down there kind of Click out and then basically you'll find here is an AI usage calculator and all we need to do in this context is Select our main model so most of the time you're going to choose GPT 4 here you're going to do you the amount of task per run so in this context as we see we are using a total of and a really easy way to see how many task would be you know C says five plus essentially you'll never count the trigger you're only going to count these so got one two three four five six
[25:15] so in total this cost around six uh task you put six there tokens per run you can real quickly find that by doing data out scrolling down tokens uses 429 and then I'll put that there and then and from here you would input the number of runs at scale the cost per task so just as an example here we can go ahead and just give this example let's just say assume let's assume that our task per run is this much to find that you just divide your monthly cost by the number task and then we can go to calculate so it cost 19 cents and that scale you can kind of
[25:46] push so if I did this 52 times it' only cost me nine bucks so knowing that I come over here look at that we got our one sentence summary for this consultancy agency this contract is a customizable free consultancy agency template provided by doc limited now obviously there's probably a lot of context in the beginning there that was kind of more oriented towards the fact that it was a free contract but you just saw this entire flow happen automatically in happen life so if you felt like you learned something today make sure to leave a like as it's free
[26:16] and helps us your Corbin Ai and let me know if you want more content around this topic there is one thing I could have done here to take this to the extra level is I could have added a loop in theory and a loop would have made it so that it would have you know maybe better compressed larger file larger PDFs at a you know more expediated rate but for now this shows you a really structured and fast way to start automatically compressing and finding data within your PDFs so if you like this kind of content you can check out the playlist at the end here it shows essentially me jumping into all 5,000 apps found on zap year
[26:48] seeing how AI can integrate with either one I either might do that one or the other playlist we had here which just shows you know modern tools for AI and your business which can be very very useful uh and then I'll make sure to link that one video where it essentially shows you from zapier and open the ey how to even connect them so like a 40 minute plus video you learn how to actually start using chbt in the context of AI so no longer the front end but without further Ado I'll see you in the next video thanks for tuning in and yes surprise I'm an AI Avatar make sure to
[27:18] explore more here at Corbin AI where we demystify AI for your personal and business life until next time