mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
Added Slack post message tool. Tested, publishes message correctly but proxy needs to be setup
This commit is contained in:
+5
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user