Slack slash command modal windows instantly returns an error

149 views Asked by At

After submitting the modal, Slack instantly responds with {"ok":false,"error":"dispatch_failed"}.
My backend doesn't even receive the requests from Slack.
The app was working a few hours ago.

Is the problem on Slack's side?

from slack_bolt import App
import os
import logging

logging.basicConfig(level=logging.DEBUG)


app = App(
    token='token',
    signing_secret='signsecret'
)


@app.middleware
def log_request(logger, body, next):
    logger.debug(body)
    next()


@app.command("/test")
def handle_command(body, ack, client, logger):
    logger.info(body)
    ack()

    res = client.views_open(
        trigger_id=body["trigger_id"],
        view={
            "type": "modal",
            "callback_id": "test",
            "title": {"type": "plain_text", "text": "Gratitude Box"},
            "submit": {"type": "plain_text", "text": "Submit"},
            "close": {"type": "plain_text", "text": "Cancel"},
            "blocks": [
                {
                    "type": "input",
                    "block_id": "my_block",
                    "element": {"type": "plain_text_input", "action_id": "my_action"},
                    "label": {"type": "plain_text", "text": "Say something nice!"},
                }
            ],
        },
    )
    logger.info(res)
    print('command end')


@app.view("test")
def view_submission(ack, body, client, logger):
    ack()
    logger.info(body["view"]["state"]["values"])


if __name__ == "__main__":
    app.start(3000)

I checked the permissions of the Slack app and tried various solutions, but nothing worked.

1

There are 1 answers

5
hadar gendelman On

I recommend just calling client.views_open instead of saving it to a variable.