Mattermost community members are invited to fork this repo to create new integrations. To have your integration referenced on http://www.mattermost.org/webhooks/, please mail [email protected] or tweet to @MattermostHQ.
Powered by Giphy.
To run this integration you need:
- A web server supporting Python 2.7 or a compatible version to run this software (optionally, you could use a service provider like Heroku - see instructions below)
- A Mattermost account where outgoing webhooks are enabled
Regarding 1. there are many options for web servers you can use, below we provide instructions for both Heroku and a general Linux/Ubuntu server to get something running:
To install this project using Heroku, you will need:
- A Heroku account, available for free from Heroku.com
- A GitHub account, available for free from GitHub.com
Here's how to start:
-
Create a copy of this project to manipulate
-
From the Github repository of this project click Fork in the top-right corner to create a copy of this project that you control and can update as you like.
-
Deploy your project copy to Heroku
-
Go to your Heroku Dashboard and click + in the top-right corner then New App. Give your app a unqiue name (like
mattermost-giphy-[YOUR_GITHUB_USERNAME]
), select your region and click Create App. -
On the Deploy screen, select GitHub at the top, then click Connect to GitHub to authorize Herkou to access your GitHub account
-
Select your account and search for your repo name by typing
mattermost-integration-giphy
in the repo-name field, then click Search and then the Connect button next to your repository -
Scroll to the bottom of the new page and under the Manual Deploy section click Deploy Branch, making sure the
master
branch is selected -
Go to Settings > Domains > Settings and copy the URL below Heroku Domain (we'll refer to this as
http://<your-heroku-domain>/
and we'll need it in the next step) -
Leave your Heroku interface open as we'll come back to it to finish the setup
-
Connect your project to your Mattermost account for outgoing webhooks
-
Log in to your Mattermost account, and from three dot icon at the top of the left-hand menu go to Account Settings > Integrations > Outgoing Webhooks > Edit
-
Under Add a new outgoing webhook, leave the Channel unselected and enter
/gif
into Trigger Words -
Paste your Heroku Domain into Callback URLs, making sure to add
http://
to the beginning and/new_post
to the end so it looks similar tohttp://myapp.heroku.com/new_post
and click Add -
Copy and highlight the Token from you newly created webhook that should appear in the Existing outgoing webhooks section below
-
Back on your Heroku dashboard, under Settings -> Reveal Config Vars, add
MATTERMOST_TOKEN
as the KEY and paste in the token you copied as the VALUE, and click Add
That's it! After waiting a minute for the Heroku process to restart you should be able to type /gif hello
into any channel and see a GIF from Gihpy's translate service.
The following procedure shows how to install this project on a Linux web server running Ubuntu 14.04. The following instructions work behind a firewall so long as the web server has access to your GitLab and Mattermost instances.
To install this project using a Linux-based web server, you will need:
- A Linux/Ubuntu 14.04 web server supporting Python 2.7 or a compatible version. Other compatible operating systems and Python versions should also work.
Here's how to start:
-
Set up this project to run on your web server
-
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 other essentials
sudo apt-get install python-pip python-dev build-essential
-
Clone this GitHub repo with
git clone https://github.com/mattermost/mattermost-integration-giphy.git
cd mattermost-integration-giphy
-
Install integration requirements
sudo pip install -r requirements.txt
-
Set up your Mattermost outgoing webhooks
-
Log in to your Mattermost account, and from three dot icon at the top of the left-hand menu go to Account Settings > Integrations > Outgoing Webhooks > Edit
-
Under Add a new outgoing webhook, leave the Channel unselected and enter
/gif
into Trigger Words -
Paste your Heroku Domain into Callback URLs, making sure to add
http://
to the beginning and/new_post
to the end so it looks similar tohttp://myapp.heroku.com/new_post
and click Add -
Copy and highlight the Token from you newly created webhook that should appear in the Existing outgoing webhooks section below
-
Run the server with the correct configuration
-
Back on SSH or your terminal, add the following lines to your
~/.bash_profile
export MATTERMOST_TOKEN=<your-token-here>
This is the token you copied in the last sectionexport PORT=<your-port-number>
The port number you want the integration to listen on (defaults to 5000)
-
Source your bash profile
source ~/.bash_profile
-
Run the server
python server.py
That's it! You should be able to type /gif hello
into any channel and see a GIF from Gihpy's translate service.
If you'd like to use this integration in a production envrionment, it is strongly recommended that you get a production Giphy API key from here. Once you have that you can configure the integration to use it:
- Go to your Heroku Dashboard and click on your app
- Go to Settings -> Config Variables and click Reveal Config Vars
- For KEY type in
GIPHY_API_KEY
and for VALUE paste in your Giphy API key, then click Add - Wait a minute for the Heroku process to restart
- Stop the process currently running the integration
- Add the following lines to your
~/.bash_profile
export GIPHY_API_KEY=<your-api-key-here>
With your Giphy API key
- Source your bash profile
source ~/.bash_profile
- Run the server again
python server.py