Notifications for free developer swag 🎉
Tags: twitter, javascript, showdev, node
Published: 2021-01-18 01:27:37

## Backstory

I love building things and recently placed as a runner up in the [digitalocean hackathon](https://dev.to/devteam/digitalocean-app-platform-hackathon-winners-announced-ig0) and am pretty stoked to be getting **moar hoodies**! After my subtle brag about getting all the swag, a friend of mine then told me "why don't you make an app to automate getting more hoodies?".

![alt text](https://media.giphy.com/media/4jHXZ9aIKFaUM/giphy.gif)

What a _fantastic_ idea.

## What I built

I originally had a reddit bot written in node.js and thought "I have so many uses for bots, I don't want to deploy a new one for each idea. That would be a pain."

![alt text](https://i.imgur.com/mQgXJqy.jpg)

For my use case, I went against the whole microservices trend and kept all the scheduling and configuration for my three bots inside one long running process called `all-the-things-bot`.

For the sake of staying on topic, you can browse the source [here](https://github.com/circa10a/all-the-things-bot).

## Free Dev Shit Bot

<img src="https://i.imgur.com/12TpTP6.png" height="35%" width="35%"/>

A bot that notifies you of potential opportunities for free dev shit also called "swag". Because we always need more laptop stickers, shirts, and hoodies!

After refactoring my app to support multiple bots, schedules, and configs. I implemented the "Free Dev Shit Bot". The bot is available on two platforms at the time of this writing.

- [Twitter](https://twitter.com/FreeDevShitBot)
- [Discord](https://discord.com/oauth2/authorize?scope=bot&client_id=800447160340447322)

### Twitter

Simply [follow the bot](](https://twitter.com/FreeDevShitBot)) for updates!

<img src="https://i.imgur.com/FOYDULy.png" height="50%" width="50%"/>

### Discord

Create a channel called `swag` in your discord server and [add the bot to your server](https://discord.com/oauth2/authorize?scope=bot&client_id=800447160340447322). The bot will check daily for free swag opportunities and notify you in the channel!

<img src="https://i.imgur.com/SYMoTfQ.png" height="50%" width="50%"/>

### What it does

The bot will scan [dev.to](https://dev.to) for the terms "free swag" and will tweet the article with a link and post to `swag` channels on all subscribed discord servers.

## How it works

At the start of the application, all bots are initialized and scheduled with [node-schedule](https://github.com/node-schedule/node-schedule). The Free Dev Shit bot is scheduled to post to twitter and discord servers at 11:55 PM CST. The logic behind the scenes searches the [dev.to `feed_content` API](https://dev.to/search/feed_content?per_page=60&page=0&sort_by=published_at&sort_direction=desc&class_name=Article&search_fields=free+swag) by filtering the last 60 articles which is ordered _newest_. The bot then processes those 60 and finds any that are less than 24 hours old and has more than 1 public reaction(for credibility). If we have any results, simply post to all the things. The dev.to API is definitely the MVP here! 🥇

## Resources

- [Follow FreeDevShitBot Twitter](https://twitter.com/FreeDevShitBot)
- [Add FreeDevShitBot to your Discord server](https://discord.com/oauth2/authorize?scope=bot&client_id=800447160340447322)
- [My all-the-things-bot source code](https://github.com/circa10a/all-the-things-bot)