Slack API - 如何在 im 消息事件中发送短时消息(通道 ID 不是有效通道)?

问题描述 投票:0回答:0

我有一个App,它订阅于 事件,而当两个用户之间的直接消息触发时,我得到了以下的json发送至我的回调URI(每个标识符都被编辑成匿名): 事件,当被两个用户之间的直接消息触发时,我得到了以下发送到我的回调URI的json(每个标识符都被编辑为匿名)。

{
    "token": "K5ROtL7xMS1Fv8zo8V33IAx8",
    "team_id": "T32SZGR2P",
    "api_app_id": "AP50R2741",
    "event": {
        "client_msg_id": "ca24d63d-c022-4629-a618-9d9a2ee0097c",
        "type": "message",
        "text": "test message\n<@ULAJP1B25>",
        "user": "U232XAB7X",
        "ts": "1592504332.001900",
        "team": "T32SZGR2P",
        "blocks": [
            {
                "type": "rich_text",
                "block_id": "T2Fe6",
                "elements": [
                    {
                        "type": "rich_text_section",
                        "elements": [
                            {
                                "type": "text",
                                "text": "test message\n"
                            },
                            {
                                "type": "user",
                                "user_id": "ULAJP1B25"
                            }
                        ]
                    }
                ]
            }
        ],
        "channel": "DLAJ2HDNU",
        "event_ts": "1592504332.001900",
        "channel_type": "im"
    },
    "type": "event_callback",
    "event_id": "Ev211G7DRFK7",
    "event_time": 1592504332,
    "authed_users": [
        "U232XAB7X"
    ]
}

我这里有两个问题

  1. 我似乎无法发送 短信 在此主题下,作为给定的 channel (DLAJ2HDNU)是无效的,它给出了 channel_not_found. 我试图收集更多的信息 关于谈话通过 conversations.info 但它也给 channel_not_found;
  2. 我无法确定收件人的用户ID或用户名,因为我只有一个。user 属性,定义了谁发送了消息。

所以我的问题是:我如何可能实现1和或2?


另外,对于上下文,我的目标是监听 @mentions 和直接消息,以便检查所提到的用户接收者是否为afk,并向提到他们的人发送一条消息,说他们可能需要一段时间才能回复。

slack slack-api
© www.soinside.com 2019 - 2024. All rights reserved.