I have created a slash command on Slack
and it works fine if I execute it on any channel. I can't figure out if there is a permission through which any user
can post on any channel
using the slash command.
Is there a way where any user can post anywhere in the channel ?
Basically I want to pass *
to Post to
option so that they are not restricted to a private slackbot group only.
EDITED:
Your app does not need any additional permissions for replying to the slash command of a user in any channel.
There are two ways on how to post into a channel as response to a slash command executed by a user:
Directly respond to the slash request within 3 seconds. e.g. if you are using Flask you are responding to a request by calling return in your @route function
Send a request to the request_url
which you find the slash command request within 30 seconds
The "Post To" property you are showing has nothing to do with slash commands. It's for incoming-webhooks, which is used by non Slack apps to send message to Slack.
Here is an example for both types of response using Flask:
from flask import Flask, json, request
import requests
app = Flask(__name__) #create the Flask app
@app.route('/slash', methods=['POST'])
def slash_response_direct():
"""Direct response"""
message = {
"text": "Hi there"
}
return json.jsonify(message)
#@app.route('/slash', methods=['POST'])
def slash_response_indirect():
"""responding to slash command via response URL"""
response_url = request.form["response_url"]
message = {
"text": "Hi"
}
res = requests.post(response_url, json=message)
return ""
if __name__ == '__main__':
app.run(debug=True, port=8000) #run app in debug mode on port 8000