📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

Claude Code + Trigger.dev: I'm Never Building Agents the Same Way

Nate Herk | AI Automation20:57

Transcription

So, I've been using Cloud Code for a while now, and I opened up trigger.dev for the first time, I'm not kidding you, like an hour and a half ago, and I've already got a couple really nice automations and agents set up. I can already tell that this combination is going to be a core piece of my workflow, whether it's internally or for clients. And this combination of Claude Code and Trigger Dev, is insanely powerful.

So, the first thing I tried was just building a workflow to scrape Nate B. Jones YouTube videos. He's like my favorite AI news channel. And it would check if he's got a new video. If yes, it would give me the key highlights. If no, it would do nothing. And so this is what the result looks like with minimal prompting. We've got the YouTube video. We've got key concepts, quotes worth remembering, stats, and data. So that's cool because I spun this up in like 10 minutes, but really it's not that impressive.

But then I thought to myself, because of the way that trigger.dev works, I want to put an agent in the cloud. So what I did is I built an agent that watches this list in my ClickUp. And whenever I put in a company as a task, it will basically do research about them. So I put this in, it triggers the agent, it does research, and then it comes back and leaves a comment for me. But not only that, but the agent can also conversate with me in here. So for this one for Enthropic, I said, "Hey, does this company have a recent valuation?" And it did more research and came back to me. So this is not just a deterministic 1 2 3 4 5 type of automation. This is a non-deterministic, I have different tools. I need to decide what loop I need to go in. And that's where I was like, "Okay, wow. I just did all of this in like 20 minutes. This is cool."

So by the end of this video, you will understand exactly how you can build workflows and agents in Cloud Code, put them on trigger.dev, and automate pretty much anything. So before we jump into building, let's just get on the same page. We use Cloud Code to describe what we want in plain English. This could be saying something as simple as, "I want to monitor YouTube for new AI videos and send me a daily summary." Cloud Code will then say, "Okay, well to do this, I need X, Y, and Z from you." So it turns a vague request into an actual working automation. Then it goes ahead and it starts writing its code. Like I said, these can be simple tasks like fetching data from an API or they can actually be kind of complex agents that have different tools and have different actions they can take and they have to decide when is good enough. And that actual automation or that agent is code and that is basically a project and that's like a file. And then what we need to do is get that out of our local Cloud Code environment on our laptop or our desktop and put that into trigger.dev on the cloud so that these can actually run all the time.

And so in past Cloud Code videos, you might have seen me use something like Modal. So why are we using trigger.dev over Modal today? It's just a lot more flexible. It has scheduled runs. It has automatic retries. It's got queuing. It's got orchestration, which is the element of different tasks and things like that, which is really cool. And I just think it's got a much cleaner UI as well.

So here's my current project in trigger.dev in production mode. And you can see that I've got basically these six different kind of tasks. These three are the actual tools. So this is the process video. This is the responder agent. This is the researcher agent. And then these ones with a clock next to them are scheduled tasks. So we've got the YouTube checker, we've got the research polar, and the follow-up polar. If I go over here on the lefthand side to schedules, you can see how often these run. So these two run every 2 minutes, and this one runs every 8 hours. If I go to runs, you can see all of the different runs that we've had, whether they have been completed or whether they've failed. And so I filtered to show you a failed run because I wanted to see the retry. So this was a ClickUp research polar, and what happened was it failed. And so it adds a delay and then it tries again. So it has this automatic retry built into it which is really cool. And when we're watching these agents or tasks run live, we see exactly every step that they're making and we see how long they take on each step.

So I'll do a live demo and I'll show you guys this. All right. So I'm in my ClickUp and what I'm going to do is add a new task and I'm just going to go ahead and say Nvidia and I'm going to save that. And now that that has been processed, we're going to have to wait in here and we'll see the ClickUp research polar start up and then it will basically say, "Okay, cool. I found a new task and I'm going to send that to the company researcher agent." So right here we can see that that got picked up. It got sent to the researcher. And if I open the researcher, which is currently executing, you can see it live running. So we can see right here that it's running for Nvidia, which is the one that we just put in here. Right now, Claude is calling it search web tool and it called it twice. It actually decided I'm going to invoke it one more time to make sure I get a comprehensive research report. Now it's using a read URL tool. It's using another read URL tool. So maybe it found two websites to look at. And there we go. After about 45 seconds, it has finished.

So now if I open up ClickUp and we go to Nvidia, we can see that this is now marked as complete. And when I click on it over here, we can see that we got a full research brief about Nvidia. And so now if I come into this task and I say at UPAI, how is their stock doing? It's going to read this. But keep in mind, it has to come in here and it has to read the context to make sure it knows who is they. In this case, when I just said, how is their stock doing? And if I go back to runs, you can see that the follow-up responder is now executing. If I click into it, we should be able to watch it actually looking at this task searching the web. And now after about 22 seconds, this one has finished. I'm going to open up ClickUp, and we should be able to scroll down and see that we just got a response right here from UpAI.

Okay, so just a little quick demo and wanted to show you guys what trigger.dev dev looks like before we actually get in there and we build one out ourselves. And I know these aren't the most impressive things in the world, but keep in mind all of these were oneshot prompted and I built these in the past like 45 minutes.

Okay, now hopping into Cloud Code. This is the Cloud Workflow builder project that I just set up and I started building these workflows in. If you've never used Cloud Code before, then I would definitely recommend you hop over to this video. I'll link it right up here and then once you understand like the interface and how the files work and everything like that, then come back and it will make a lot more sense.

So, what I'm going to do in this video is I'm going to create a brand new project and walk through everything with you guys step by step so you can see exactly how it works. But real quick before we do that, I just wanted to show you kind of what this end result looks like because these folders and files build up as you build more workflows. Really, the main thing that I wanted to show you guys is where those TypeScript files actually live, which is right here in a src. We've got the trigger folder, which is trigger.dev, and then I've got two different folders for the different types of workflows. We've got the AI news digest which is the two, you know, the process video type script and the YouTube check type script which you guys saw right here. YouTube check and process video. And then we have the company research ones, the two polars and the responder and the researcher agent which you guys saw right here. The two polars and the researcher and responder. So really what I wanted to do there is just contextualize for you guys how Cloud Code helps us build these TypeScript files and then we push those to trigger and then they can actually run live. But I did promise you guys we're going to do all of this together.

So, I'm going to go ahead and open up a new folder here. I made a new folder called trigger demo. And it's completely blank. And now you guys should have your Cloud Code instance looking exactly like I do. And by the way, I am using this in VS Code. So, I'm going to close out of this stuff. Open up Claude Code. And we are now on the same page.

So, the first thing I want you to do is go over to my free school community. The link for that down in the description. Go to the classroom. Go to Claude Code and go to the trigger.dev section right here. and you're going to grab the claw.mmd file and the trigger ref.md file. You're going to download both of those and then you're basically just going to drag both of those into the lefthand side right over here. I'm not going to dive super super deep into this, but the trigger ref file is basically like the trigger.dev API reference and how to do TypeScript. And that's important because in the bottom of the claw.mmd file, we tell it to look here if it ever needs to look at code examples, patterns, and things like that. So, now that you guys have the claw.md file in here, you've got the trigger refile in here. We're going to be able to build automations a lot easier now.

All right. So, what I'm going to do is give Claude code a pretty vague request. I'm just not even going to use plan mode and I'm going to show you how good it's going to be. I need you to build me an automation that's going to go off every single Monday and it's going to search the web and it's going to find me um leads. It's going to find me dental practices that I can sell websites to. So, I'm going to shoot that off. And what it's going to do first of all is it's reading the cloudmd file to figure out what its goal is. And hopefully, it should come back and ask us some questions so that it knows how to build this workflow well because we didn't tell it anything about text stack or hardly anything at all. And it needs to write this automation really well for us.

So, the first thing it does is it asks us where should the leads be delivered each Monday. And I'm just going to go ahead and say ClickUp. For location, it says where should it be searching? I'm just going to say nationwide. And then the final one is, do you have SER API, Google Maps, anything like that set up? And I'm actually for this one going to click other. And I'm going to say I don't yet have any of that set up. And ideally, I don't want to have to pay for any sort of subscription for this. And we'll see if it can figure it out with that. I'm going to tell it to create a new list in my ClickUp. And for volume, I'm just going to go ahead and do 25 leads small batch just to start.

Now, mine is going to cheat a little bit because in the past, it's already used my ClickUp. But what you would need to do is it will basically create you aenv file and you will put your project secrets in thatv file. So that will be like your ClickUp API key or your workspace ID or your open router API key, things like that.

So now it asks us if we're ready to build this plan. So we have our Monday dental lead generator. Every Monday at 8 a.m. we will search Yelp Fusion AI for dental practices across the US and then we'll create new tasks in the dental leads list in ClickUp. Yelp Fusion's 100% free. Awesome. For the architecture, it's going to create basically two different tools, let's call them. The first tool is going to find leads and the second tool is going to create the leads in ClickUp, which is great because if one thing fails, it can retry and it can, you know, ceue up just that one task rather than having the whole automation break. And this is awesome. It's automatically doing the item potency like I talked about earlier. And it's making sure that the same practice never gets added twice. And having this dduplication process be automatically taken care of is really nice. So, I'm just going to tell this to go ahead and start building.

So, as usual, it starts setting up the project, as you can see, as well as it is creating its to-do list, and it's going to go through and build this out for us. Okay, it built that really fast. It said that it made a new ClickUp list for us, which if I go to ClickUp, we can see right here, we've got dental leads. It created the two type scripts. So, if I look up here, we've got trigger, we've got dental leads, and we have create lead as well as find leads. And this is the part where I said it cheated a little bit because it already had our list ID from earlier. But what we need to do now is go get our Yelp API key. So, I'm going to go grab that. And then we need to put in a ClickUp API key. Wow. So, it ended up finding out that Yelp killed their free API tier. So, it's going to change this to use SER API instead. Okay. So, now it's already changed that to use SER API. So, I've got those two API keys. And here's what we're going to do. We're going to go to the ENV. And you can see that it's put this placeholder in here for SER and for ClickUp. So, you're going to come in here and paste in your two API keys. And then you're going to make sure to save this file and then you can close out of it. Okay. Okay, so it wants to do its test run in the dev environment in our trigger.dev. So remember, we're in production. We can also be in dev. So this is where we can test things. This is where we can make changes. And then when we're good with that, we push that to production to actually be live.

So what I'm going to do is in my trigger.dev, I'm going to open up a new project since this is what your guys would look like. We're just going to call this one test. And I'm going to go ahead and create that. Now once we're in here, I'm going to go down to the bottom and go to project settings. And right here, we see a project ref. So I'm going to copy this value. And we need to give this to Claude Code so it can actually move stuff into here. Okay, so it's working away right now, but you can see that we do have two tasks in here. We have our find dental leads and we have our create dental lead. If I go to schedules, we should see that the find dental leads runs at 8 a.m. only on Mondays. And now what it's doing is it's going to try to test it out to see if it actually works. But what's going to happen is it's probably not going to work because if you guys remember, we had to give Claude code here our env, you know, ClickUp API key as well as that SER API key. But those API keys don't actually get pushed anywhere. They don't get pushed to GitHub. They don't get pushed to trigger.dev because they're in av file. And if anything here has a dot before it, it's basically hidden from like commits and stuff like that. So what we actually have to do is we have to go into trigger.dev. We have to go all the way down here to environment variables and this is where we add those once again. So I'll click add new and all I have to do actually it's really simple is I come into the file over here. I can copy this entire thing and then when I go back into trigger I can paste in that entire thing and all three of those will get put in not just like having to do that one by one. And now before you save this you're going to want to do it in development and production because there's no point in adding it just to development because ultimately you're going to push it to production. So you might as well just do development and production and then go ahead and save that. And now trigger when it's actually running those TypeScript, you know, files, it can actually use these API keys in its work and it will actually be successful.

So what happened was this was trying to actually trigger a test run in trigger. So it was trying to do this by itself. But one thing that you can do to make this actually a lot better is you can give it the trigger.dev MCP server. So here's a file that you can drag into the lefthand side. It basically just sets up the MCP configuration for trigger.dev. And I will also link this in the same exact classroom section right here. So you can just download it and drag it in. But now I can go ahead and ask it to try to test it out again. And hopefully it works and it can send over a payload and all that kind of stuff. And the thing I want you guys to understand too is yes, I just did this, but it it's a little bit different every time you build it because ultimately what's happening is we're talking to an AI model that thinks and has decision capabilities. So, if you're entering in the exact same prompts that I am, you might not get the exact same result. So, it's really just a matter of talking to it, asking what's wrong, and helping it out. And so, now it's asking us for a trigger.dev secret key. Well, let's go into trigger.dev. Let's go over here and go to API keys. And we need to grab this and give that to cloud code. But, of course, I don't want to give this straight into the chat. So, I'm going to say, "Hey, I've got this. Can you put a placeholder in the envir practice to never give secrets right here in the chat? You want to just put it into like config files or usually thev." Okay. So, just paste it in that API key. I've saved it. And now let's see if it can actually restart the server and try to test out our workflow. This is why it's so tough doing like live cloud code demos. It's just cuz like it literally runs different every time.

Okay, so it says that it triggered a run. Now, if I come back in here and I go to runs, we should see. Wow. Okay, so we actually got a lot of different runs come through. It was trying a lot of different things. These are currently executing right now. Oh, okay. Well, the reason why it did so many is because it had to do one create dental lead for every single lead that it found. And if I open up my ClickUp, we can see that we do have 25 leads right here. So, let's just click into one to see what it looks like. We've got Tampa Dental in Tampa, Florida. And in the description, it gave us the address, the phone, the rating, and the website. So, that's really interesting to me. The first workflow, which is the trigger, it finds the leads. So, if I open this up and I click into it, we can see what it did. It found five and then it found five more. And it found five more until it got to 25. And then after it found those 25, it basically said, "Okay, cool. I'm going to hand each of these leads to one individual kind of like worker." And that is why we saw the create dental lead tool get called 25 times. Cloud Code comes back and says, "Cool, it works perfectly. 25 leads created in 9 seconds across five cities. Pretty awesome."

So, from here, obviously, what you'd do is you'd iterate upon the workflow a little bit. You'd try to make it better and better. You'd add different features if you want. Maybe we want to add personalized outreach and add like an AI element in there. But now once you get to a spot where you're ready, we want to push that into production because right now we're in development. Meaning if we don't keep this connection open right here, it says your local dev server is connected to trigger.dev. If this wasn't open like we see in our main project right here, you can see I turned it off. Then these would not be running, which is why we have to push them to production.

So there's a few ways to do that. So the way that I would recommend doing this is by connecting to GitHub and pushing your codebase. So basically this entire project into GitHub. So like you can see this is the GitHub repo that I made for the previous workflows and I had all of them in one GitHub repo which is fine in this case. If I go to the SRC trigger you can see that we had the AI news digest and the company research. So here's what we're going to do. We're going to push this project into GitHub and then have GitHub sync with trigger.dev and then they'll be able to bring everything into production. And now once again, I just wanted to throw out there, this is why you have to make sure that things are in AENV and that you're not having any secrets in your project because otherwise they'll be in GitHub. And I always make them private either way, but still it's just best practice. And then you're going to add, of course, your API keys into trigger.dev.

So at this point, what it's probably going to do is it's probably going to use your command line interface and it's going to ask you to login with GitHub. So once you get authenticated, it's really easy and it can create repos and it can you know make commits and it's very very simple. So if you guys have watched any of my videos where we've built websites then you know exactly how this flow works. We're building code in cloud code we push that to GitHub and then GitHub automatically syncs with forcell or in our case trigger.dev meaning that we have our actual live automation or our live site automatically syncing with GitHub. And the reason why we want to use GitHub is for version control. It keeps things, you know, in the cloud and we can also do more collaboration with other engineers, other people, whatever it is. So, I'd say getting familiar with GitHub is probably a good idea. And just to really hammer it home, you can see it says good.env is excluded from our commit to GitHub.

Okay, awesome. So, we now have our new GitHub repo right here. It's called trigger- test. So, I'm going to open that up. Make sure we are good. Do we have our workflows? Yes, we do. Right there. And now I'm going to go back into trigger. I'm going to scroll all the way down to project settings. and I'm going to connect a GitHub repo. I'm going to sign up with my account and I'm going to connect the repository that we just made and hit connect. Now, right here it says every push to the selected tracking branch creates a deployment in the corresponding environment. Which means every time we have a new push to the master branch in our GitHub repo, it will automatically get synced into our production environment. So, right now we're in development. If I go to production, we should see that it's going to actually build up these things now that I've connected our GitHub repo. Because right here in GitHub, you can see that we are in the master branch and we have our TypeScript right here.

Now, if for some reason this isn't working or you don't want to take the GitHub route, you can always manually deploy this kind of stuff and you can just tell Cloud Code to look at this and it will help you push this into the production environment. Okay, so you can see that those just got pushed through into production. And unfortunately in live production, this would actually only run at 8 a.m. on Mondays. So, we're going to do a manual run right here. I'm going to go in here. I'm going to hit test. And I'm just going to go ahead and hit run test. And so, that's going to go ahead and trigger this off. We're going to watch this actually find those 25 leads. Remember, it should automatically be not loading any in if it's already processed them before. So, it's looking in Tampa, Tulsa, Arlington. It found these leads. And if I go to runs, it's also it should be scheduling all of these for ClickUp, which 7:29 p.m. It's doing that right now. And if I go into our ClickUp, we should see now that we have 50 leads in here. And I just want to make sure that none of these have been duplicated. Okay, actually it looks like some of these are. So, let me just show you guys real quick what we might do about that.

So, I just did a test run of finding leads and it all worked. However, I did notice that some of the leads were duplicates. So, I thought that you had worked on item potency here to make sure that that didn't happen, but apparently it was happening. So, can you fix this? Okay, so it made a change in the create leads workflow where it's basically going to search ClickUp before creating and now have a place ID. So, it says that this change should be more permanent, but it doesn't affect the ones that already were made. So, I'm going to go ahead and run this twice and we'll see if there's any duplicates. Okay, so I had to do a few more changes. And this really shows the importance of using plan mode and having a really good idea of what you want built before you actually tell it to go build it. For the sake of the video, I was trying to show you how I could just kind of oneshot prompt and and it would still be pretty good. But this example showed really why you need to plan harder because the search criteria wasn't very big and it had a weird way of dduplication. But now we're in a much better spot where we now have 48 rows and it shows that some of them were filtered out because they were duplicates and it was like searching again and again until it was able to fill up all the slots and now we have more companies. So anyways, all of these were being ran in our development environment because we didn't want to mess with anything in prod. And now what we would do is we'd come back in here and say, "Cool, this looks good." Push this to GitHub. and then trigger would automatically pull those live changes from GitHub and we'd be all set for Monday at 8 a.m.

Okay, so hopefully by now you guys feel confident in your ability to hop into Cloud Code, go to my free school community, grab these resources, chuck them in there, and then start building some automations that you can then throw into trigger.dev to just run all the time for you. If there's one thing that I want you to take away from this video, it's the fact that AI is still very much a blackbox. These models are insanely smart. you can see what they do. But you also saw in this video how I had to talk so much to it and I had to like just be very clear. It's just the whole idea of you no longer having to write code, but you having to be the person that assures the quality and make sure that it's on track. But anyways, I'm having so much fun learning these new tools and diving into different use cases. So definitely let me know in the comments what you guys want to continue to see. And if you really want to stay tapped in, if you want more courses, if you want live Q&As's, and a community of over 3,000 people who are building their own businesses with AI, then definitely check out my paid community, AIS Plus. The link for that is down in the description. I'd love to see you guys in either of these communities. But that's going to do it for today. So, if you enjoyed the video or you learned something new, please give it a like. It definitely helps me out a ton. And as always, I appreciate you guys making it to the end of the video. I'll see you on the next one. Thanks everyone.