在仅通知机器人中处理消息反应的正确方法是什么?

What's the right way to handle message reactions in a notification only bot?

我在 Teams 中创建了一个单向通知机器人(仅限个人范围),我能够发送主动消息,但是,当有人对消息做出反应时,Teams 会显示已反应消息的通知到。我如何防止这种行为,只是默默地忽略消息反应。我希望因为它是一种单向通知机器人,所以可以选择禁用它,但显然没有。

我有一个 PHP REST API 端点,它被配置为机器人端点地址。 API 非常基本,只处理某些类型的请求,例如 installationUpdate。对于所有其他类型,它只发送带有空主体的 HTTP 200 响应。

当用户第一次在团队中安装应用程序时,我会存储 conversationId、tenantId 和 serviceUrl,然后在 Web 应用程序中发生某些事件时使用这些值发送通知(主动消息)。这些是通过 C# 控制台应用程序发送的。

当用户对消息做出反应时,我收到类型为 messageReaction 的请求,这是我无法弄清楚如何处理这个消息反应被忽略并且不会导致Teams 中的通知。

这就是我的 PHP REST API(机器人端点)的样子

function onBotRequest() {
    if ($_SERVER['REQUEST_METHOD'] != 'POST') {
        http_response_code(404);
        return;
    }
    $requestJson = json_decode(file_get_contents('php://input'), true);
    if ($requestJson['channelId'] != 'msteams') {
        http_response_code(404);
        return;
    } elseif ($requestJson['type'] == 'installationUpdate') {
        $serviceUrl = $requestJson["serviceUrl"];
        $conversationId = $requestJson["conversation"]["id"];
        $tenantId = $requestJson["conversation"]["tenantId"];

        if ($requestJson['action'] == 'add') {
            // App installed 
            // Store conversationId, tenantId, serviceUrl in db
        } elseif($requestJson['action'] == 'remove') {
            // App uninstalled
            // Remove conversationId, tenantId, serviceUrl from db
        }
    } elseif ($requestJson['type'] == 'messageReaction') {
        // What should be sent as the response here to ignore the message reaction?
    }
    header('Content-Type: application/json');
    http_response_code(200);
}

用于发送主动消息的代码

var credentials = new MicrosoftAppCredentials(appId, appPassword);
var connectorClient = new ConnectorClient(new Uri(serviceUrl), credentials);
var response = await connectorClient.Conversations.SendToConversationAsync(conversationId, activity);

我尝试发送不同的 HTTP 状态代码,如 400,但无论响应状态代码如何,通知仍然发生。我想我在响应正文中缺少一些必需的参数,但我找不到任何文档。

删除对 TeamsNotifyUser 的调用将阻止 Teams 在消息反应为 added/removed 时发送通知。