RSS SMS is a script which allows you to subscribe to RSS feeds and be notified of certain posts by SMS if they match your desired keywords. For example, if you wanted to know about deals on OzBargain for CPUs, makeup or chocolates you could subscribe to their RSS feed and use the keywords 3900x, Mecca, and Ferrero Rocher respectively. I find this script incredibly useful for this exact purpose as the deals I am interested in may run out of stock in as little as 60 minutes and checking OzBargain this frequently is impractical. Almost all news, podcast, and user forum sites have implemented RSS feeds for their content.
This readme will walk you through how to set up this script on your own hardware or using a variety of Amazon's services. If you have access to a free SMS API such as Pushbullet or Telstra*, then you can run this script entirely for free.
*In the past, Telstra has offered 1,000 free SMS messages per month for its customers using their API, however I am unsure if this was the result of multiple promotions or just their normal policy.
This quick start guide has not yet been written but is on the todo list. Please see Set Up for a more in-depth walkthrough of how to deploy RSS SMS.
To be written..
- Run locally
- Twilio SMS API
To be written..
- Deploy to AWS Lambda to run the script
- Set up AWS SNS to send SMS
- Set up AWS S3 to store data
- Set up AWS Cloudwatch to schedule the executions
To get RSS SMS working you will need to deploy it and set up the chosen APIs. I strongly suggest that you set up and run RSS SMS locally to ensure that you can get it working before deploying it elsewhere. This will help to save you some sanity.
The config.yml file is used to specify the RSS feeds and keywords that each mobile number is subscribed to. You can specify multiple mobile numbers, multiple RSS feeds for each number, and multiple keywords (regex is supported) for each RSS feed. Most SMS APIs require you to use the E.164 international telephone numbering plan.
The keywords are case insensitive and can be grouped together so the texts you receive are more readable. For example, in the config.yml file shown below if the keyword Hershey(|')s
is triggered, then the SMS would show "Alert: Chocolates" instead of "Alert: Hershey(|')s".
# Configuration file config.yml
# Australian Number
'+614XXXXXXXX':
https://www.ozbargain.com.au/deals/feed:
- 3900x
- Mecca
- Chocolates:
- Ferrero Rocher
- Cadbury (Dairy Milk|Marvelous Creations|Favourites)
- Hershey(|')s
- All knives:
- kni(f|v)e
http://www.hellointernet.fm/podcast?format=rss:
- "#137"
# United States number
'+14XXXXXXXX':
- ...
You will also need to set up a .env file or environment. The required variables will depend on the chosen APIs and will be described in APIs.
You will have to clone the repo and install all of the dependencies. I recommend you use a virtual environment to install your dependencies as it will make deployment much easier if later use AWS Lambda.
git clone <URL>
cd rss-sms
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
I recommend you use the local file management API to manage the config.yml and texted.yml files. This is configured at the top of the main.py file as shown below.
# Import APIs
from file_apis.file_local import FileLocal
# Assign APIs
file_config = FileLocal()
file_texted = FileLocal()
You will also need to choose an SMS service as described here.
You will need to run RSS SMS constantly throughout the day so it can always check the most recent posts. You can accomplish this using cron to create a cronjob that runs on a schedule. The following command will run main.py and log its output to rss-sms.log every 10 minutes.
*/10 * * * * PATH_TO/python3 PATH_TO/main.py >> ~/rss-sms.log
AWS Lambda provides you with a free and easy way to run RSS SMS. The online web console makes it easy to edit your config.yml file as needed. You have up to 1 million requests and 400,000 GB-seconds of computer time per month for free*. This is more than enough to run RSS SMS every 10 minutes or more.
To get started, you will need to create an IAM user as described here. Make sure you add the AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
variables to your .env file or environment as these are required to use the AWS API as your user. Since AWS Lambda is stateless, you must use the AWS S3 file management API or similar to manage the texted.yml file. The config.yml file however, may be managed using the local file management API. If you are using AWS Lambda and you do not have access to a free SMS API, I recommend that you use the AWS SNS service and double down on the Amazon ecosystem.
You will need to read the APIs section to set up each of the APIs. The top of the main.py file should look as follows.
# Import APIs
from sms_apis.sms_aws import SmsAws
from file_apis.file_local import FileLocal
from file_apis.file_aws import FileAws
# Assign APIs
sms_client = SmsAws()
file_config = FileLocal()
file_texted = FileAws()
*As of 14/03/2021
You need to create a deployment zip file containing the required source files. Complete the following steps.
- Create a new folder called deployment
- Copy the main.py file into the deployment folder and rename it to lambda_function.py
- Copy the config.yml file into the deployment folder
- Copy the file_apis, sms_apis and url_apis folders into the deployment folder
- Select and zip the contents of the deployment folder and name it deployment.zip
You can now create the Lambda function. Complete the following steps.
- Navigate to the AWS Lambda console
- Select 'Functions' in the navigation pane
- Click 'Create function'
- Choose the following
- Author from scratch
- Name: rss-sms
- Runtime: Python3.X
- Click 'Create function'
- Click 'Upload from' and select '.zip file'
- Upload the deployment.zip file that was created earlier
AWS Lambda allows us to control our dependencies using Layers to reduce the size of our deployment file. Complete the following steps.
- Create the following folders python/lib/python3.X/site-packages/
- Copy the contents of the site-packages folder in your virtual environment and paste them into the folder created above
- Likely located at venv/Lib/Python3.X/site-packages, venv/Lib/site-packages or similar
- Zip the root python folder and name it (i.e. rss-sms-dependencies.zip)
- Navigate to the AWS Lambda console
- Select 'Layers' in the navigation pane
- Click 'Create layer'
- Choose the following
- Name: rss-sms-dependencies
- Upload: Choose the rss-sms-dependencies.zip created earlier
- Compatible runtimes: Python3.X
- Click 'Create'
You can now attach this dependency layer to our Lambda function. Complete the following steps.
- Navigate to the AWS Lambda console
- Select 'Functions' in the navigation pane
- Click 'rss-sms' to edit it
- Under 'Layers', click 'Add a layer'
- Choose the following
- Custom layers
- Custom layers: rss-sms-dependencies
- Version: the latest version
- Click 'Add'
You need to change the function timeout limit as the default 3 seconds is not long enough. Complete the following steps.
- Edit the 'rss-sms' Lambda function
- In the 'Configuration' tab, select 'General configuration'
- Click 'Edit'
- Change the Timeout value to be 3 minutes and 0 seconds
- Click 'Save'
You need to configure the environment variables used by RSS SMS. Complete the following steps.
- Edit the 'rss-sms' Lambda function
- In the 'Configuration' tab, select 'Environment variables'
- Click 'Edit'
- Click 'Add environment variable' and add the required environment variables
- Click 'Save'
You can now run RSS SMS by clicking 'Test', creating a test using the default values and running it. You should receive a text to your mobile if any of the RSS feeds contained any of the keywords from the config.yml file. However, you still need to schedule RSS SMS to run constantly. Complete the following steps.
- Navigate to the AWS CloudWatch console
- Select 'Event' > 'Rules' in the navigation pane
- Click 'Create rule'
- Under 'Event Source', choose the following
- Schedule
- Fixed rate of: 10 minutes
- Under 'Targets', click 'Add target' and choose the following
- Function: rss-sms
- Click 'Configure details'
- Choose the following
- Name: rss-sms-scheduler
- Click 'Create rule'
RSS SMS should run immediately and then again every 10 minutes. Change the config.yml file to trigger on a recent post and run a test to verify that RSS SMS is sending texts correctly and on time.
To change your subscriptions, you just need to edit the config.yml file and click 'Deploy' to save your changes. You can verify that your changes have worked by running a test.
You need to give the appropriate permissions to the AWS user you created earlier. Complete the following steps.
- Navigate to the AWS IAM console
- Click on the user you created earlier to edit them
- Add the following permissions to the user account
AmazonSNSFullAccess
Add the following keys to your environment.
aws_region_name_sms
- You can find a list of SMS supported regions and their costs in this article this article.
monthly_spend_limit
- The maximum amount you want to spend each month on SMS. This may take up to an hour to update.
- Note: By default, AWS limits your SMS quota to $1/month. If you wish to increase this limit, please follow the steps in this article.
By default, the AWS SMS API uses the Transactional
SMS type which ensures that the message is delivered over routes with the highest delivery reliability. This message type typically costs more than the Promotional
SMS type, however in Australia these costs are the same*.
*As of 14/03/2021
Pushbullet is not currently supported although I'm planning to add support in the future as you can send up to 100* free SMS messages per month.
*As of 14/03/2021
Twilio is not currently supported although I'm planning to add support in the future.
Nothing needs to be configured for the local file management API.
You need to give the appropriate permissions to the AWS user you created earlier. Complete the following steps.
- Navigate to the AWS S3 console
- Click on the user you created earlier to edit them
- Add the following permissions to the user account
AmazonS3FullAccess
Add the following keys to your environment.
aws_region_name_file_management
- You can find a list of S3 supported regions and their costs in this article.
bucket_name
- The bucket used to store the already texted RSS posts is automatically created if it doesn't already exist.
Nothing needs to be done to configure the TinyURL API, unless you require custom URLs which this API does not currently support. TinyURL was configured using their public URL shortening service is it produced some of the shortest URLs compared to other options and is free.
Below are a list of known limitations for RSS SMS.
- The only way to be notified of posts is via SMS. Receiving notifications via email for RSS feeds and keywords you care less about is a planned future feature.
- You aren't able to easily subscribe multiple mobile numbers to the same set of RSS feeds and keywords.
If you would like to contribute a new API service, please create a merge request with a clear description of what the new API is, how to set it up, and how to use it.