Manage Your Email With GPT4 - Full Tutorial
Key Takeaways
The video demonstrates how to use GPT4 and MindsDB to manage emails, including setting up MindsDB, authorizing Gmail, getting and sending emails, creating an AI model, and automating tasks. It covers the use of OpenAI API Key and provides resources for further learning.
Full Transcript
if you're like me then you get a ton of emails you hate reading them and you especially hate replying if that's the case having an AI that can automatically respond to emails and manage your inbox is probably a pretty appealing proposition so in this video I'm going to show you exactly how we can make that an AI that can manage your inbox now this AI can do super simple things like summarize emails for you send you maybe a bulk email at the end of the week with the important ones you need to reply to or it could simply respond to specific emails it could delete emails it could send emails on your behalf it can do practically anything and in this video I'll show you how you get this setup done and then you can go and adjust this and make it as cool as you want now for this project specifically what we'll do is we'll connect to Gmail we'll authorize ourself and then we'll read new emails every day every two days whatever increment you want whenever we get a new email we'll take that content pass that to chat gbt chat gbt will then generate a response for us and then we'll send the email on our behalf now you can obviously filter the emails you could also maybe generate a draft instead of actually send get a bunch of customizations you can make but I'll keep it pretty simple here and allow you guys to adjust it as we go [Music] now to do all of this I'm going to use a platform called mines DB now you can click the link in the description and create a completely free account you do not need to pay for this I've teamed up with them for this video and they've sponsored it but I've worked with them on some other videos in the past and you guys seem to really enjoy the platform just to give you a quick bit of information on what this platform is essentially this platform allows you to write SQL like queries to generate AI models so what we can actually do is write an entire AI machine learning model based on openai and chat gbt in just a few lines of SQL like syntax now you can hook this up with a bunch of different data sources so in our case the data source is going to be our email inbox but in previous videos I did something like Twitter we could do something like slack messages we could connect this to mongodb or postgres and you can write all kinds of different AI models in this SQL like syntax so here chat box classification forecasting recommendation engine real time research and development and you can see that this is kind of the syntax right create chatbot this using whatever the information is here right let's go and see if they have another one here create a job a job is something that will run recurringly you guys get the hang of it really really cool and if you know anything about SQL this makes it super powerful to actually work with your data and really quickly create machine learning models based on it without having to really know a lot about the implementation details hence why we're going to use it here anyways let's make a new account let's hop into kind of the cloud editor here from minesdb and I'll show you step by step what we need to do to make this AI that can manage our inbox alright so once you've made your free account then you should be brought to a page that looks like this which is the mindsdb cloud editor now to give you a bit of information on how all of this works you can write all of the code that you need and generate all the machine learning models and all that kind of stuff directly from the web you don't need to set anything up locally however if you do have a model that you want to be using in production then what you're able to do is actually connect to the mindsdb host from something like python JavaScript whatever it is and you can then ping the uh the API or you can ping the machine learning model sorry and it will return to whatever data you want now I'll put a video on the screen that kind of shows you how to do that this is another video on the channel that uses mindsdb for now though we actually won't need to leave this window everything can be done here and directly automate the inbox all right so how do we get started well the first thing with mindsdb is we need to add a data source so you can go here and click on new data source you also could upload a file or a machine learning model and you can go through here and kind of select one of the I think like over 130 data sources that they currently support so pretty much any place you could imagine you can connect to in our case we want to connect to Gmail so I'm actually not going to use this graphical editor instead we're going to write some syntax that will connect to our Gmail account now in order to connect to the Gmail account we actually need to generate something known as an app password now this isn't the most secure way in the world to do this so be careful if you're going to be running production applications with this however to generate an app password we're going to go to our Gmail account so you can go to my account.google.com that will bring up whatever Gmail account you're currently signed into now obviously you can change your account from the top right hand corner just by signing in signing out Etc but I don't want to leak my accounts so I won't do that and what we can do is simply search app password like this in the top bar here and click on app passwords which will be under the security pane now I need to sign in so let me sign in and then I'll show you how we generate the password alright so once you're brought to this page then what you're able to do is click on select app choose what you want in our case it's going to be mail right because we're generating this for Gmail and then you're going to pick a device you can just pick other it doesn't actually matter the device that you pick and then you can give this a name so something like server two whatever you want to name it right API Gmail Etc what will happen is you'll generate the app password and then you need to copy it directly because you won't be able to see it again now I already have one so I'm not going to do this but what you guys will do generate that app password once that app password is generated then we are good to go and we can go back to minesdb alright so to create the integration or the connection with our emails what we need to do is create a data source now I'm going to copy in some syntax here just to save us a little bit of time feel free to pause the video here and type this out so what we have here is create database and then the name of the database which in this case will be the email data source just keep it that name it'll be easier as you follow along with engine equal to email and then we pass in the parameters which are equal to some curly braces and then we pass our email and the app password for the email that we just generated so I'm going to go ahead and run this obviously I'll blur out my information here and then it will create a new data source for us this takes a second and once that data source is generated we can start running normal SQL queries to view the information in that data source so this data source will contain a bunch of our different emails and we can query them you know however we would normally query a database so what I can actually do here is write a select query and say select asterisks from and then this is going to be the email underscore data source dot emails like that when I run this we should see that we get a bunch of emails appearing kind of in this bottom terminal tab that I'm pulling up on the screen and we should see all the different columns and information in it now I'm hopefully not going to leak too much information when I do this but let's give it a second to run and then I'll show you the result alright so that query has finished running and you can see that it's giving me a bunch of different columns right ID created at 2 from subject body Etc now some of you may be saying okay well that's useful but I would want to use this in an app again you can actually connect to this from code there's all kinds of tutorials from mysdb regardless you see that we're getting some emails I don't really want to leak too much information but I think this is fine if you guys see you know monetization opportunity you can imagine the emails that I get and regardless now that we know how to select from there I'll just show you one more query that we'll select based on say a specific subject or something and then we can actually move on to looking at how to send emails and how to generate replies to specific emails so let me copy in another query here which to save us a bit of time so what I'm doing here is I'm selecting ID to subject body from email data source.emails where the subject is equal to something specific I'm ordering it by the ID and then I'm limiting limiting it sorry to five now this is just an example of a more compound query you can run that's going to have some more filters and checks in this case we're checking the subject we could check the to field we can check the from field uh there's a bunch of fields we can check right so anyways that's one I'm not going to run this just wanted to show you that that's another query you could use so now that we've done that let me show you quickly how we would send an email from something like minesdb then once we know how to read our emails and send emails we can combine those two together with that chat gbt integration which will allow us to generate the replies and then actually send them to specific emails alright so to send an email we're going to write the following query insert into email datasource dot emails to subject body now what we're putting here is the different parameters that we're going to have so in this case the two Fields is going to be this the subject is going to be this the body of the email is this right and then we have the values so we would put the email we want to send to the subject and then we put the body now I will change this to an email that I have access to that I can leak in fact we can just send this to the email that is available um at my YouTube description so that's not one that I'm leaking Tech with Tim at viralnationtalent.com don't email me you will get a reply from chat gbt just kidding anyways what I can do is run this here and I'll show you in a second when I go to my email that this will be generated right so we'll have this so let's go down here and see it says query successfully completed so I'll show you that new kind of unread or just sent email and then we'll move on alright so as you guys can see here the email was received and says hello from minesdb just sent zero minutes ago okay so that is working so now at this point we know how to read and send emails and we now need to start generating some replies which is going to involve using an AI table now ai tables are the implementation of machine learning models in mindstv they're very interesting because we can use SQL syntax to query the AI model so it seems a bit strange I know but it's actually really useful and super easy to work with because we can combine different queries with our data sources and take information from one row or from one table and pass that into the AI table which will then generate a reply or response for us in a new row or a new column depending on how we set it up you'll see what I mean I know that was probably a bit confusing what we're going to do is start creating a model so again I'm just going to copy in the syntax I know I'm copying a lot of stuff here but it's going to be faster than me typing all of it out and potentially making a mistake so what we do to create a new model is we say create model and then we say minesdb dot the name of the model in this case I'm naming it sponsorship reply now what I want to do is predict some field so I'm saying I'm predicting a response okay so this is the field that we will use when we actually want to get a response and you know use that as a reply to the email okay so create model mind CB does sponsorship reply we're essentially just naming the output column here which in this case is response and we're saying we're going to use a specific engine now there's all kinds of different engines we can use here in minesdb they have classification regression they probably have better ones for this use case but I love using chat GPT and open AI so that's the one that I went with so I said using engine equal to open AI Max tokens is 300 and then we need to pass the openai API key I'll show you how we get that in one second so we pass the API key we passed the model name this is the most recent one as of filming this video and then this is the most important part here that you'll adjust which is the prompt template now the prompt template is what we are essentially using as our AI model or our machine learning prompt so the way that I always use chat EBT is I'll just come up with a good prompt that contains some variable data in this case that variable data is the body of the email and it will then kind of do what I say as like a mock machine learning model I'm not sure if that makes sense but if I read this to you'll see what I mean so first determine if the following email is related to sponsorships if it is reply to the following email in a personalized polite and professional manner make sure to include my sponsorship rates and explain what each one is obviously these are fake but an insert maximum 60 second integration into a video costs ten dollars and a dedicated YouTube video costs fifty dollars if it is not related to sponsorships return the exact string of no reply here is the email and then this is the email right here which is the body of the email okay so I'm asking Chad gbd to First tell me okay is this related to sponsorships if it is give me the reply and then we'll generate the reply and send that to the person okay so now that we have that what we'll need to do is generate this API key and obviously you guys will write this prompt template based on what you want to occur um for chat gbt right or for the AI model so if you wanted to talk about you know why they should come visit your storefront or you wanted to just reply to people and tell them to call your phone number whatever you wanted to do that's what you would put in the prompt template right you specify what kind of reply you want in my case I've specified this is the reply and it will make it personalized based on the person that sent the email okay so how do we get this API key well let me go to the openai website and I will show you alright so what we need to do to get our openai API key is we first need to have an account with openai I assume most of you probably already do if you're using chat EBT and then we're going to go to platform.openai.com okay I'll leave this link in the description from here we'll click on the settings we'll go to view API keys and then what we can do is generate a new key now you can see I already have a key obviously I will delete this after the video so that you guys don't steal it but you click create secret key give it a name and then it will generate a key for you which you can copy and use wherever you would like okay so that's it that's how you get the API key also can just go directly to this link platform.openai.com account slash API Keys okay now we have our API key you know we paste that inside of here and we can just go ahead and run this and it's going to start generating a model for us once the model is generated I'll show you how we use it with this SQL query which is quite useful so after a few seconds here this model should be finished you can actually check if it's done by going to minesdb over here models and you can see sponsorship replies here there's also a query that you can use for that but I'm not going to show that to you right now anyways the model is finished and the way we use this is we just query it like a normal SQL table now this will seem a bit weird but I'm just going to paste in a query here and explain this to you so I'm saying select body response from mindcb.sponsorship reply which is the name of the model we just made right where body is equal to and then we specify in here the body that we wanted to generate a reply for now that's because remember when we generate the model inside of those double curly braces which represents a variable this is the prompt template we named it body right so if I go back here you can see that we have body so if we add two variables like body and then we had subject then we would pass multiple where Clauses so let me paste this back in we'd say where body equals that and subject is equal to this right so you would pass multiple variables in this case we're just passing one variable okay so select body response from mindtv.sponsorship apply where the body is equal to this response will be that output column and it will run that chat GPT kind of prompt on this and then give us whatever the response from chat gbt was so let's run this here and give this a second and let's see what it actually says for the reply all right so we have the body here all right and then if we go over here to response we can see that it says I'm pleased to provide you with our sponsorship rates and then it kind of says all this here dedicated video please know these rates are subject to change if you have any specific requirements blah blah blah best regards and then we could have put this in the template right to say you know reply as Tim rosica from this company blah blah blah and we can fine tune that template as much as we want and kind of keep remaking the model all right so anyways that is how that works so we now are able to generate a reply now the interesting part comes when we start hooking this up with our email data source what we can do now is we can actually query our email data source and then we can combine that with a query to our sponsorship reply so it's like joining a table in SQL right that's what we can do and then we can keep generating that response column output so that we can see what the replies would be for the emails we actually have in our inbox so I'm going to paste in a pretty complex query here but this will do exactly what I just described where again we're kind of combining the AI table which is really what it's called with our data source and then generating a column or an output for every single piece of our data source with that AI table all right so I've just pasted in the query here let's kind of run through it so select asterisks from and then we have an inner or kind of compound query in here where we're saying select eatup audio's body r dot response as reply and then e dot subject from email data source dot emails as e join mindsdb.sponsorship reply as R so again if you're familiar with query or with SQL Server now with query what we're doing is joining the tables together where now what will happen is the AI table will generate a reply column for every single body entry that it has here then we'll say where e dot subject is equal to this the reason I put this here is I only want a generator reply for one specific email this is just for the video but for you guys you could remove this right you can keep this order by and then you can limit it to say 10 just so it doesn't take forever to run so that's the query all we have to do really is just join a data source with the AI table it might take a little bit of experimenting to come up with the correct query and then you'll see that it will generate replies for all of the emails that are in our data source so let me go ahead and run this uh we'll give it a second to complete and then I will show you the result alright so I just changed the query a little bit to get it to work because for some reason it wasn't finding that other email subject that's possible I deleted that email regardless we have this here which is an email I get a lot actually and anyways uh you can see that it has the body and then if we go over here it has the reply now I won't go through the whole reply because it does actually leak the person's name so I don't want to put that in the video but you can see it gives us that reply column which was generated by the AI table so that's exactly how you would do this in terms of mixing the two tables together obviously you can write more complex SQL queries and you can filter this better so you're only replying to specific emails like it's a certain sender it's a certain body it you know text is contained in here whatever you want to do that's valid SQL syntax so now at this point we know how to actually generate this query the last thing we need to do is make it so that we do all this but then we actually send an email so that would be one additional step where now we're combining this with that send email syntax so we generate the reply and then we actually send that reply to the person now we want to do this on some kind of increment right every hour every two hours every day so we're going to use something in mindsdb called jobs now jobs are just like cron jobs pretty much where they'll run whatever increment you set them at and it's super useful because we don't need to set up a server or handle anything ourself mindsdb can just take care of it for us so again I'm going to paste in another large piece of syntax by the way I'll try to keep all of this kind of in the description below so you guys can copy it in alright so this is the code here we're going to write create job minesdb dot email reply what's the name of the job as and then we put the query inside of here that we actually want to run so what we're doing is inserting into the email data source dot emails the two subject body now what that's going to do is take two so who we're sending it to the subject of the email then the content and add that in and then we're selecting e.2 e dot subject and s dot response as the body so now you can see we're saying from email data source dot emails e that means we're labeling this as e where we're getting the 2 and the subject from We're then joining that to the AI table minesdbe.sponsorship reply labeling that as s and getting the response for every single email that matches this query here we're then going to insert the reply into the email data source it will actually send that email now what I'm doing here is just having a where Clause I say where edot subject is equal to the following just so we only reply to that email and then we're limiting this to 10. now obviously you could remove the if you want and then you'd be replying to every single email anyways we'll put those back here and that is pretty much it we're then doing the time increment and we're saying we're going to run this job every single day for this specific job the minimum increment is day so you can't do something like hour uh you can actually only do day I tested this out previously and that's the one that works in terms of the minimum increment okay so that is all the code again this will be available from the link in the description if you wanted to test this out by the way before you actually start sending emails to random people you can go here to the to field and you can just fill in your email no actually we need single quotes here but you could do something like Tim at techwithtim.net and then you'd be able to test and see if all these replies are good maybe you want to forward the replies whatever you want to do but this is a way that you could actually test it out now I'm not going to run this job because I've already tested it it's working and well I don't want it running right now but obviously you would just run the query it would go ahead and create this job and now I'll show you actually how you would delete the job what you can do is you can write drop job and if you write drop job that's going to delete it so if for some reason you want to get rid of it once you make it you can just do drop job and then you are good to go alright so I think with that said that's going to wrap up this video I know there's a bit of complexity here there's a bunch of queries stuff you're going to have to copy in obviously it's just not that easy to make an AI that manages your inbox however with minesdb we could do this relatively fast compared if we had to code this on our own and I will try to leave all of the syntax that I mentioned in this video in the description down below I hope I have enough space there so you guys can just copy it directly from there rather than having to type everything in anyways if you guys enjoyed make sure to leave a like subscribe to the channel again check out my instb from the link in the description thanks to them for sponsoring this video and I look forward to seeing you in another one [Music] foreign
Original Description
Today, I'll teach you to program AI To Manage Your Inbox (Emails). This AI can perform simple tasks such as summarizing emails and sending you a bulk email to more elaborate functions like responding to emails and much more!
Start your MindsDB Cloud FREE Trial here: https://s.mdb.ai/free-cloud-account
Use MindsDB open source version here: https://github.com/mindsdb/mindsdb
Explore MindsDB docs here: http://s.mdb.ai/mindsdb-docs
All queries available to copy here: https://github.com/techwithtim/MindsDB-AI-Email-Assistant/tree/main
🎞 *Video Resources*
Google App Password: https://myaccount.google.com/apppasswords
OpenAI API Key Link: https://platform.openai.com/account/api-keys
Previous Video With MindDB (GPT4 Chatbot): https://www.youtube.com/watch?v=SWd_KU70C0s
🎓 *Premium Courses*
🏢 _CourseCareers_ https://coursecareers.com/a/techwithtim
🔗 _BlockchainExpert_ https://algoexpert.io/blockchain (use code “tim”)
💻 _ProgrammingExpert_ https://programmingexpert.io/tim (use code “tim”)
🎓 *Free Courses*
📚 _Introduction To Software Development_ https://coursecareers.com/a/techwithtim
⏳ *Timestamps*
00:00 | ChatGPT Manages My Inbox
01:06 | MindsDB Setup
02:37 | Authorizing Gmail
05:47 | Getting Emails
07:35 | Sending Emails
09:35 | Creating Our AI Model
12:20 | Getting an OpenAI API Key
13:10 | Using The Model
18:05 | Creating a Job/Automation
🔗 *Socials*
📸 _Instagram_ https://www.instagram.com/tech_with_tim
🐦 _Twitter_ https://twitter.com/TechWithTimm
💬 _Discord_ https://discord.gg/twt
🤝 _LinkedIn_ https://www.linkedin.com/in/tim-ruscica-82631b179/
🌐 _Website_ https://techwithtim.net
💾 _GitHub_ https://github.com/techwithtim
*Support*
👕 _Merch_ https://teespring.com/stores/tech-with-tim-merch-shop
💵 _Donations_ https://www.paypal.com/donate?hosted_button_id=CU9FV329ADNT8
🙏 _Patreon_ https://www.patreon.com/techwithtim
🔖 *Tags*
- Tech With Tim
- Chat GPT
- E-Mails
#️⃣ *Hashtags*
#programming #chatgpt #email
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Tech With Tim · Tech With Tim · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
A* Path Finding Algorithm(Visualization)
Tech With Tim
Python Programming Tutorial #1 - Variables and Data Types
Tech With Tim
Python Programming Tutorial #2 - Basic Operators and Input
Tech With Tim
Python Programming Tutorial #3 - Conditions
Tech With Tim
Python Programming Tutorial #4 - IF/ELIF/ELSE
Tech With Tim
Python Programming Tutorial #5 - Chained Conditionals and Nested Statements
Tech With Tim
Python Programming Tutorial #6 - For Loops
Tech With Tim
Python Programming Tutorial #7 - While Loops
Tech With Tim
Python Programming Tutorial #8 - Lists and Tuples
Tech With Tim
Python Programming Tutorial #9 - Iteration by Item (For Loops Continued...)
Tech With Tim
Python Programming Tutorial #10 - String Methods
Tech With Tim
How to Overclock a NVIDIA GPU
Tech With Tim
Python Programming Tutorial #11 - Slice Operator
Tech With Tim
Python Programming Tutorial #12 - Functions
Tech With Tim
Python Programming Tutorial #13 - How to Read a Text File
Tech With Tim
Python Programming Tutorial #14 - Writing to a Text File
Tech With Tim
Python Programming Tutorial #15 - Using .count() and .find()
Tech With Tim
Python Programming Tutorial #16 - Introduction to Modular Programming
Tech With Tim
Python Programming Tutorial #17 - Optional Parameters
Tech With Tim
Python Programming Tutorial #18 - Try and Except (Python Error Handling)
Tech With Tim
Python Programming Tutorial #19 - Global vs Local Variables
Tech With Tim
Python Programming Tutorial #20 - Classes and Objects
Tech With Tim
Cool VBS Script to Prank Your Friends!
Tech With Tim
How to Overclock an AMD GPU
Tech With Tim
Best GPU'S For Mining Ethereum (2018)
Tech With Tim
Recursion and Memoization Tutorial Python
Tech With Tim
Ethereum Mining Rig - Hardware Guide
Tech With Tim
Pygame Tutorial #1 - Basic Movement and Key Presses
Tech With Tim
How to Install Pygame (Windows 8/10)
Tech With Tim
How to Trade Your Cryptocurrency (Bitcoin, Ethereum etc.) For Cash!
Tech With Tim
How to Mine Ethereum 2018 - WORKING (Super-Easy)
Tech With Tim
Microphone Comparison - $10 Mic vs $150 Mic (Blue Yeti USB)
Tech With Tim
Pygame Tutorial #2 - Jumping and Boundaries
Tech With Tim
Pygame Tutorial #3 - Character Animation & Sprites
Tech With Tim
Pygame Tutorial #4 - Optimization & OOP
Tech With Tim
OBS Studio Tutorial - Best OBS Settings
Tech With Tim
Linear Search Algorithm - Python Example and Code
Tech With Tim
Make Any Mic Sound AMAZING! (WITH OBS)
Tech With Tim
Binary Search Algorithm - Python Example & Code
Tech With Tim
Pygame Tutorial #5 - Projectiles
Tech With Tim
Pygame Game - Mini Golf
Tech With Tim
Pygame Tutorial - Projectile Motion (Part 1)
Tech With Tim
Pygame Tutorial - Projectile Motion (Part 2)
Tech With Tim
Pygame Tutorial #6 - Enemies
Tech With Tim
Pygame Tutorial #7 - Collision and Hit Boxes
Tech With Tim
Pygame Tutorial #8 - Scoring and Health Bars
Tech With Tim
Cloud Mining vs. Hardware Mining - 2018
Tech With Tim
How to Install Pygame on Mac OSX (Fast-Simple)
Tech With Tim
Pygame Tutorial #9 - Sound Effects, Music & More Collision
Tech With Tim
Pygame Tutorial #10 - Finishing Touches & Next Steps
Tech With Tim
How to Fade Your Screen in Pygame [CODE IN DESCRIPTION]
Tech With Tim
How to Create a Button in Pygame [CODE IN DESCRIPTION]
Tech With Tim
Pygame Side-Scroller Tutorial #1 - Scrolling Background/Character Movement
Tech With Tim
Pygame Side-Scroller Tutorial #2 - Random Object Generation
Tech With Tim
Pygame Side-Scroller Tutorial #3 - Collision
Tech With Tim
Pygame Side-Scroller Tutorial #4 - Scoring and End Screen
Tech With Tim
How to Create A Message Box in Python - Tkinter
Tech With Tim
Is Ethereum Mining Still Profitable - Is It Worth It (April 2018)
Tech With Tim
How to Run MAC OSX on a WINDOWS PC (Clover Boot-loader)
Tech With Tim
Programming Problem #1 - Alphabet Soup (Beginner/Novice)
Tech With Tim
More on: LLM Foundations
View skill →Related Reads
📰
📰
📰
📰
OpenAI makes ChatGPT Health available to all U.S. users
TechCrunch AI
I built an AI-first bank statement converter. The one rule that stopped it lying to me.
Dev.to AI
Building trade assistant: How Jefferies optimized front office trading operations with AI
AWS Machine Learning
Changes to LLM pricing: Novita and StreamLake
Dev.to · Narev Bot
Chapters (9)
| ChatGPT Manages My Inbox
1:06
| MindsDB Setup
2:37
| Authorizing Gmail
5:47
| Getting Emails
7:35
| Sending Emails
9:35
| Creating Our AI Model
12:20
| Getting an OpenAI API Key
13:10
| Using The Model
18:05
| Creating a Job/Automation
🎓
Tutor Explanation
DeepCamp AI