diff --git a/README.md b/README.md index 24ea37f..26d5584 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ You can create chat workflow automations using **two methods**: - Admins must configure settings in the UI: - Navigate to: `Marketplace → Private Apps → AI Chat Workflows Automation → Settings` - Only users with admin access can configure the app’s LLM settings. + - **Confidence Threshold**: Adjust minimum confidence (0-100) for trigger validation. Lower (40-60) = creative/flexible, Higher (85-95) = strict/precise. Default: 75. ### 2. ⚙️ Use Slash Command `/chat-automation-create` - Opens a UI modal where you can fill in all the necessary details to create a workflow. diff --git a/handler/PostMessageSentHandler.ts b/handler/PostMessageSentHandler.ts index dfcdf02..a9f0cf0 100644 --- a/handler/PostMessageSentHandler.ts +++ b/handler/PostMessageSentHandler.ts @@ -23,6 +23,7 @@ import { } from "../utils/Messages"; import { ActionTypeEnum } from "../definitions/ActionTypeEnum"; import { createTextCompletion } from "../utils/AIProvider"; +import { SettingEnum } from "../settings/settings"; interface CheckConditionResponse { condition_met: boolean; @@ -66,6 +67,16 @@ export class PostMessageSentHandler implements IPostMessageSent { await findTriggerResponsesByNullCombinations(read); const allResponses = [...triggerResponses, ...triggerResponses2]; + const confidenceThresholdSetting = (await read + .getEnvironmentReader() + .getSettings() + .getValueById(SettingEnum.ID_CONFIDENCE_THRESHOLD)) as number; + + const confidenceThreshold = Math.max( + 0, + Math.min(100, confidenceThresholdSetting || 75) + ); + for (const [index, response] of allResponses.entries()) { // UI Approach if (!response.data.usedLLM) { @@ -141,7 +152,7 @@ export class PostMessageSentHandler implements IPostMessageSent { : checkConditionPromptByLLM; if (!checkConditionResponse.condition_met) continue; - if (checkConditionResponse.confidence < 75) continue; + if (checkConditionResponse.confidence < confidenceThreshold) continue; if ( response.data.response.action === diff --git a/settings/settings.ts b/settings/settings.ts index be7401f..e59e6f0 100644 --- a/settings/settings.ts +++ b/settings/settings.ts @@ -11,6 +11,7 @@ export enum SettingEnum { ID_RC_MODEL = `rc-model`, ID_RC_AUTH_TOKEN = `rc-auth-token`, ID_RC_USER_ID = `rc-user-id`, + ID_CONFIDENCE_THRESHOLD = `confidence-threshold`, KEY_GROQ = `groq`, KEY_GEMINI = `gemini`, KEY_RC = `rocketchat`, @@ -91,4 +92,14 @@ export const settings: ISetting[] = [ public: false, packageValue: "", }, + { + id: SettingEnum.ID_CONFIDENCE_THRESHOLD, + i18nLabel: "Minimum Confidence Threshold (0-100)", + i18nDescription: "Lower = creative/flexible (less accurate), Higher = strict/precise (more accurate). Default: 75", + i18nPlaceholder: "75", + type: SettingType.NUMBER, + required: true, + public: true, + packageValue: 75, + }, ];