How do you invoke the / poll command using the Slack API?

My slack channel supports the /poll command from the Simple Poll app. How do you call this command using the Slack API?

Using the python slack (er) API module :

 from slacker import Slacker # Using what now called a "legacy token" slack = Slacker('my-token') slack.chat.post_message( '#test', '/poll "Do you prefer cats or dogs?" "Cats" "Dogs"', as_user=False, username="Poll Bot", icon_emoji=':question:', parse='full') 

The message is simply displayed in the #test channel as plain text, and is not converted to a survey.

I tried using <!poll> instead of /poll in the message, as a kind of implicit message formatting alert , but the same result.

Note. This question is a bit outdated, and after the review, I found out that my code uses what is now called the legacy token , which does not allow me to specify any OAuth scopes . An outdated token already has the permissions necessary for this case.

+4
python slack-api slack
source share
2 answers

I stumbled on the same issue, so I worked a bit on coding, and here's a working example:

https://github.com/dazlious/slack-cmd-trigger

You can activate any channel with your api token using the command.

+1
source share

All Articles