Check out n8n: https://plug.dev.plug.dev/gSoRcuq
💻️ Need some help with a project or some consulting? Contact me here: https://www.neuralnine.com/services
🐍 The Python Bible Book: https://www.neuralnine.com/books/
💻 The Algorithm Bible Book: https://www.neuralnine.com/books/
Timestamps:
(0:00) Intro
(1:00) Preview
(4:14) Environment Setup
(12:28) Workflow 1: Turn GitHub Issues Into PRs
(29:51) Workflow 2: Turn Slack Messages Into Issues
(40:18) Summary Recap
(41:26) Outro
Оглавление (7 сегментов)
Intro
The project we're going to build today is extremely useful and extremely interesting. We're going to build a completely autonomous AI coding agent using N8N anthropics cloud code and also open AAI for powering an agent. Now, when I say fully autonomous coding agent, I don't mean one of these tools where you just prompt stuff and then they do everything for you and deploy it somewhere. I'm talking about a workflow where I can talk to an AI agent via Slack or I can just create GitHub issues and then this bot takes the GitHub issue, does the changes, commits them and pushes them to GitHub and creates a pull request. So we end up with a coding assistant where all we have to do is text it via Slack or create a GitHub issue and then it goes and works for you. So not only do I think that this is a very interesting project where you can learn a lot, I also think this is a very useful thing to build because I'm going to need it myself in my startup soon. So, if you like this video, let me know by hitting a like button and subscribing. But now, let us get right into it.
Preview
— Now, before we jump right into the video, I want to show you the final result that we're going to end up with today because I think this is super interesting once you see it. What I have here is two N8N workflows. One of these workflows triggers whenever we have a GitHub issue that is being created. It runs a command which executes a script on my PC. We're not going to talk about this here in the preview. I'm going to show it in the tutorial. And it sends a success message via Slack. The second workflow takes a Slack message, feeds it through an AI agent, creates an issue based on that, and also sends a message. This might not sound fancy, but let's see how this actually works. I have a GitHub repository here. It doesn't have anything in it, just the N8 tutorial repo, at least on the main branch. And what I can do now is I can go to issues and I can create a new issue. Ignore the ones that we have here. I can just create a new issue and type some requests. So for example, I can say add the first 10 Fibonacci numbers to readme MD. Then his description do what is described in the title. So this is a very simple issue. It's going to be very easy to implement this. So let's see what happens. I'm going to run this workflow. I'm going to also run this workflow. Um even though we don't need the second one yet. I'm going to create this issue and what you're going to see is that this triggers the first workflow. There is a GitHub trigger. It executes something on my PC which we're going to code from scratch in this video. And after a while, without me doing anything, I'm going to get a Slack message here in this channel, which is going to tell me that it was implemented successfully. And then on GitHub, I'm going to see a separate branch with a pull request where this feature in this case uh quote unquote is implemented. So there you go. I get the message implemented issue 14. And if I go now here, you can see there's a pull request which did exactly what I asked for. So I have a commit message. So we can see here we have exactly what we asked for. We have the first 10 Fibonacci numbers in the readme MD file and that is super convenient. Now this is one workflow. The second workflow in combination with the first one looks like this. I have here the first workflow activated the second one and now I can type create a minimalistic flask application. I type this now in Slack channel. Uh basically just an app py file and an index html file super minimal and concise. So this is now what I sent into this channel. As a result of that, what happens is this triggers this Slack trigger uh initiates an AI agent that now takes the information, creates an issue. I get a confirmation message here that the issue was created successfully. I even get a link so I can take a look at it. And this workflow now also triggered as a result of an issue being created. So now again, what I do is I wait and at some point I'm going to get the confirmation that this worked and I'm going to see the Flask application implemented and a pull request. There you go. Successfully implemented issue 17. Now we can go here to this issue and we have a pull request. If I go to the commit messages, we're going to see that the code for the flask application is there. HTML flask. So this is what we're going to build today. Of course, this also works with more complicated stuff, but I hope this was motivation enough to keep watching. All right, so let us get
Environment Setup
started with the implementation right away. Let me show you briefly the text tag of this video today. So these are the platforms tools that we're going to use also Python locally. We're going to write a Python script but we're going to need N8N for automating the entire workflow for working with the triggers actions. We're going to use clot code in headless mode to do the actual coding. So this is going to be our coding agent that actually implements the changes that we request. We're going to work with Slack so that we can communicate with a bot that can then lead to an N8 end trigger so that we can start the workflow. We're going to work with OpenAI to power uh one agent in the workflow that is going to be responsible for turning Slack messages into GitHub issues. And of course, we're going to use GitHub because we're going to have our repository here and we're going to use GitHub triggers and web hooks. Now, I need to mention for the sake of transparency that N8N is sponsoring this video today. However, I genuinely think that this is probably the easiest way to implement this with N8N. I wanted to build something like this already uh for quite some time because in my startup that I'm currently building I have people my co-founders that are not technical people so they don't know how to code and what I want to build for them and what I try right now is a tool where they can chat with some bot and then it creates pull requests that I just have to merge. So for little UI changes, for example, it makes a lot of sense to have non-technical people create GitHub issues or talk to bots, then they do some changes and then I just have to see um if everything looks fine. So I have to give the final approval, but I don't have to bother or they me with every little UI change. So I think this is a really useful use case and I think N8N makes it very easy to build all of this. Now for the setup, let us start with the most obvious one, which is N8N. We're going to need a feature that's only available in the self-hosted variant of N8N. So you can also use the cloud version, but they don't have the possibility to execute commands locally. My idea here is to run claude code in headless mode locally. So I want to have a Python script that is going to also do the whole commit and push and everything. And this needs to happen locally on my system. Now it's going to be my laptop. When you deploy this, it's going to be the server. And this only works with the self-hosted variant of N8N. So, if you want to build the exact same thing that I built today, get N8N onto your system and use the self-hosted version. Now, how exactly you choose to install N8N depends on your system and also how you want to install it. There's a Docker installation. You can use npm. I installed it on Arch Linux here and this is also something that works for other Linux systems. I basically installed something called nvm, which is the node version manager. So, I basically just said pseudo Pac-Man and of course change this to your package manager, whatever operating system you're using. pseudoacman- sinstall nvm. So that's going to be basically how we install the node version manager. Then you also need to run the source command to initialize it so you can actually use it. You can also put this in your uh bash rc or anything. I'm rushing through this because I don't think that the setup of nn is um super important to cover here because I'm using a system that a lot of you guys are not using. So just get nadn onto your system. The straightforward ways to use npm. However, you need to have a specific node version. So what you want to do is you want to say nvm install and then you can use the version that's recommended either 22 or 24 I think. So in my case I did 22 then nvm use 22. This make sure that you're using node version 22. And then the command that's going to be the same on all systems is npm install and then - g for global n8. This is going to install n8 onto your system. In my case I already did this. So once you have this done, you can just run n8 and it's going to start um the self-hosted variant. However, there is something that you need to consider for GitHub to be able to send triggers to us. So say, hey, an issue was created, it needs to have a URL. So we need to send this web hook somewhere. event somewhere. And this only works if you have a public IP address. So what you can do is you can deploy this on a server and just specify the IP address or the domain. Or if you want to do this on your laptop locally, on your computer locally, you have to use something like a tunnel that allows you to have a public domain at least temporarily. And for this, I use ngrock. So this is also an open source tool. Ngro, this is uh the website. I think it's open source. I'm not actually sure if it's open source, but it actually says proprietary software. So maybe it's not open source. I don't know. But you can just run ngrock to create a tunnel to get a temporary public address. For this, all you have to do is you have to install it in some way. So on Windows there's going to be an installer. On Linux you use your package manager. So on AR you have to use the AUR. So if you use something like Yay you can just install ngrock like this. But basically you can just say ngrock http and then the port of n8 which is 5678. So by doing this what happens is you get a URL this one in this case which is going to forward everything that gets to this URL is going to be forwarded to localhost port 5678. This is important. You need this because GitHub needs to be able to target a web hook URL. You need to be able to send the events somewhere and this is yours somewhere so to say. So to summarize at this point to not make this super complicated, we installed N8N however you do that on your system. We installed ngrock system and we ran ngrock http 5678. So we now have a public uh domain or a public address. Now what we need to do is we need to run N8N but it with a couple of environment variables set up. So the thing is you need to provide the web hook URL that we just created. You also need to provide certain other flags that we're going to need for certain components in our workflow. So the first thing we want to do is we want to say web hook URL all in caps is equal to and then we want to provide the URL. So I'm going to go here again to the ngrock thing. I'm going to copy this and I'm going to paste it here in quotation marks. Then we can do a backslash to start a new line and we're going to say n_editor base URL is equal to and then quotation marks again the same address. So then what we want to do, new line, we want to provide also a flag that is set to true because the execute command note that I talked about, the one that allows us to run Python scripts locally and also that we're going to need to run clot code locally, this needs to be enabled because it's an unsafe note. So we say n again all in caps enable unsafe core notes that is going to be equal to true. Then we can say nodes exclude is equal to an empty list. I'm not sure how many of these we actually need and we need to put that in quotations. Uh I'm not sure if all of these now are necessary. The first three are necessary for sure. The rest is uh yeah just some config I like to pass. By the way, you can of course also just set these up as environment variables. You can create a N file and just source it. But now we're just going to launch it like this. Then we're going to say N8 runners enabled is equal to true. Then we're going to say N8N_Roxroxy_hops is equal to 1. And then we can provide a time zone if we want to. Generic time zone can be equal to in my case now I'm in Europe/ Amsterdam as of right now. And then the last one would be TZ is equal to Europe Amsterdam. But I think the most important ones are the first three. These are just extra. And now the final thing, don't forget this is of course the most important one. N8N. So that's the entire command. Here we have the environment variables. We have n8N in the end. And when we run this now, it's going to be run with all these environment variables. So it knows it allows us the unsafe nodes. And you can see now this is accessible via this URL which is our ngrock URL. Now one thing to keep in mind if you're not actually deploying this to a server, if you're actually using ngrock, every time you start ngrock, you're going to get a different uh URL at least in the free plan. So this is important to consider. Uh you just have to say visit site. It's fine. And now you get to N8N. And now the first time you see this, you're going to have to create an account. In my case, I already used N8N locally, so I just have to log in. But you just create a local account. It's not actually online. It's just on your system. In my case here, I have accounts neuronline. com and a password that I'm going to enter now. And this is now naden. And now I'm
Workflow 1: Turn GitHub Issues Into PRs
going to tell you right away that most of the work that we're going to do here is going to be setup work. So the actual workflow, the actual logic is not super complicated, but you need to set up GitHub, a Slackbot, you need to pass all the credentials, you need to set up all the events, you need to set up the API keys, and then just wiring everything up is not really the biggest issue. The biggest issue is setting up everything so it works. So what we're going to do now is we're going to create a workflow. And this workflow is going to be empty. We start from scratch. And I want to build this in two parts. So I'm actually going to use two workflows here. The first workflow will be GitHub issue comes in, we take the content, we feed it into our script. Our script is going to be our Python script on our system that is going to run clawed code headlessly, which means non-interactively. It's going to execute all the changes. It's going to push everything to GitHub, create a pull request, and then once this is done, we're going to just send a Slack message, for example. The second workflow is going to be a workflow that takes a Slack message and turns it into an issue. So, they're going to trigger one another. I'm going to have a select message. The slack message is going to create a GitHub issue. The issue the trigger or trigger the trigger. And then it's going to start the workflow, do everything, and push an update. So, let us get started here with a GitHub trigger. I'm just going to type GitHub and then we can click here on GitHub. And on triggers, you will find on issues. So, on issues, we can click on this. And it requires a credential. In my case, I have it set up here, but I'm going to create a new one. So if you don't have anything you can click here on create new credential and all you have to pass here is an access token and a user. So for this of course we need to go to GitHub. So I'm going to go here to my GitHub settings. I'm going to scroll down to developer settings then to personal access tokens and I think it was fine grain tokens. Here I have some N8N test tokens already. I'm going to go to generate new token. Now in this case I need to verify myself with GitHub mobile and now I can create a GitHub token. Let me call this N8N tutorial token. So I'm going to allow for 30 days. And what I actually also want to do is I want to allow this for a specific repository. So for the sake of this tutorial, we can create a new repository on GitHub to play around with. So on GitHub here, I can go to repositories, new, and create a new repository. Let's call this one N8N tutorial repo. And let's say it's private, so it's not a public one. I'm going to create a readme file. And then I'm going to say create repository. So this is the one that we're going to play around with. And for this I'm going to create a fine grain token that has access only to this specific repository. So here I'm going to say N8N tutorial repo. And I can now add some permissions. Now the most important one for anything to work here is web hooks. But we're also going to go with pull request. We're issues. uh probably contents. I'm not sure if contents is necessary. Yeah, I think that's fine. But the important thing is you want to give write permissions for these because we're going to do we're going to create issues. We're going to read issues. I'm just going to give read and write for all of these. And then I'm going to generate a token. So click again generate token. And then you get your personal access token here. Copy it. Make sure you don't lose it. Don't show it to anybody. And with this token now that you copied, you want to go back to N8N and you want to type in the user. I think that's just going to be the username neural 9 here. Then the access token is going to be the one that we just got. So I can save this and you can see connection tested successfully. If you see this, it worked. So you basically are now authenticated with GitHub. Make sure you choose the correct account if you have multiple. And now what we can do is we can say, okay, what kind of triggers do we actually react to? For this, we need to first specify the owner. In my case, that's going to be neural 9. There you go. And the repository name is going to be the N8N indent tutorial repo. And the events that we're listening for are issues. Now you can see we do have this web hook URL now. So let's see what happens if I say execute step. This is now listening for the test event. So what I can now do is I can go to the GitHub repository and I can create an issue. So I can go here new issue and I can say test issue and maybe the text is hello world. So I can create this and this is an event which is going to be picked up by the trigger. We didn't see this now in real time but you can see that now on the right side here I have the body and the header of the web hook trigger. So now we have something happened and we can see okay this was the issue one and if we scroll down we can also see title test issue and somewhere here we should also have the content there you go down here body hello world so that's actually all we need because what we're going to do with this issue is we're going to get title body we're going to maybe get some system prompt in addition to that and we're just going to feed this into clot code headlessly so it can work on this and once it's done it's going to deliver the results so for now we can keep that The second thing we want to do here is we want to attach the execute command block. And this is the thing that we had to enable the unsafe core nodes for because that is only enabled if you actually pass this flag. So execute command and with this here we can now execute terminal commands and we can use these fields. Now this only makes sense once we have our Python script. So that's the next thing that we're going to be doing. So here now I am in my tutorial directory. You can pick any directory that you want on your system. I'm going to create another directory here called scripts even though it's just going to be a single script and we're going to say here handleisssue py. So let us get started with the imports. We're going to start by importing os. We're also going to import cis. We're going to import subprocess ssp and then also from path or actually from path lip we want to import path and our arguments. Now we need four arguments for different reasons. We need the repo to be able to clone it. We want to know which repository this is about. In this case, it's trivial because we only have the same repository. So, we could also hardcode it. The second thing is we want to have the number of the issue so we know what branch to create. Our cloud code agent will create a separate branch and push everything there. And we also need of course the title and the body. So, we're going to say repo num title body is equal to cis argument vector and then we're going to start from one because zero is the script itself up until five. So these are now the parameters and based on that we can create the branch name which is going to be uh cloth and then let's say issue num and of course this needs to be an fstring for this to work. Now what we need to do first is we need to clone the repository onto our system if we don't have it yet and otherwise we need to go into this directory and run clot code there. So I'm going to say repo directory is going to be equal to path home that is going to be the home directory of my user. So /home neural 9 and in my case I'm going to go to a tutorial directory again and um also some directories further down. So I'm going to go to home neural 9 documents programming neural 9 and then tutorial of course pick the path that you want. This can be any path on your system and then we have workspace in here is going to be the workspace for cloud code and then repo is going to be the directory of the repository. Cool. So that is that and now what we want to do is we want to say if the repository directory if not repo dear exists. So if it doesn't exist we want to clone it. So for that first of all we're going to create the parent directory repo dear parent domake directory. This is important because of course we need to create a workspace first of all before we can create repo. So here parents is equal to true and then exist okay as well. And then we're going to have our subprocess run SP run. And we're going to run the command for git clone. We always want to say check equals true in the end. But our command is just going to be get clone. And then here we need an string git@github. com and then slash repo or actually sorry it's not slash it's colon repo. git. Now this of course assumes that you can do that. You need to have an SSH key set up. You need to be able to clone the repository yourself. Otherwise, you can also specify the token here. But just make sure you can clone this repository and you run this in the command line. And then the final argument is the string version of our repo directory. That is what we're going to clone it to. Then we want to go into this directory. We want to cd into it. So os change directory to the repo directory. And then we basically just do all the git stuff. So we can say spun git checkout and then main. We want to check out to the main branch. Then we want to pull everything. So just get pull. And then we want to create our own branch. So actually I'm going to copy this here. It's going to be get checkout. But we're also going to add a flag with -ashb. So dash capital B and then our branch which is not a string but our string that we created here clot issue and then the number. So we create a new branch. We check out into this branch. And now the magical part, the entire intelligence is going to be in the next command which is going to be running claude code in headless mode. Headless mode means we don't get clawed code as an interface. We don't chat with it. We provide an instruction and it runs without a user interface automatically. Delivers the code, does all the tool use, whatever. For this, of course, we need to set up permissions. We're going to do that in a second. But for now, we're just going to say clot. The important flag here being -p. This is basically the headless mode. And then we can use an fstring fix issue and then # number. Then we can say just title back slashn and then body. Now once this is done we can say get add everything. So get add and then just dot to add the current directory. And then after this we basically just need to commit and push. So we're going to say get commit dash m for the commit message. And this is going to be a formatted string fix issue and then number. So this is important because we're going to mention the issue number which means that it's going to be tagged. The commit message is going to tag the issue. And then finally we do a get push. So get push-u and then origin the branch that we're using right now because we're not pushing to main. Remember we're pushing to this custom branch. And then to make everything work for sure, we're going to do d-force. So to summarize, what do we do? We get the arguments, the repo, the number of the issue, the title body of the issue. We create a branch. We define a branch name. We see if we already have the repository on our disk. If not, we create a directory. We clone the GitHub repository. We go into the repository. We check out main. We pull from main. We go to our new branch. We fix the issue there with cloud code in headless mode. We add everything. We commit everything. We push everything. And now the final thing that we need to do, this now was all git. Uh what we need for the next one is GitHub. So you need to make sure that you have the GitHub CLI on your system so that you can use the GH command. But then it's basically let me do that here in a more expressive mode. GH then PR for pull request and then create here we can now say d-title maybe. Now this we can do on separate lines. So we can say title like this here and then we can say the title is fix issue with the number and then the title of the issue. Then we would say the body of the pull request that we're creating is just a simple closes the issue number. By the way, of course you can use clot code or any other uh AI to also fill this up with meaningful text. I'm going to keep it simple and say fixes the issue, closes the issue, whatever. Then we're also going to say the base branch. So d-base is going to be the main branch. And finally the head branch is going to be our branch. So if I didn't make any mistakes here, any stupid mistakes, this should work. This is now a script that handles basically the issue processing. And of course, one thing that I forgot. First of all, this here should not be just title as a text. Um and also we need to add check true everywhere. So check true here, check true here and check true everywhere else. All right. So this script is now there and we can just run it here with our execute command node in naden. So how exactly do we do that? We say python 3 that is the command to run this. We provide the full path. So home neural 9 in my case, documents programming neural 9 and then tutorial and scripts and then handle issue. py this is just a full path to the Python script. And then we can drag and drop stuff from here. We said we need to pass the repository. number of the issue, the title and the body of the issue. So the first thing is going to be the repository full name. So body not issue but repository and then full name. That is the repo. We can just drag it here and important we want to put this in quotation marks. So quotation marks and then these double curly brackets to actually use the field. So you can see this translates to neural 98N tutorial repo. The second thing is the issue number. So in issue we have the number here. Drag this here too. Also even though this is an integer we want to put it in quotation marks. And then of course same thing with issue title just put it in quotation marks and then also with the issue body. So, quotation marks. I don't see it anymore here. I'm just going to go down here to issue. Where is it? Issue body. There you go. Hello world. We can just drag this in between the quotation marks. So now the command is Python 3 our script test repo 1 test issue hello world. That is exactly what we want to do. But one more thing before we can run any of this because I got an error. Now we need to set the permission mode correctly. So we're going to go back to our tutorial directory to scripts. And initially I wanted to do a dotclaw directory, but we're not going to do that now. I'm just going to go into the Python file here. And I'm going to attach more arguments here in the end, which is going to be d-permission- mode. And that's going to be accept edits. That's the easiest way to do this. This basically tells it that it can accept edits. We don't need any claw directory with the settings file. That's the simplest way. And now we can run the entire thing again. So I'm going to execute the workflow here. We're listening for GitHub triggers. We can go now to GitHub. You can see I played around with an issue that failed. So, let's try again. I'm going to create a new issue. I'm going to call it hello world. And I'm going to say add the text hello world to the readme MD file. Very simple one. This creates now the issue. This should get our trigger to working. Executes now the command. And as a result of that when I go to the tutorial directory first of all I have a workspace here. In this workspace I have a repo. If I go in this repo you can see claude issue five. It's issue five now because I uh tried to troubleshoot the issue before. But this is now where it's working currently. And now you can see workflow executed successfully. Um, and if I go now to GitHub, we will hopefully see there you go. Fix issue hello world. And you can see that the commits here made the change that it added hello world to the readme MD file. So, we didn't have to do anything. Just open an issue, wait a little bit, and the pull request is there. So, let's maybe try this with something more complicated to see that it actually works. I'm not even going to track anything. I'm just going to stay in GitHub to show you that this works. So, new issue minimal flask to-do app for example. And here now I'm going to say create a minimal flask to-do application very concise just a simple app py file with some HTML files no design super simple I'm just creating this issue now and of course this is not going to work because the workflow is not running. So let's go ahead create a new issue with the same text minimal flask app. Of course when you deploy this will always be running so you don't have to always click execute workflow. So just create the issue now and wait. We're not going to do anything. We're just going to wait. Of course we can take a look at n to see what the progress is. But I'm not going to go into the command line. Not going to type anything. I'm just going to wait for the results to be there. And just by waiting I got here now a pull request. There you go. Fix issue minimal flask gap. I can take a look at the commit and what happened here. We have HTML file index. We have app py full flask application was delivered. I didn't do anything. So that's going to be our first workflow. The second workflow is going to trigger this one. So the second workflow is going to be a slack bot that I can communicate with. I can just send messages into a channel describing what I want to happen. Every message will result in a GitHub issue being created which is going to trigger this workflow and then do everything that we just saw. So for
Workflow 2: Turn Slack Messages Into Issues
this I'm going to go back to personal here create workflow and we're going to start from scratch with a Slack trigger. So Slack trigger then we can say on new message posted to channel. This is what I want to listen for. And here of course we need to set up again the credentials. So click on the pen or if you have one or just create a new credential here and what's required here is an access token. How do we get this access token for this? We need to go to the Slack API. So you can just Google Slack API or you can type API. slack. slack. com/apps. And here we want to create a new application from scratch. So I'm going to click here from scratch and I'm going to call this N8N tutorial bot. And it's going to be in my Slack Workspace neural 9. So I'm going to create the application here. And what this application needs to be able to do is it read messages. react to events. So the first thing I want to do is I want to go to OOTH and permissions. I want to scroll down here to scopes and I want to add oath scopes and the scopes that we're going to add here are channels history, channels read and chat write because we also want to be able to respond with the bot. Then we want to install this to the actual workspace. So we can say install to neural 9 and then we just allow this to be installed onto Slack. Now let me move my terminals to a different workspace here so I can actually see what's happening. So let me move all of this here and here. Now we have uh stuff that I played around with. I'm going to create a new channel. Let's call this one bot automation. Whatever it's going to be a public channel. And the important thing here is actually just to add the channel or to see that the bot is here. So we're going to invite this bot the N8 tutorial bot to this channel. We're not going to be able to use it yet. I'm just going to set it up. And the important thing here is that we get this bot user OOTH token. So this is the access token that we're going to need for N8N. I'm going to go to N8N. Paste a token here. Save. This is going to tell me again connection tested successfully. This means that this actually worked. And once this is done, we can set up the web hook URL. But before we can test the URL, it is required here that we select a channel. Which channel should we select? You just click on the channel here. Bot automation in my case, the one I created. Scroll down here and copy the channel ID. So just click copy channel ID. Go back here by ID. Enter the channel ID and then we can do execute step or first of all we should copy the URL. Copy the test URL. Execute step. Go back to the Slack API. Go to event subscriptions. And here now we need to enable events and provide a web hook URL. So I'm just going to paste this here. And while this is running, it's very important that you do this while this is running here. Otherwise it's not going to work. Um you need to do that. Then you're going to see verified and then we can go and subscribe to bot events which is going to be message channels. So this is important. Without this it will not be able to react to messages that are sent in channels. All right. Now once all of this is set up we can go back here and reinstall to neural 9. So just reinstall to the workspace allow. Copy the token again. Go back to N8N. It's a bit tedious because we need to do it uh like this. But just go to the Slack account too. Paste the access token here. Save it. It's again going to be tested successfully. And now we can listen. We can go to Slack and I can say hello bot. And this is going to trigger the Slack trigger. You can see message. And the important thing is here text hello bot. So this works. The trigger works. The next thing we want to do is we're want to use an agent. We're going to use OpenAI here so we can try different models. We have Enthropic and OpenAI. Um, and what we're going to do is we're going to take that Slack information, the Slack message, and we're going to instruct the agent to turn it into an issue title and issue body. So, I'm going to go here and type agent AI agent. Um, and the important thing is we're going to choose here the Open AI chat model. Now, for model, what you need to do is you need to set up an OpenAI API key. I'm not going to do this now. You just go to the OpenAI platform. You log in, you get the key, you paste the API key. I think you will be able to do that. Um, I'm going to use the one that I already have here. So, you just provide an OpenAI credential here. And then important, we also want to have a tool attached, which is a structured output tool or actually in order to be able to use that, we need to go into the agent and say require specific output format. This is going to allow us to use the structured output parser because that is what we need to get the issue title and the issue uh body. And now for this here I don't want to type it out um on video because it would just waste a lot of time. So we're going to go define using JSON schema and I'm going to copy paste this. And you can see now the basic structure. You can pause the video and type it. It's just type object properties repository full name if we need it issue title issue body. I don't even think we are going to need repository but issue title and issue body is what we need. We just need to create a new issue with this information. So we're going to get the slack message. We want to turn this into a prompt. For this we're going to go into the agent and say define below for the source of prompt. And here we're going to say turn the following Slack message into a GitHub issue with title and body. And then we can just say colon and drag and drop the message which is our hello bot here. So we just drag this in here which is JSON blocks zero element zero text. And then just to make sure it doesn't hallucinate keep it simple and concise. Don't add anything that was not asked for. So that is that we will be able to take this uh I'm not going to do this now with the message that we have here but we're going to assume that this works and the output is going to be the structured JSON object. So we need to then take this and turn it into an issue. Now maybe to work with this let's execute the workflow again and make it actually do something useful. Change the color scheme of the application to red. This would be my message. This triggers. Now the AI agent is working on this and it will produce a structured output object. So there you go. Workflow executed successfully. We're going to look at what this looks like in a second. But here now we're going to say create or actually I will type GitHub. Then we're going to go for an action which is going to be create an issue. So you can see the output here is issue title change application color scheme to red. Issue body change the red essentially. So we use the same credentials from before. GitHub account 2 in my case. Resource is issue. Operation is create. We select again neural 9 as the repository owner here. And we select the N8N tutorial repo and the title is going to be the issue title. The body body. That is all we need to do. So by having this I can just say execute step and this is going to create a GitHub issue. So if I go now into my repository here to issues, we can see change application color to red. So this workflow already functions. The last thing I want to do is I want to return a Slack message. So I want to say Slack uh send message. Where is that? Down here. Send a message. I want to use again Slack account 2. Message send message to channel. We can do again by ID. Just go back here. Scroll down. Copy the ID. Paste it here. And the message text is successfully created issue. And then maybe we can also add the URL of the issue but maybe the HTML URL like this. That is good. So I can actually execute this now and on Slack I get the message successfully created issue with the link to the issue and automated this uh automated with this init workflow. Cool. All right. So this already works. The only thing left to do now is to run them in parallel to run them simultaneously. And also one thing that I want to do is I want to add a Slack message to the other one. So I want to go back to my workflow 3 which is the uh the one that executes the commands. I want to do Slack and then send a message again. And here I want to say successfully implemented. Uh and then maybe PR. No, we actually don't have a PR ring. Uh PR link. So I'm going to say successfully implemented issue and then we can say uh from our GitHub trigger we can get the issue number issue hashtag number that should work. So now let us see what happens when we run both of them simultaneously. So I'm going to have one here and I'm going to run this. this and we're going to see what happens if I say uh we need to consider that on the main branch we don't have anything. So let's start with something simple. Add ABC to the readme MD file. So that's super simple. I'm going to run this. This should trigger first of all the workflow on the bottom. You can see it did that. So the AI agent now will create the issue on GitHub. Will give us a message back tell us that it successfully created the issue. There you go. Issue is created. Oh, but we actually have a problem executing this workflow because we didn't specify the channel uh that we want to send this to. This is a stupid mistake on my end. So, let me copy the channel ID here as well. So, channel by ID. Do this. So, this should now work. Let's repeat the whole thing again. Execute both workflows. Let me send the same message. Add ABC to the readme file. Run this. This runs the first workflow that will create the issue. There you go. Issue created. We also get the message that this issue was created. We can also see it down here. This now triggered the GitHub issue trigger executes the command locally. Executes clot code locally. Um and then after a while I should be able to see the changes pushed onto GitHub with a pull request. There you go. Successfully implemented issue 12. You can also see here on GitHub fix issue 12. Add ABC to readmemd commits. And there you go. So this is a very
Summary Recap
useful thing. You can also combine this maybe in a single workflow. Let me recap one more time before we end this video. how all of this worked. We have a GitHub trigger that always triggers when we create issues. These issues then are taken. We get the number, the repo, we get the title and the body of the issue. We feed that into our Python script which basically just runs a bunch of git commands. So here we have the handle issue py file and what it does is it takes a title and the body of the issue primarily. It clones the repository, checks out into a separate branch, uh runs clot code headlessly with accept edits permission mode. It adds everything, commits everything, pushes everything, then uses the GitHub CLI to create a pull request. Once this is done, our workflow sends a Slack message. And down here we have the Slack trigger, which is basically a pre-step, a step before the other one, which basically allows me to send a message to Slack. This message is taken by an AI agent powered by OpenAI and using structured output, it creates an issue title and an issue body. Then we use this GitHub component here to create an issue and we send a success message with a link to Slack. So that's it for this
Outro
video today. I hope you enjoyed it and hope you learned something. If so, let me know by hitting a like button and leaving a comment in the comment section down below. Also, don't forget to check out N8N, the sponsor of this video. You will find everything you need in the description down below. Make sure you check them out. It's a very useful tool. It's a very interesting use case to try this. Maybe it helps you if you work in a team with non tech people. And besides that, don't forget to subscribe to this channel and hit the notification bell to not miss a single future video for free. Other than that, thank you much for watching. See you in the next video and bye.