Giphy integration?


Anyone want to share with me the secret to getting giphy integrated with v1.2.1? :slight_smile:

I followed the recipe but I get an error in the python when the request is handled:

File “/usr/lib/python2.7/”, line 295, in _handle_request_noblock
self.process_request(request, client_address)
File “/usr/lib/python2.7/”, line 321, in process_request
self.finish_request(request, client_address)
File “/usr/lib/python2.7/”, line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File “/usr/lib/python2.7/”, line 649, in init
File “/usr/local/lib/python2.7/dist-packages/werkzeug/”, line 217, in handle
rv = BaseHTTPRequestHandler.handle(self)
File “/usr/lib/python2.7/”, line 340, in handle
File “/usr/local/lib/python2.7/dist-packages/werkzeug/”, line 251, in handle_one_request
elif self.parse_request():
File “/usr/lib/python2.7/”, line 253, in parse_request
self.send_error(400, “Bad request version (%r)” % version)
File “/usr/lib/python2.7/”, line 364, in send_error
self.log_error(“code %d, message %s”, code, message)
File “/usr/local/lib/python2.7/dist-packages/werkzeug/”, line 273, in log_error
self.log(‘error’, *args)
File “/usr/local/lib/python2.7/dist-packages/werkzeug/”, line 279, in log
_log(type, ‘%s - - [%s] %s\n’ % (self.address_string(),
File “/usr/local/lib/python2.7/dist-packages/werkzeug/”, line 267, in address_string
return self.environ[‘REMOTE_ADDR’]
AttributeError: ‘WSGIRequestHandler’ object has no attribute ‘environ’

Hi @booksprint,

Hmmm, that’s not an issue I’ve seen before. Can you provide me some more details on your setup? For example what OS you’re running it on, and anything else you might think is relevant.

Also, does hitting the root handler work? Basically hitting should return “OK” as the body of the HTTP response

I found the “production” instructions to be rather unrefined regarding the web server based install.

Maybe this can help:

First make sure you have set up the variables via the .bash_profile. Then make sure in the outgoing hook configuration for your Mattermost install to give the precise address of the python based webserver.
For me this is: http://localhost:8066/new_post
as I installed it on the same host as Mattermost and changed the port to one above Mattermost. Finally paste the token from Mattermost to the .bash_profile and source it again.
After starting the server the gif: command should work.


I did use the host:port in the webhook and python server config. Its when I hit that endpoint that I got the errors that you see. The errors were generated when hitting it through a browser or triggering by using the reserved word in the channel.

My set up is Ubuntu 14.04. Python 2.7.6. Apache.

I also set the env vars in bash (and sourced it) and set them in the python script manually as well.

I am using an SSL config for apache. If I hit https://host:port/new_post the above error is produced.

Thanks for your help.

If it’s failing on both the https://host:port/new_post and the https://host:port/ endpoints then it looks like some sort of issue with Flask or Python requests.

It might be related to your use of SSL but if Apache’s handling it, then I’m not too sure what would be causing the issue. Are you able to temporarily disable SSL and test out the integration, for troubleshooting purposes?

I also checked the requirements.txt to see if it has the latest versions of Flask and Python Requests. Flask is latest at 0.10.1 but Requests is at 2.2.1 when the latest is 2.8.1. So you can try upgrading Requests to the latest version with pip install requests==2.8.1.


Thanks for this - I have the same isues after trying requests 2.8.1

Interested to know if anyone else was able to get Giphy integration to work in Ubuntu.

Hi, we configured everything exactly like you did, but we receive - - [02/Dec/2015 18:02:09] "POST / HTTP/1.1" 405 -

in the log.

Outgoing Hook:

URLs: http://localhost:8066
Trigger Words: gif:
Token: yndo4k4bify8uqsr7tp4puki9A


export MATTERMOST_TOKEN=yndo4k4bify8uqsr7tp4puki9A
export PORT=8066

Some idea?

http 405: method not allowed

Hi ! I have this exact same issue. 405 not allowed. Any idea, someone?