3

I built a Slack bot and tried to make my bot interact with another bot in the a channel, but it seems not working.

For example, I want to use the voting function of Polly (a Slack bot).

Regular users like me send /polly "Which is better?" "Tacos" "Pizza" message and Polly will create a Slack poll in a channel. But when I made my bot send the same message in the same channel (I use python-slackclient and chat.postMessage method), the message just like a simple text, in other words, it didn't trigger Polly.

So, in a channel, how can a Slack bot interact with another bot and trigger some functions of it? Did anybody ever do something like this?


update

https://github.com/ErikKalkoken/slackApiDoc/blob/master/chat.command.md

I tried this method but got another problem...

The error message is

{'error': 'missing_scope',
 'needed': 'post',
 'ok': False,
 'provided': 'identify,bot:basic'}

The Oauth token requires "post" scope, but official documents show that "post" scope is deprecated. How do I make my token have "post" scope?

Wen
  • 47
  • 5

2 Answers2

1

I have tried to make two bots interact and didn't find it to work. Slack somehow recognizes the source of the message and if the message is sent by a bot or an app, it fails to respond to it. I have even tried to post the message as a user through the slack API but did not get it to work. However, Bots can use the chat.command method to invoke a slash command. Unofficial documentation can be found here:

https://github.com/ErikKalkoken/slackApiDoc/blob/master/chat.command.md

Akshay Apte
  • 1,539
  • 9
  • 24
  • Thank you so much!! – Wen Aug 09 '17 at 06:37
  • OK:) but I got a error while I used slack bot token as the token argument. The error message is { 'error': 'missing_scope', 'needed': 'post', 'ok': False, 'provided': 'identify,bot:basic'} The token requires scope "post", how can I add that to my Oauth scope... ? – Wen Aug 09 '17 at 06:54
  • you need to add access scope to the bot user. Go to the slack API page and add the required permissions for your bot. http://api.slack.com into My Apps – Akshay Apte Aug 09 '17 at 09:16
1

You are correct that the undocumented chat.command requires the post scope to work, which is not available in the standard OAuth process (e.g. you can not choose it as scope on the Slack app config site.)

The only currently working solution that I know of it to use a legacy token.

See also this answer.

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
  • 1
    thanks for your answer! by the way, the same question on your GitHub is also asked by me:) – Wen Aug 09 '17 at 09:17
  • yeah I saw that and also answered your question on my github :-) And as I said there I have also send a request to the Slack team asking kindly to integrate this method in the standard Oauth process.Lets see what they say... – Erik Kalkoken Aug 09 '17 at 09:28
  • @ErikKalkoken, Have you received any update from Slack team on this? – Avin Apr 21 '20 at 06:04
  • Support said the following: "I'll make sure to pass the suggestion to our product team and let them know about the increasing demand" Have not heard anything else back. – Erik Kalkoken Apr 21 '20 at 11:01