ask-slack 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01d86ade7e8ae10d0ea5370bf29ad2d5817dab29d6fed2d210bdf6a900498206
4
- data.tar.gz: ba00d9649330d05b973d12a7d173c28337b8c5d0a54236b6c0c40d45902181d5
3
+ metadata.gz: 8328e80c2b6386b33282dd95c8af3eceab18182e53547d5fe6b849a9bcbe874d
4
+ data.tar.gz: c73406fd2a39f3d8dca19f856226373cc30c090023a2f73d2f1b342081a2c3bd
5
5
  SHA512:
6
- metadata.gz: 53cc6ece6ba677124a33a25cff481df7e3dafcd1bff49186211e46ba30f6f64089263d9585eda6a1041191e7288659234d3f2d41c1730d04376a216a023f7822
7
- data.tar.gz: 15db0b3dfcb89f293ceda3dbb18c9623ceaa8f5344c6664a88ca32e4df6fe7952eb23862863a761e004faeade2223b557f618134cbe5a90cea88a7ab83e8fea6
6
+ metadata.gz: b46af6dc89a858df607c4e0b57a32873463ab80883757e0bcbba57e1297882a23e2d23fbe916d9e7fa31912caace997be3166b170537af293bff1ae07fb48452
7
+ data.tar.gz: 32d1694ed20b65b4595a7b24a70aad1f255745d33208b6844b73ce7099154bcea8761f0520826a72f260eb448f067a7d5ed7635980c4a2bcd7aa46e8b769e35e
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: slack.use_slack
3
+ description: How to navigate the Slack API with slack-ruby-client — discover methods, handle auth, pagination, and errors
4
+ ---
5
+
6
+ Use this skill when you need to interact with Slack — posting messages, reading
7
+ channels, managing users, uploading files, or searching conversations.
8
+
9
+ ## Step 1: Get the Client
10
+
11
+ ```ruby
12
+ client = Ask::Slack.client
13
+ ```
14
+
15
+ This returns an authenticated `Slack::Web::Client`. It expects a valid Slack Bot
16
+ User OAuth Token resolved via `Ask::Auth.resolve(:slack_token)`.
17
+
18
+ If you get an auth error, read `Ask::Slack::Context::AUTH_HOW` for token setup.
19
+
20
+ ## Step 2: Explore the Context
21
+
22
+ The gem ships with structured context you should reference:
23
+
24
+ ```ruby
25
+ Ask::Slack::Context::DOCS_URL # Slack Web API methods docs
26
+ Ask::Slack::Context::GEM_DOCS # slack-ruby-client Ruby docs
27
+ Ask::Slack::Context::QUICK_START # Copy-paste examples
28
+ Ask::Slack::Context::GEM_NAME # "slack-ruby-client"
29
+ ```
30
+
31
+ The `QUICK_START` constant has basic examples for channels, messaging, and users.
32
+
33
+ ## Step 3: Discover Available Methods
34
+
35
+ Use code tools to explore the underlying SDK client:
36
+
37
+ ```ruby
38
+ Code.new.call(code: "
39
+ client = Ask::Slack.client.client # unwrap proxy to get raw client
40
+ puts client.methods(false).sort.join(\"\\n\")
41
+ ")
42
+ ```
43
+
44
+ Common Slack API methods:
45
+ - `client.chat_postMessage(channel:, text:, blocks:)` — send a message
46
+ - `client.conversations_list` — list public channels
47
+ - `client.conversations_history(channel:)` — read channel history
48
+ - `client.conversations_replies(channel:, ts:)` — get thread replies
49
+ - `client.users_list` — list workspace users
50
+ - `client.files_upload_v2(channels:, content:, file:)` — upload files
51
+
52
+ For method details, read the slack-ruby-client source:
53
+ ```ruby
54
+ # Discover the underlying WebClient methods
55
+ Read.new.call(path: "$GEM_PATH/slack-ruby-client-*/lib/slack/web/client.rb")
56
+ ```
57
+
58
+ ## Step 4: Authentication & Common Errors
59
+
60
+ Auth failures are converted to `Ask::Auth::InvalidCredential`. For detailed
61
+ error guidance, use:
62
+
63
+ ```ruby
64
+ Ask::Slack::Errors.for("channel_not_found")
65
+ Ask::Slack::Errors.status_code_description(429)
66
+ Ask::Slack::Errors::RATE_LIMIT
67
+ Ask::Slack::Errors::PAGINATION
68
+ ```
69
+
70
+ Common scenarios:
71
+ - **not_in_channel**: Bot isn't in that channel → invite or use `conversations_join`
72
+ - **missing_scope**: Token lacks required OAuth scope → add at api.slack.com/apps
73
+ - **rate_limited**: Exceeded per-method limit → check Retry-After header
74
+ - **invalid_blocks**: Block Kit JSON has validation errors
75
+
76
+ ## Step 5: Pagination
77
+
78
+ Slack uses cursor-based pagination. The pattern is:
79
+
80
+ ```ruby
81
+ response = client.conversations_list(limit: 200)
82
+ cursor = response.response_metadata.next_cursor
83
+ # Pass cursor in next request:
84
+ client.conversations_list(limit: 200, cursor: cursor) unless cursor.empty?
85
+ ```
86
+
87
+ Most list methods accept `limit` (max 200) and `cursor` parameters.
88
+
89
+ ## Step 6: Message Formatting
90
+
91
+ For rich messages, use Block Kit (JSON blocks). The `QUICK_START` constant
92
+ has examples for header, section, context, divider, and actions blocks. For
93
+ detailed Block Kit reference, see the Slack API docs.
94
+
95
+ ## Step 7: Fallback Strategy
96
+
97
+ If the SDK doesn't have a method for what you need:
98
+ 1. Check `Ask::Slack::Context::DOCS_URL` for the API method
99
+ 2. Use `client.post("method.name", params)` for custom API calls
100
+ 3. Use `client.get("conversations.list")` style for raw endpoint access
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module Slack
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto
@@ -146,7 +146,7 @@ files:
146
146
  - LICENSE
147
147
  - README.md
148
148
  - lib/ask-slack.rb
149
- - lib/ask/skills/slack.compose/SKILL.md
149
+ - lib/ask/skills/slack.use_slack/SKILL.md
150
150
  - lib/ask/slack/client.rb
151
151
  - lib/ask/slack/context.rb
152
152
  - lib/ask/slack/error_guide.rb
@@ -1,168 +0,0 @@
1
- ---
2
- name: slack.compose
3
- description: How to format and send effective Slack messages — blocks, attachments, markdown, and threading
4
- ---
5
-
6
- Use this skill when you need to communicate via Slack — sending messages,
7
- formatting rich content, or managing conversations with the Slack API.
8
-
9
- ## Step 1: Establish the Channel and Context
10
-
11
- Before sending any message, confirm:
12
-
13
- - **Channel** — public channel name (e.g. `#general`) or user DM ID
14
- - **Intent** — are you informing, asking, alerting, or collaborating?
15
- - **Thread** — should this be a new message or reply in an existing thread?
16
-
17
- ```ruby
18
- client = Ask::Slack.client
19
- ```
20
-
21
- ## Step 2: Choose the Message Format
22
-
23
- Slack supports three levels of message formatting:
24
-
25
- **Plain text** — Simple, fast, use for ephemeral or bot messages:
26
- ```ruby
27
- client.chat_postMessage(channel: "#general", text: "Deploy finished successfully!")
28
- ```
29
-
30
- **Markdown-ish text** — Use basic formatting in `text`:
31
- - `*bold*` for emphasis
32
- - `_italic_` for book titles or terms
33
- - `~strikethrough~` for obsolete info
34
- - `` `code` `` for inline code
35
- - ``````code block`````` for multi-line code
36
- - `>quote` for blockquotes
37
-
38
- **Blocks** — Rich interactive messages with structured layout:
39
- ```ruby
40
- client.chat_postMessage(channel: "#deploy", blocks: [
41
- {
42
- type: "header",
43
- text: { type: "plain_text", text: "🚀 Deploy Complete" }
44
- },
45
- {
46
- type: "section",
47
- text: { type: "mrkdwn", text: "Version *v2.3.1* deployed to *production*" }
48
- },
49
- {
50
- type: "context",
51
- elements: [
52
- { type: "mrkdwn", text: "By: @kaka | Duration: 2m 34s" }
53
- ]
54
- }
55
- ])
56
- ```
57
-
58
- ## Step 3: Use Block Kit for Rich Messages
59
-
60
- Block Kit is the recommended way to compose Slack messages. Key block types:
61
-
62
- **Header** — Bold, centered title (1 per message recommended):
63
- ```ruby
64
- { type: "header", text: { type: "plain_text", text: "📋 Report Title" } }
65
- ```
66
-
67
- **Section** — Body content with optional accessory:
68
- ```ruby
69
- { type: "section",
70
- text: { type: "mrkdwn", text: "Description here" },
71
- accessory: { type: "button", text: { type: "plain_text", text: "View" }, value: "view", url: "..." } }
72
- ```
73
-
74
- **Divider** — Visual separator:
75
- ```ruby
76
- { type: "divider" }
77
- ```
78
-
79
- **Context** — Small text for metadata, timestamps, authorship:
80
- ```ruby
81
- { type: "context", elements: [{ type: "mrkdwn", text: "Posted 2h ago" }] }
82
- ```
83
-
84
- **Fields** — Multi-column layout in a section:
85
- ```ruby
86
- { type: "section",
87
- fields: [
88
- { type: "mrkdwn", text: "*Status:*\n✅ Complete" },
89
- { type: "mrkdwn", text: "*Duration:*\n45s" }
90
- ] }
91
- ```
92
-
93
- **Actions** — Interactive buttons (avoid more than 3):
94
- ```ruby
95
- { type: "actions", elements: [
96
- { type: "button", text: { type: "plain_text", text: "Approve" }, style: "primary", value: "approve" },
97
- { type: "button", text: { type: "plain_text", text: "Reject" }, style: "danger", value: "reject" }
98
- ] }
99
- ```
100
-
101
- ## Step 4: Handle Threading
102
-
103
- Reply in a thread to keep conversations organized:
104
-
105
- ```ruby
106
- # Reply to a specific message
107
- client.chat_postMessage(
108
- channel: "#general",
109
- thread_ts: "1234567890.123456", # parent message timestamp
110
- text: "I've looked into this — here's what I found..."
111
- )
112
-
113
- # Broadcast reply to channel as well (use sparingly)
114
- client.chat_postMessage(
115
- channel: "#general",
116
- thread_ts: "1234567890.123456",
117
- text: "Update for everyone",
118
- reply_broadcast: true
119
- )
120
- ```
121
-
122
- ## Step 5: Handle Errors
123
-
124
- Slack API errors are converted to `Ask::Auth::InvalidCredential` for auth failures.
125
- For other errors, check the error message:
126
-
127
- ```ruby
128
- begin
129
- client.chat_postMessage(channel: "#unknown", text: "test")
130
- rescue Slack::Web::Api::Errors::ChannelNotFound => e
131
- # Channel doesn't exist or bot not invited
132
- end
133
- ```
134
-
135
- Common errors:
136
- - `channel_not_found` — Bot not in channel or channel doesn't exist
137
- - `not_in_channel` — Bot needs to be invited: `/invite @botname`
138
- - `invalid_blocks` — Block Kit JSON validation error
139
- - `rate_limited` — Too many requests, retry with backoff
140
- - `msg_too_long` — Message exceeds 40,000 character limit
141
-
142
- ## Step 6: Upload Files
143
-
144
- For longer content, upload as a file:
145
-
146
- ```ruby
147
- client.files_upload_v2(
148
- channels: "#general",
149
- content: "Long content here...",
150
- filename: "report.txt",
151
- title: "Deploy Report"
152
- )
153
- ```
154
-
155
- ## Formatting Reference
156
-
157
- | Format | Markdown | Result |
158
- |--------|----------|--------|
159
- | Bold | `*text*` | **text** |
160
- | Italic | `_text_` | *text* |
161
- | Strikethrough | `~text~` | ~~text~~ |
162
- | Code | `` `code` `` | `code` |
163
- | Code block | ```` ```code``` ```` | ⬛ code |
164
- | Quote | `>text` | blockquote |
165
- | Link | `<https://...\|label>` | [label](...) |
166
- | User mention | `<@U12345>` | @username |
167
- | Channel | `<#C12345>` | #channel |
168
- | Emoji | `:rocket:` | 🚀 |