feat: add removeAckAfterReply option for Discord, Slack, and Telegram
Add `messages.removeAckAfterReply` config option to automatically remove acknowledgment reactions after the bot sends a reply, reducing visual clutter while still providing immediate feedback. Platforms: Discord, Slack, Telegram Implementation: - Added removeAckAfterReply boolean field to MessagesConfig (default: false) - Track ack reaction state in all three platform handlers - Remove ack reaction after successful reply delivery - Graceful error handling with verbose logging Platform-specific: - Discord: uses removeReactionDiscord() - Slack: uses removeSlackReaction() - Telegram: uses setMessageReaction() with empty array Closes #627
This commit is contained in:
committed by
Peter Steinberger
parent
a29f5dda2e
commit
b5858c0148
@@ -59,7 +59,7 @@ import {
|
||||
} from "../routing/session-key.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { resolveSlackAccount } from "./accounts.js";
|
||||
import { reactSlackMessage } from "./actions.js";
|
||||
import { reactSlackMessage, removeSlackReaction } from "./actions.js";
|
||||
import { sendMessageSlack } from "./send.js";
|
||||
import { resolveSlackThreadTargets } from "./threading.js";
|
||||
import { resolveSlackAppToken, resolveSlackBotToken } from "./token.js";
|
||||
@@ -913,6 +913,7 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
|
||||
const rawBody = (message.text ?? "").trim() || media?.placeholder || "";
|
||||
if (!rawBody) return;
|
||||
const ackReaction = resolveAckReaction(cfg, route.agentId);
|
||||
const removeAckAfterReply = cfg.messages?.removeAckAfterReply ?? false;
|
||||
const shouldAckReaction = () => {
|
||||
if (!ackReaction) return false;
|
||||
if (ackReactionScope === "all") return true;
|
||||
@@ -927,6 +928,7 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
|
||||
}
|
||||
return false;
|
||||
};
|
||||
let didAddAckReaction = false;
|
||||
if (shouldAckReaction() && message.ts) {
|
||||
reactSlackMessage(message.channel, message.ts, ackReaction, {
|
||||
token: botToken,
|
||||
@@ -936,6 +938,7 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
|
||||
`slack react failed for channel ${message.channel}: ${String(err)}`,
|
||||
);
|
||||
});
|
||||
didAddAckReaction = true;
|
||||
}
|
||||
|
||||
const roomLabel = channelName ? `#${channelName}` : `#${message.channel}`;
|
||||
@@ -1157,6 +1160,16 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
|
||||
`slack: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${replyTarget}`,
|
||||
);
|
||||
}
|
||||
if (removeAckAfterReply && didAddAckReaction && ackReaction && message.ts) {
|
||||
removeSlackReaction(message.channel, message.ts, ackReaction, {
|
||||
token: botToken,
|
||||
client: app.client,
|
||||
}).catch((err) => {
|
||||
logVerbose(
|
||||
`slack: failed to remove ack reaction from ${message.channel}/${message.ts}: ${String(err)}`,
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
app.event(
|
||||
|
||||
Reference in New Issue
Block a user