How can I make it so that slack bots can use Giphy

2019-04-04 06:29发布

For some reason, the existing Giphy app for slack does not allow bots to call a GIF from giphy.com

If I type "/Giphy sad", the Giphy app will automatically load a sad GIF of somekind from Giphy.com

But if my slackbot does it, or my hubot, or my twitterbot, or any bot that I create, even if the text is identical, it won't work. I'm assuming this is because giphy intentionally excluded bots from being able to call the command? Or is it that bots can't call commands in general?

So in addition to this general question, my specific coding question is: what would be the best way to make it so that a slack app or a bot can call a GIF from Giphy?


additional info you may not need: -I'm creating this so that we can pull "moods" off of Twitter account into a slack channel and have a bunch of GIFs show up in that slack channel that represent the mood of the tweets. -I've been using Node-Red to do some of this -I've tried using the built in twitter app for slack, no dice

2条回答
闹够了就滚
2楼-- · 2019-04-04 07:08

The official API does not support invoking other slash commands, but there is an unofficial API method that does it:chat.command.

Note that this will only work in situations where you have full control over a Slack workspace and can use legacy tokens.

查看更多
Ridiculous、
3楼-- · 2019-04-04 07:09

I'm assuming this is because giphy intentionally excluded bots from being able to call the command? Or is it that bots can't call commands in general?

Bot users cannot invoke Slash commands. This is a restriction by Slack and not Giphy or any other integration. :(

So if you want to get gifs from Giphy, you will have to implement that yourself using the Giphy API. Thankfully, the Giphy API is super easy to use. Giphy API

In a recent hackathon project I built this for Slack, which you may find useful. It get's a random gif that is tagged "fail" from Giphy and then posts it as a message in Slack.

查看更多
登录 后发表回答