This integration service posts RSS feeds into specific Mattermost channels by formatting output from html to text via Mattermost's incoming webhooks. It can also be managed through slash-commands.
To run this integration you need:
- A network connected device running python like Raspberry Pi or any other Linux device which supports python and the required packages or running Docker
- A Mattermost account where incoming webhooks are enabled and optionally slash-commands enabled
The following procedure shows how to install this project on a Linux device running Ubuntu 14.04. The following instructions work behind a firewall as long as the device has access to your Mattermost instance.
To install this project using a Linux-based device, you will need Python 2.7 or a compatible version. Other compatible operating systems and Python versions should also work.
Here's how to start:
-
Set up your Mattermost instance to receive incoming webhooks
- Log in to your Mattermost account. Click the three dot menu at the top of the left-hand side and go to
Account Settings > Integrations > Incoming Webhooks. - Under Add a new incoming webhook select the channel in which you want Feed notifications to appear, then click Add to create a new entry.
- Copy the contents next to URL of the new webhook you just created (we'll refer to this as
https://<your-mattermost-webhook-URL>
).
- Log in to your Mattermost account. Click the three dot menu at the top of the left-hand side and go to
-
Set up a new slash-commands on your Mattermost instance to manage the feeds
- In the Integrations Menu, go to Slash Commands.
- Under Add a new slash command, enter the name of your command, a description and the word to trigger the command. The Request URL is simply the address to reach the machine where the project run. The default port is
8080
but is overriden byintegration_listening_port
.
You can optionally opt-in for Autocompletion, and use this value :
/rss-bot list | add <Feed Name> <Feed URL> [<Image URL>] [<Show Name>] [<Show Title>] [<Show Description>] [<Show URL>] | remove <Feed Name>
- Click Add to create the new command and copy the Token value for the command you just created. We'll refer to it as
<your-slash-command-token>
.
-
Set up this project to run on your Linux device
- Set up a Linux Ubuntu 14.04 server either on your own machine or on a hosted service, like AWS.
- SSH into the machine, or just open your terminal if you're installing locally.
- Confirm Python 2.7 or a compatible version is installed by running:
python --version
If it's not installed you can find it here - Install pip and git:
sudo apt-get install python-pip supervisor git python-virtualenv
- Clone this GitHub repository:
git clone https://github.com/bitbackofen/Rss-Atom-Feed-Integration-for-Mattermost.git
cd Rss-Atom-Feed-Integration-for-Mattermost
- Copy sample file
settings.py.sample
:
cp settings.py.sample settings.py
- Edit
settings.py
to suit your requirements:
nano settings.py
Save your changes (F2) and exit nano (CRTL-X) - Setup virtual environment:
virtualenv -p python2 env
source env/bin/activate
(env) $ pip install -r requirements.txt
Leave virtual environment:(env) $ deactivate
- Test the the feed fetcher:
./env/bin/python ./feedfetcher.py
You should see your feeds scrolling through. Check your configured Mattermost channel for the new feeds.
If everything works fine: - a) Start feedfetcher with nohup:
nohup ./env/bin/python ./feedfetcher.py &
b) Alternatively: Start feedfetcher with Supervisor:sudo cp Rss-Atom-Feed-Integration-for-Mattermost.conf.sample /etc/supervisor/conf.d/mRss-Atom-Feed-Integration-for-Mattermost.conf
- Edit the supervisor configuration file:
sudo nano /etc/supervisor/conf.d/Rss-Atom-Feed-Integration-for-Mattermost.conf
and change paths incommand=
anddirectory=
to suit your environment. - Tell Supervisor to look for any new or changed program configurations:
sudo supervisorctl reread
- Followed by telling it to enact any changes with:
sudo supervisorctl update
Refer to this tutorial for more information about Supervisor.
This config assumes that the feed fetcher will run on the same computer as mattermost as well as that a own user/group called rss was created for feedfetcher.
Place the following config under /etc/systemd/system/rss_atom_feed_integration_for_mattermost.service
:
[Unit]
Description=RSS integration for mattermost
After=syslog.target network.target mattermost.service
[Service]
Type=simple
User=rss
Group=rss
ExecStart=/home/rss/Rss-Atom-Feed-Integration-for-Mattermost/env/bin/python /home/rss/Rss-Atom-Feed-Integration-for-Mattermost/feedfetcher.py
PrivateTmp=yes
WorkingDirectory=/home/rss/Rss-Atom-Feed-Integration-for-Mattermost/
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
Please note:
- Remove
mattermost.service
fromAfter
if the fetcher was installed on a different computer than mattermost - change
User
andGroup
to the user and group that the fetcher should run under - change
ExecStart
andWorkingDirectory
to the actual installation paths
Now you can start the fetcher with systemctl start rss_atom_feed_integration_for_mattermost.service
to enable auto-start on boot type systemctl enable rss_atom_feed_integration_for_mattermost.service
This integration also works with Microsoft Windows:
- Download Python 2.7 from Python.org and install it
- Download mattermost_integration_rss from Github or get it using
git clone https://github.com/bitbackofen/Rss-Atom-Feed-Integration-for-Mattermost.git
- Extract the archive to a directory of your choice if you downloaded archive.zip.
- Start a command prompt and cd into your Python installation directory: e.g.
cd c:\python27
- Install requirements using
Scripts\pip.exe install -r \path\to\Rss-Atom-Feed-Integration-for-Mattermost\requirements.txt
cd \path\to\Rss-Atom-Feed-Integration-for-Mattermost\
- Start the Script:
C:\Python27\python.exe feedfetcher.py
(changeC:\Python27\
if you installed Python elsewhere).
- cd into your mattermost_integration_rss directory:
cd /path/to/Rss-Atom-Feed-Integration-for-Mattermost
- Stop feedfetcher:
sudo supervisorctl
supervisor> stop Rss-Atom-Feed-Integration-for-Mattermost
Exit supervisor (CRTL-c) - Update mattermost_integration_rss
git pull origin master
- Have a look at
settings.py.sample
for changes. - Start the feedfetcher:
sudo supervisorctl
supervisor> start Rss-Atom-Feed-Integration-for-Mattermost
This integration is also available as a Docker image.
- Set up any box with Docker on it or access to a remote Docker Host.
- Clone this GitHub repository:
git clone https://github.com/bitbackofen/Rss-Atom-Feed-Integration-for-Mattermost.git
cd Rss-Atom-Feed-Integration-for-Mattermost
- Copy sample Compose and Feeds files:
cp docker-compose.yml.sample docker-compose.yml
cp feeds.env.sample feeds.env
- Edit the environment variables of
docker-compose.yml
to suit your needs. If a variable is omitted, the default value is used (except forMATTERMOST_HOOK_URL
andMATTERMOST_CMD_TOKEN
) - Complete
feeds.env
with the desired RSS feeds - Spin up the container with
docker-compose up
You should see your feeds scrolling through. Check your configured Mattermost channel for the new feeds. If everything works fine: - Start the container with
docker-compose up -d