Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute slash command as slack bot

Tags:

I'm writing a simple slack bot which should execute other slack commands upon being called. Everything is up and running, however the slack commands this bot issues don't seem to be executed.

For instance my bot posts /giphy kitten every hour and the message appears just like that in the channel (so the sending side seems to work), but the slash command itself isn't executed. If I post the same command into the same channel myself it works as expected. Are bots not allowed to execute slash commands?

like image 784
ubuntudroid Avatar asked Oct 03 '16 10:10

ubuntudroid


2 Answers

Bots can use the undocumented API method chat.command to invoke slash commands.

See here for an unofficial documentation page of this API method.

This question was also answered here.

like image 106
Erik Kalkoken Avatar answered Nov 09 '22 06:11

Erik Kalkoken


The command chat.command needs the permission scope post, which only legacy tokens have and which is not available for Slack apps.

I just asked the Slack customer support if sending slash commands programmatically is still possible and received the following reply:

I'm afraid not. Slash commands can only be triggered by human-sent messages from the client. Apologies.

like image 34
b.geisb Avatar answered Nov 09 '22 05:11

b.geisb