Added Slack post message tool. Tested, publishes message correctly but proxy needs to be setup

This commit is contained in:
Waleed Latif
2025-02-02 23:43:31 -08:00
parent a040708997
commit 0e99fdd311
5 changed files with 153 additions and 3 deletions
+5 -1
View File
@@ -12,6 +12,8 @@ import { functionExecuteTool as functionExecute } from './function/execute'
import { visionTool as crewAIVision } from './crewai/vision'
import { scrapeTool } from './firecrawl/scrape'
import { readUrlTool } from './jina/reader'
import { slackMessageTool } from './slack/message'
// Registry of all available tools
export const tools: Record<string, ToolConfig> = {
// AI Models
@@ -33,7 +35,9 @@ export const tools: Record<string, ToolConfig> = {
// Firecrawl Tools
'firecrawl.scrape': scrapeTool,
// Jina Tools
'jina.readurl': readUrlTool
'jina.readurl': readUrlTool,
// Slack Tools
'slack.message': slackMessageTool
}
// Get a tool by its ID
+71
View File
@@ -0,0 +1,71 @@
import { ToolConfig, ToolResponse } from '../types'
export interface SlackMessageParams {
apiKey: string
channel: string
text: string
}
export interface SlackMessageResponse extends ToolResponse {
output: {
ts: string
channel: string
}
}
export const slackMessageTool: ToolConfig<SlackMessageParams, SlackMessageResponse> = {
id: 'slack.message',
name: 'Slack Message',
description: 'Send a message to a Slack channel',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
description: 'Your Slack API token'
},
channel: {
type: 'string',
required: true,
description: 'Target Slack channel (e.g., #general)'
},
text: {
type: 'string',
required: true,
description: 'Message text to send'
}
},
request: {
url: 'https://slack.com/api/chat.postMessage',
method: 'POST',
headers: (params: SlackMessageParams) => ({
'Content-Type': 'application/json',
'Authorization': `Bearer ${params.apiKey}`
}),
body: (params: SlackMessageParams) => ({
channel: params.channel,
text: params.text
})
},
transformResponse: async (response: Response) => {
const data = await response.json()
if (!data.ok) {
throw new Error(data.error || 'Slack API error')
}
return {
success: true,
output: {
ts: data.ts,
channel: data.channel
}
}
},
transformError: (error: any) => {
const message = error.message || 'Slack message failed'
return message
}
}