松弛的应用程序不响应直接消息

slack app not responding to direct message

我想让我的应用程序回复直接消息,但它没有发布回复,而且我在文档中找不到任何地方如何做到这一点。这是我试过的:

@app.event("app_mention")
def event_test(body, say, logger):
    logger.info(body)
    say("What's up?")

@app.event('message')
def respond_message(message, say):
    say("Hello there.")

@app.message('knock knock')
def respond_message(message, say):
    say("Hello there.")

它响应@app 提及,但不响应直接消息...

您能否确认您的应用具有侦听 'message' 事件所需的作用域?

'message' 事件所需的范围:

    channels:history
    groups:history
    im:history
    mpim:history

详情如下:

https://api.slack.com/events/message

正在更新我的答案以备将来使用:
https://api.slack.com/apis/connections/events-api

捕获事件需要:

  1. 为事件分配所需的范围
  2. 订阅活动

我想通了 ~ 除了添加所需的范围外,您还必须在“应用程序配置”->“事件订阅”选项卡中切换设置...文档可能需要一些改进 tbh。