Skip to content

Commit 36d0fb4

Browse files
committed
feat: add numberCruncher conversation type to simplify slack setup
1 parent 17388aa commit 36d0fb4

2 files changed

Lines changed: 114 additions & 1 deletion

File tree

src/conversations/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import chatbot from './chatbot.js'
55
import eventHistorian from './eventHistorian.js'
66
import eventSetup from './eventSetup.js'
77
import vibesAnalyst from './vibesAnalyst.js'
8+
import numberCruncher from './numberCruncher.js'
89

910
// Internal conversation types are usable by the service but not exposed via the config API
1011
const internal: Record<string, ConversationType> = {
1112
chatbot,
1213
eventHistorian,
1314
eventSetup,
14-
vibesAnalyst
15+
vibesAnalyst,
16+
numberCruncher
1517
}
1618

1719
const defaultConversationTypes: Record<string, ConversationType> = {
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { ConversationType, Direction } from '../types/index.types.js'
2+
3+
const numberCruncher: ConversationType = {
4+
name: 'numberCruncher',
5+
label: 'Number Cruncher',
6+
description:
7+
'An admin bot that checks LLM API budget endpoints on a schedule and posts alerts to a Slack channel when spending exceeds configured thresholds',
8+
platforms: [{ name: 'slack', label: 'Slack' }],
9+
properties: [
10+
{
11+
name: 'slackChannel',
12+
label: 'Slack Channel ID',
13+
description: 'The ID of the Slack channel the bot posts to (starts with C- or G-)',
14+
required: true,
15+
type: 'string'
16+
},
17+
{
18+
name: 'slackWorkspace',
19+
label: 'Slack Workspace ID',
20+
description: 'The Slack workspace (team) ID (starts with T-)',
21+
required: true,
22+
type: 'string'
23+
},
24+
{
25+
name: 'slackBotToken',
26+
label: 'Slack Bot Token',
27+
description: 'The Bot User OAuth token for the Slack app (starts with xoxb-)',
28+
required: true,
29+
type: 'string'
30+
},
31+
{
32+
name: 'slackBotUserId',
33+
label: 'Slack Bot User ID',
34+
description: 'The user ID for the bot in Slack (starts with U-), used for routing incoming messages',
35+
required: false,
36+
type: 'string'
37+
},
38+
{
39+
name: 'slackSigningSecret',
40+
label: 'Slack App Signing Secret',
41+
description: 'The signing secret for the Slack app. Defaults to the system-wide signing secret if not provided.',
42+
required: false,
43+
type: 'string'
44+
},
45+
{
46+
name: 'slackAppKey',
47+
label: 'Slack App Key in Webhook',
48+
description: 'The app key for the Slack app, used as the last part of the webhook URL to route incoming messages.',
49+
required: false,
50+
type: 'string'
51+
},
52+
{
53+
name: 'botName',
54+
label: 'Bot Name',
55+
description: 'The name the bot uses when posting messages.',
56+
required: false,
57+
type: 'string',
58+
default: 'Number Cruncher'
59+
},
60+
{
61+
name: 'budgets',
62+
label: 'Budget Configurations (JSON)',
63+
description:
64+
'Array of budget configs. Each entry: { "label": "AWS Bedrock", "endpoint": "https://...", "apiKey": "...", "thresholdPercent": 80 }. Endpoints must return { "quota": { "limit": "250.0" }, "remaining_limit": "199.40" }.',
65+
required: true,
66+
type: 'array'
67+
},
68+
{
69+
name: 'checkInterval',
70+
label: 'Check Interval (seconds)',
71+
description: 'How often to check budgets, in seconds. Defaults to 86400 (24 hours).',
72+
required: false,
73+
type: 'string',
74+
default: '86400'
75+
}
76+
],
77+
// internal
78+
agents: [
79+
{
80+
name: 'numberCruncher',
81+
properties: [
82+
{ $ref: 'botName', as: 'agentConfig.botName' },
83+
{ $ref: 'budgets', as: 'agentConfig.budgets' },
84+
{ $ref: 'checkInterval', as: 'triggers.periodic.timerPeriod' },
85+
{ name: 'proactive', as: 'triggers.periodic.proactive', type: 'boolean', required: false, default: true }
86+
]
87+
}
88+
],
89+
channels: [{ name: 'numberCruncher' }],
90+
adapters: {
91+
slack: {
92+
type: 'slack',
93+
config: {
94+
channel: '{{{properties.slackChannel}}}',
95+
workspace: '{{{properties.slackWorkspace}}}',
96+
botToken: '{{{properties.slackBotToken}}}',
97+
botUserId: '{{{properties.slackBotUserId}}}',
98+
signingSecret: '{{{properties.slackSigningSecret}}}',
99+
appKey: '{{{properties.slackAppKey}}}'
100+
},
101+
chatChannels: [
102+
{
103+
name: 'numberCruncher',
104+
direction: Direction.BOTH
105+
}
106+
]
107+
}
108+
}
109+
}
110+
111+
export default numberCruncher

0 commit comments

Comments
 (0)