python 松弛斜线命令模态窗口立即返回错误

jm81lzqq  于 2023-10-14  发布在  Python
关注(0)|答案(1)|浏览(121)

提交模型后,Slack立即响应{"ok":false,"error":"dispatch_failed"}
我的后台甚至没有收到Slack的请求。
应用程序几小时前还在工作。
问题出在Slack那边吗

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)

我检查了Slack应用程序的权限,并尝试了各种解决方案,但都没有效果。

cx6n0qe3

cx6n0qe31#

我建议只调用client.views_open,而不是将其保存到变量中。

相关问题