@graphai/slack_agent 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -0
- package/lib/slack_agent.js +17 -3
- package/package.json +7 -7
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
# @graphai/slack_agent for GraphAI
|
|
3
|
+
|
|
4
|
+
Slack message agents for GraphAI.
|
|
5
|
+
|
|
6
|
+
### Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
yarn add @graphai/slack_agent
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## setup
|
|
13
|
+
|
|
14
|
+
### Acquiring a Slack Token for Posting Messages
|
|
15
|
+
|
|
16
|
+
1. **Obtain a Slack Token:**
|
|
17
|
+
- Go to the [Slack API Developer Portal](https://api.slack.com/apps) and select or create your app.
|
|
18
|
+
- Follow the steps in the **Permissions** or **Authentication** section to generate the necessary token for your use case (e.g., user token, bot token).
|
|
19
|
+
|
|
20
|
+
2. **Set the Token as an Environment Variable:**
|
|
21
|
+
- Export the token as an environment variable by running the following command in your terminal:
|
|
22
|
+
```bash
|
|
23
|
+
export SLACK_TOKEN=your-slack-token-here
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
3. **Using a Bot Token:**
|
|
27
|
+
- If you are using a bot token, ensure that the bot is added to the channel where you intend to post messages. This can be done from the Slack app by inviting the bot to the relevant channel.
|
|
28
|
+
|
|
29
|
+
### Usage
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { GraphAI } from "graphai";
|
|
33
|
+
import { slackAgent } from "@graphai/slack_agent";
|
|
34
|
+
|
|
35
|
+
const agents = { slackAgent };
|
|
36
|
+
|
|
37
|
+
const graph = new GraphAI(graph_data, agents);
|
|
38
|
+
const result = await graph.run();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Agents description
|
|
42
|
+
- slackAgent - Slack Agent
|
|
43
|
+
|
|
44
|
+
### Input/Output/Params Schema & samples
|
|
45
|
+
- [slackAgent](https://github.com/receptron/graphai-agents/blob/main/docs/agentDocs/messaging/slackAgent.md)
|
|
46
|
+
|
|
47
|
+
### Input/Params example
|
|
48
|
+
- slackAgent
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
{
|
|
52
|
+
"inputs": {
|
|
53
|
+
"message": [
|
|
54
|
+
"Hello amateraru from GraphAI Slack agent!"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"params": {
|
|
58
|
+
"post_channel": "#p_bootcamp_e_raycast_jp_amaterasu_dev"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
package/lib/slack_agent.js
CHANGED
|
@@ -5,6 +5,12 @@ const web_api_1 = require("@slack/web-api");
|
|
|
5
5
|
const slackAgent = async ({ params, namedInputs }) => {
|
|
6
6
|
const token = process.env.SLACK_TOKEN ?? namedInputs.slack_token;
|
|
7
7
|
const channel = params.post_channel;
|
|
8
|
+
if (!token) {
|
|
9
|
+
throw new Error("SLACK_TOKEN is not set in environment variables.");
|
|
10
|
+
}
|
|
11
|
+
if (!channel) {
|
|
12
|
+
throw new Error("Slacl post_channel is not set in params.");
|
|
13
|
+
}
|
|
8
14
|
const message = namedInputs.message ?? params.message;
|
|
9
15
|
const text = Array.isArray(message) ? message.join("\n") : message;
|
|
10
16
|
const web = new web_api_1.WebClient(token);
|
|
@@ -19,11 +25,19 @@ const slackAgentInfo = {
|
|
|
19
25
|
name: "slackAgent",
|
|
20
26
|
agent: exports.slackAgent,
|
|
21
27
|
mock: exports.slackAgent,
|
|
22
|
-
samples: [
|
|
28
|
+
samples: [
|
|
29
|
+
{
|
|
30
|
+
inputs: { message: ["Hello amateraru from GraphAI Slack agent!"] },
|
|
31
|
+
params: {
|
|
32
|
+
post_channel: "#p_bootcamp_e_raycast_jp_amaterasu_dev",
|
|
33
|
+
},
|
|
34
|
+
result: {},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
23
37
|
description: "Slack Agent",
|
|
24
|
-
category: ["
|
|
38
|
+
category: ["net"],
|
|
25
39
|
author: "Receptron team",
|
|
26
|
-
repository: "https://github.com/receptron/graphai",
|
|
40
|
+
repository: "https://github.com/receptron/graphai-agents/tree/main/net/slack_agent",
|
|
27
41
|
license: "MIT",
|
|
28
42
|
};
|
|
29
43
|
exports.default = slackAgentInfo;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphai/slack_agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Slack message agents for GraphAI.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -10,24 +10,24 @@
|
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"eslint": "eslint src --fix",
|
|
12
12
|
"format": "prettier --write '{src,tests}/**/*.ts'",
|
|
13
|
+
"doc": "npx agentdoc",
|
|
13
14
|
"test_run": "node --test --require ts-node/register ./tests/run_*.ts",
|
|
15
|
+
"test_graph": "node --test --require ts-node/register ./tests/run_graph.ts",
|
|
14
16
|
"test": "node --test --require ts-node/register ./tests/test_*.ts",
|
|
15
17
|
"ci": "yarn run format && yarn run eslint && yarn run test && yarn run build"
|
|
16
18
|
},
|
|
17
19
|
"repository": {
|
|
18
20
|
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/
|
|
21
|
+
"url": "git+https://github.com/receptron/graphai-agents.git"
|
|
20
22
|
},
|
|
21
23
|
"author": "Isamu Arimoto",
|
|
22
24
|
"license": "MIT",
|
|
23
25
|
"bugs": {
|
|
24
|
-
"url": "https://github.com/
|
|
26
|
+
"url": "https://github.com/receptron/graphai-agents/issues"
|
|
25
27
|
},
|
|
26
|
-
"homepage": "https://github.com/
|
|
28
|
+
"homepage": "https://github.com/receptron/graphai-agents#readme",
|
|
27
29
|
"devDependencies": {},
|
|
28
30
|
"dependencies": {
|
|
29
|
-
"@slack/web-api": "^7.3.4"
|
|
30
|
-
"dotenv": "^16.4.5",
|
|
31
|
-
"graphai": "^0.5.7"
|
|
31
|
+
"@slack/web-api": "^7.3.4"
|
|
32
32
|
}
|
|
33
33
|
}
|