My slack channel supports the /poll
command from the Simple Poll app. How do you invoke this command using the Slack API?
Using the python slack(er) API module:
from slacker import Slacker
# Using what's 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 just shows up in the #test channel as plain text, not converted to a poll.
I tried using <!poll>
instead of /poll
in the message, as sort of implied in the message formatting documenation, but same result.
Note: This question is a bit old now, and upon revisiting I have found out that my code is using what's now called a legacy token, which doesn't allow specifying any OAuth permission scopes. The legacy token already has the permissions it needs for this case.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…