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 python-setuptools"
-
Clone this GitHub repo with
git clone /~https://github.com/numberly/mattermost-integration-giphy.git
cd mattermost-integration-giphy
-
Install integration requirements
sudo python setup.py install
-
Set up your Mattermost slash command
-
Log in to your Mattermost account. Click the three dot menu at the top of the left-hand side and go to Integrations > Slash Commands
-
Under Add a new command, enter
gif
into Command Trigger Word -
Paste your Web Server domain into Callback URLs, making sure to add
http://
to the beginning and/new_post
to the end so it looks similar tohttp://<your-web-server-domain>:<MATTERMOST_GIPHY_PORT>/new_post
and click Add -
Select
POST
method -
(optional) Choose a username and icon url (more details here)
-
(optional) Check the autocomplete checkbox, add
[KEYWORD]
as the hint,Returns a GIF from Giphy based on the keyword
as the description andGet a GIF from Giphy
as the descriptive label -
Copy the Token from your newly created slash command that appears under the Existing commands section
-
Run the server with the correct configuration
-
Back on SSH or your terminal, add the following lines to your
~/.profile
export MATTERMOST_GIPHY_TOKEN=<your-token-here>
This is the token you copied in the last section (you can specify multiple tokens which are separated by a colon)export MATTERMOST_GIPHY_HOST=<your-host>
orexport HOST=<your-host>
The host you want the integration (defaults to 0.0.0.0)export MATTERMOST_GIPHY_PORT=<your-port-number>
orexport PORT=<you-port-number>
The port number you want the integration to listen on (defaults to 5000)
-
Source your bash profile
source ~/.profile
-
Run the server
python run.py
That's it! You should be able to type gif: hello
or /gif hello
into any channel and see a GIF from Giphy'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:
- Stop the process currently running the integration
- Add the following lines to your
~/.profile
or~/.bashrc
export GIPHY_API_KEY=<your-api-key-here>
With your Giphy API key
- Source your bash profile
source ~/.profile
orsource ~/.bashrc
- Run the server again
python run.py