Skip to content

Commit e197cb0

Browse files
committed
feat: add organization flow with slack message
1 parent 75e2019 commit e197cb0

7 files changed

+70
-5
lines changed

bun.lockb

440 Bytes
Binary file not shown.

example/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ These examples use OpenAI and FireCrawl APIs. You need to have the following env
1717

1818
- `bun run-organization-analysis.ts callstackincubator` - Analyzing an entire GitHub organization
1919
- `bun run-project-analysis.ts facebook/react-native` - Analyzing a single GitHub project
20+
- `bun run-organization-analysis-with-slack-message.ts callstackincubator` - Analyzing an entire GitHub organization and sending the report to Slack
21+
22+
> [!NOTE]
23+
> In order to run Slack example, you need to have `SLACK_API_TOKEN` environment variable set.
24+
> You will also need to have `SLACK_CHANNEL_ID` environment variable set.

example/agents.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { createAISDKTools } from '@agentic/ai-sdk'
22
import { FirecrawlClient } from '@agentic/firecrawl'
3+
import { SlackClient } from '@agentic/slack'
34
import { openai } from '@ai-sdk/openai'
45
import { agent } from 'flows-ai'
56

67
const firecrawl = new FirecrawlClient()
8+
const slack = new SlackClient()
79

810
export const githubAgent = agent({
911
model: openai('gpt-4o'),
@@ -25,6 +27,17 @@ export const npmAgent = agent({
2527
tools: createAISDKTools(firecrawl),
2628
})
2729

30+
export const slackAgent = agent({
31+
model: openai('gpt-4o'),
32+
system: `
33+
You are a Slack agent.
34+
You can send messages to Slack.
35+
Your messages should be concise and to the point.
36+
You always start with a friendly greeting in a casual, developer-friendly tone.
37+
`,
38+
tools: createAISDKTools(slack),
39+
})
40+
2841
export const analysisAgent = agent({
2942
model: openai('gpt-4o'),
3043
system: `

example/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@agentic/ai-sdk": "^7.2.0",
17-
"@agentic/firecrawl": "^7.2.0"
17+
"@agentic/firecrawl": "^7.2.0",
18+
"@agentic/slack": "^7.2.0"
1819
}
1920
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { execute } from 'flows-ai'
2+
import { sequence } from 'flows-ai/flows'
3+
4+
import { githubAgent, slackAgent } from './agents'
5+
import { githubProjectHealthAnalysisFlow } from './flows'
6+
7+
const projectName = process.argv[2]
8+
9+
if (!projectName) {
10+
throw new Error(
11+
'Please provide a project name, e.g.: bun run-project-analysis.ts facebook/react-native'
12+
)
13+
}
14+
15+
if (!process.env['SLACK_API_TOKEN']) {
16+
throw new Error('Please set SLACK_API_TOKEN environment variable.')
17+
}
18+
19+
const channelId = process.env['SLACK_CHANNEL_ID']
20+
if (!channelId) {
21+
throw new Error('Please set SLACK_CHANNEL_ID environment variable.')
22+
}
23+
24+
/**
25+
* In this example, we run already defined `githubProjectHealthAnalysisFlow`,
26+
* and then, we send the report to Slack.
27+
*/
28+
const response = await execute(
29+
sequence([
30+
githubProjectHealthAnalysisFlow,
31+
{
32+
agent: 'slackAgent',
33+
input: `Send the report to the channel "${channelId}"`,
34+
},
35+
]),
36+
{
37+
agents: {
38+
githubAgent,
39+
slackAgent,
40+
},
41+
input: projectName,
42+
onFlowStart: (flow) => {
43+
console.log('Executing', flow.agent.name)
44+
},
45+
}
46+
)
47+
48+
console.log(response)

example/run-organization-analysis.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import { organizationAnalysisFlow } from './flows'
66
const orgName = process.argv[2]
77

88
if (!orgName) {
9-
console.error(
9+
throw new Error(
1010
'Please provide an organization name, e.g.: bun run-organization-analysis.ts callstackincubator'
1111
)
12-
process.exit(1)
1312
}
1413

1514
/**

example/run-project-analysis.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import { githubProjectHealthAnalysisFlow } from './flows'
66
const projectName = process.argv[2]
77

88
if (!projectName) {
9-
console.error(
9+
throw new Error(
1010
'Please provide a project name, e.g.: bun run-project-analysis.ts facebook/react-native'
1111
)
12-
process.exit(1)
1312
}
1413

1514
/**

0 commit comments

Comments
 (0)