Skip to content

Commit ba9760a

Browse files
authored
Enhance: Add support to pull slack bot token (#451)
Signed-off-by: Daishan Peng <[email protected]>
1 parent 0637bb6 commit ba9760a

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

oauth2/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type oauthInfo struct {
2929
Integration string `json:"integration"`
3030
Token string `json:"token"`
3131
Scope []string `json:"scope"`
32+
UserScope []string `json:"userScope"`
3233
OptionalScope []string `json:"optionalScope"`
3334
}
3435

@@ -227,6 +228,9 @@ func mainErr() (err error) {
227228
if len(in.OAuthInfo.Scope) != 0 {
228229
q.Set("scope", strings.Join(in.OAuthInfo.Scope, " "))
229230
}
231+
if len(in.OAuthInfo.UserScope) != 0 {
232+
q.Set("user_scope", strings.Join(in.OAuthInfo.UserScope, " "))
233+
}
230234
if len(in.OAuthInfo.OptionalScope) != 0 {
231235
q.Set("optional_scope", strings.Join(in.OAuthInfo.OptionalScope, " "))
232236
}

slack/credential/bot.gpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Name: Slack OAuth Bot Credential
2+
Share Credential: slack-bot-cred as slack.bot.write
3+
Type: credential
4+
5+
---
6+
Name: slack-bot-cred
7+
Tools: ../../oauth2
8+
9+
#!sys.call ../../oauth2
10+
11+
{
12+
"oauthInfo": {
13+
"integration": "slack",
14+
"token": "SLACK_TOKEN",
15+
"scope": [
16+
"chat:write",
17+
"im:write",
18+
"users:read"
19+
]
20+
},
21+
"promptInfo": {
22+
"fields" : [
23+
{
24+
"name": "Slack API Key",
25+
"description": "A Bot token for your Slack account.",
26+
"sensitive": true,
27+
"env": "SLACK_TOKEN"
28+
}
29+
],
30+
"message": "Enter your Slack User or Bot OAuth Token."
31+
}
32+
}

slack/credential/tool.gpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Tools: ../../oauth2
1212
"oauthInfo": {
1313
"integration": "slack",
1414
"token": "SLACK_TOKEN",
15-
"scope": [
15+
"userScope": [
1616
"channels:history",
1717
"groups:history",
1818
"im:history",
@@ -34,7 +34,7 @@ Tools: ../../oauth2
3434
"fields" : [
3535
{
3636
"name": "Slack API Key",
37-
"description": "An OAuth User or Bot token for your GitHub account.",
37+
"description": "An OAuth User or Bot token for your Slack account.",
3838
"sensitive": true,
3939
"env": "SLACK_TOKEN"
4040
}

slack/tool.gpt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Name: Slack
33
Description: Tools for interacting with Slack
44
Metadata: bundle: true
5-
Share Tools: List Channels, Search Channels, Get Channel History, Get Channel History by Time, Get Thread History From Link, Get Thread History, Search Messages, Send Message, Send Message in Thread, List Users, Search Users, Send DM, Send DM in Thread, Get Message Link, Get DM History, Get DM Thread History
5+
Share Tools: List Channels, Search Channels, Get Channel History, Get Channel History by Time, Get Thread History From Link, Get Thread History, Search Messages, Send Message, Send Message in Thread, List Users, Search Users, Send DM, Send DM in Thread, Get Message Link, Get DM History, Get DM Thread History, Send Direct Message As Bot
66

77
---
88
Name: List Channels
@@ -184,6 +184,16 @@ Param: limit: the number of messages to return
184184

185185
#!/usr/bin/env node ${GPTSCRIPT_TOOL_DIR}/index.js getDMThreadHistory
186186

187+
---
188+
Name: Send Direct Message As Bot
189+
Description: Send a direct message as a bot or an app in the Slack workspace
190+
Share Context: Slack Context
191+
Credential: ./credential/bot.gpt
192+
Share Tools: List Users, Search Users
193+
Param: userids: comma-separated list of user IDs to send the message to for a group message (example: USER1ID,USER2ID), or just one ID for an individual message
194+
Param: text: the text to send
195+
196+
#!/usr/bin/env node ${GPTSCRIPT_TOOL_DIR}/index.js sendDM
187197
---
188198
Name: User Context
189199
Description: Get information about the logged in user.

0 commit comments

Comments
 (0)