trigger run id being added during the slack agent task

This commit is contained in:
dal 2025-07-18 22:34:02 -06:00
parent a6c3474464
commit 0e46d64683
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
1 changed files with 24 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import { chats, db, eq, messages } from '@buster/database';
import { chats, db, eq, messages, updateMessage } from '@buster/database';
import {
SlackMessagingService,
addReaction,
@ -269,6 +269,29 @@ export const slackAgentTask: ReturnType<
runId: analystHandle.id,
});
// Update the message with the trigger run ID
if (!analystHandle.id) {
throw new Error('Trigger service returned invalid handle');
}
try {
await updateMessage(message.id, {
triggerRunId: analystHandle.id,
});
logger.log('Updated message with trigger run ID', {
messageId: message.id,
triggerRunId: analystHandle.id,
});
} catch (updateError) {
logger.error('Failed to update message with trigger run ID', {
messageId: message.id,
triggerRunId: analystHandle.id,
error: updateError instanceof Error ? updateError.message : 'Unknown error',
});
// Don't throw here - continue with the flow since the task is already triggered
}
// Step 6: Send initial Slack message immediately after triggering
const messagingService = new SlackMessagingService();
const busterUrl = process.env.BUSTER_URL || 'https://platform.buster.so';