Using N8N and Gemini to detect spam Github Issues
Feeding my ADHD dopamine addiction today and scrolling through X/Twitter I saw a post from someone about spam Github Issues. The titles contained explicit words advertising adult videos and things like that. The purpose of these, I am not sure. However, until Github has a way to block these I though I would setup a quick way to do it in N8N and an ai text classifier.
What is N8N
N8N is simply a very user friendly and open source process automation tool. Just like something you would see with Zapier or Make.
How do we use it with Github
N8N has a lot of prebuilt triggers, anything from manually clicking a button to chat interactions. We will be using the built in Github Issue Trigger. You can read about that trigger here. This will require authentication so you can setup a credential in N8N using a Github Personal Access Token, that process is described here.
Pipe it into a text classifier
The data you recieve from the trigger will provide you your title and under body.issue.title
which we will pass to the text classifier. Using the classifier you can setup different categories, for this example I setup spam and not spam. Each category also provides a description. This is where you describe what should land in each category and the model will use as a prompt to help it figure out what it should classify into this category. These can be changed as needed with your testing to see what fits your use case.
I used these descriptions:
- spam: Consider something spam if it contains explicit words or doesn't appear to be an actual issue with a code repo
- not spam: Consider something not spam spam if it contains something that looks like it could be a real code issue.
Handling the results
Once the text classifier has classified the title it will pipe it out through a path with the name of the category it classified it as. You will see a hook for each one of the categories in the visual builder. From here we can hookup different actions depending on how its classified. In this use case we can just hook up a action to the spam category to do whatever we want, probably something with the issue in Github.
Here is a picture of the final setup where we are just piping the data out to Execution Data which just stores the data that came out of the last execution. You can replace any of these with anything you want, including custom code via Python or Javascript.
Conclusion
N8N is an amazing tool that you can use for very simple automations like this or setup very complicated processes to make your life easier. With it's built in AI features such as the text classifier or their agent builder the sky is the limit.