Slash command is /actions whenever I post this n channel ,a message with button should be posted. This is working correctly. But if I click the button to open dialog or submit the dialog again message with button gets posted. And I am not calling the post function during this too. I am calling it under route /actions Code:
@app.route("/actions", methods=["POST"])
def actions():
a = send_menu()
#prefix = "payload="
data = request.get_data(a)
Should Execute: Only when /actions slash command is used Should Not: When a button from below function is clicked Question: How can I achieve to stop this?
Below function that executes unnecessarily
def send_menu():
try:
response1 = standup_menu_block()
post_response = requests.post(webhook_url, json={
'channel': SLACK_CHANNEL,
'blocks': response1,
}
)
return post_response
***This function will post a message and a button
Steps: 1./actions is input in channel 2.triggers send_menu() and post a message with a button 3.Now if I click that button again the message is posted and dialog is opened
It is doing what you are telling it to do. See this shell session:
assigning
x()
toz
caused the function body (here the print statement) to execute.Same is happening with:
a = send_menu()
which is causing this block:
to get executed.