Facebook Group Alerts
This tool automatically notifies you of interesting posts published in preconfigured Facebook groups. It runs every hour, fetching each group's feed and marking each post as interesting or garbage, based on the configurable whitelist
and blacklist
rules. Once an interesting post is detected, it automatically sends an e-mail alert to preconfigured e-mails with the post link and content.
Use Case
Facebook Group Alerts can be used to receive alerts about interesting apartment rental posts. This is useful in case you are a member of several Facebook groups whose members post all sorts of apartment rental listing posts and you wish to filter them according to specific parameters (such as the number of bedrooms, pet allowance, etc), all while getting a near-realtime notification as soon as they are posted, so you can snatch one of the apartments before somebody else does.
Requirements
- MongoDB instance to avoid duplicate alerts
- Node.js
v4.2.x+
for ES6 generators support - Facebook User Access Token to read the groups' feeds
- Amazon Web Services account (free tier) + Amazon SES (Simple Email Service) to send the alert emails
- Facebook application with
v2.3
Graph API version for requesting the deprecateduser_groups
permission (this one is a bit tricky)
Instructions
- Set the MongoDB database uri in the
config.js
file (get a free MongoDB database at MongoLab) - Generate a Facebook User Access Token:
- Go to the Graph API Explorer
- Select your application from the dropdown in the top right
- Select
v2.3
as the API version in the request URI input field - Click Get Token -> Get User Access Token
- Select the
user_groups
permission (it won't show up unless you selectedv2.3
as the API version) - Click Get Access Token
- Extend the Facebook User Access Token:
- Visit the following URL, replacing each
{variable}
with its corresponding value:https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id={app-client-id}&client_secret={app-client-secret}&fb_exchange_token={user-access-token}
- Make sure the access token in the response is set to expire in 2 months by using the Facebook Debugger (Yes, you'll have to regenerate and re-extend the access token every 2 months, unfortunately)
- Copy the entire access token to the
config.js
file (set it insources.facebook.access_token
)
- Visit the following URL, replacing each
- Set the Facebook group IDs to scan within the
sources.facebook.groups
array:- Execute a request to
https://graph.facebook.com/v2.3/me/groups?access_token={user-access-token}
to retrieve your Facebook account's group IDs
- Execute a request to
- Set up Amazon SES to send the alert e-mails
- Sign up for Amazon SES
- Verify alert e-mail sender and recipient e-mails
- Create an AWS IAM User
- Copy the IAM user's Access Key ID & Secret Access Key to the
config.js
file within thealerts.ses
object - Attach the
AmazonSESFullAccess
policy to the IAM user
- Configure the whitelist and blacklist keyword arrays to control which posts are marked as interesting and which are ignored
- Set the
filter.blacklist
array with phrases in posts that will mark a post as "not interesting", such as "no pets" - Set the
filter.whitelist
array with phrases in posts that will mark a post as "interesting", such as "renovated"
- Set the
- Run
npm install && npm start
to test it out (you may receive lots of e-mails if configured loosely) - If everything works as expected, deploy to a cloud service of your choice (AWS Elastic Beanstalk recommended, using the free tier)
- Enjoy automated alerts about interesting posts delivered straight to your inbox!
Collaborating
- If you find a bug or wish to make some kind of change, please create an issue first
- Make your commits as tiny as possible - one feature or bugfix at a time
- Write detailed commit messages, in-line with the project's commit naming conventions
- Make sure your code conventions are in-line with the project
License
Apache 2.0