slackapi / bolt-python

A framework to build Slack apps using Python
https://slack.dev/bolt-python/
MIT License
1.05k stars 243 forks source link

action not triggered when selecting an element in mrkdwn #634

Closed knobutan closed 2 years ago

knobutan commented 2 years ago

Triggering @app.action stopped working. It was working for the last year, however recently actions are not triggered by button click or selection under mrkdwn. I have updated both bolt and sdk to the latest but the symptom did not change. I planted logger in those @app.action, but I get the impression it is not even called.

Reproducible in:

The slack_bolt version

$ pip freeze | grep slack slack-bolt==1.13.0 slack-sdk==3.15.2

Python runtime version

Python 3.9.1

OS info

MacOS Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64

Steps to reproduce:

test2.py.zip

My app is a simple text fetcher using a slash command.

  1. User: call the slash command
  2. Bolt: It prompts an input using a dropdown
  3. User: select a value from the dropdown
  4. Bolt: retrieve the value and fetch plain texts, then prompt back to the user (on Slack)

Expected result:

@app.action("selectci") is called when selecting a value in the dropdown. By clicking GET, it kick off @app.action("button_click") and fetches text

Actual result:

It claims it cannot handle the payload. It was working fine until last week.

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

seratch commented 2 years ago

Hi @knobutan, thanks for asking the question!

I've checked your code. It seem that the line respond(body) throws an exception. Perhaps, you might accidentally have added the line. This code never works even with old versions of bolt-python. Your app should work if you remove the line (I've confirmed it works).

# Action when you click GET button
@app.action("button_click")
def action_button_click(body, ack, respond):
    # Acknowledge the action
    ack()
    respond(body) # This line never works

Since this is not an issue caused by either bolt-python or the Slack Platform, let us close this issue now. If you have any follow up questions, feel free to write in.

knobutan commented 2 years ago

@seratch Thank you so much for your update and pointing it out. I forgot to remove it after debugging this problem. Is there a forum or QA page where I can post dev related questions?

I reviewed docs again but am still having the same problem with my code. Specifically at calling action from blocks. If you can clarify my understanding about the flow, that would be great. This is what I intended

  1. Slack: Call the slack command
  2. @app.command("/mgb") gets triggered and respond what's in blocks to slack
  3. There are 2 actions in the block:
    • (type:static_select) triggered when selecting an options in elements
    • (type:button) triggered by button click

Problems I am having are ack() seems not triggered in the first action, and button click action not returning neither ack() nor respond() as if actions are not being triggered at all.