Module: Ask::Slack
- Defined in:
- lib/ask/slack/client.rb,
lib/ask/slack/context.rb,
lib/ask/slack/version.rb,
lib/ask/slack/error_guide.rb
Defined Under Namespace
Modules: Errors Classes: ClientProxy
Constant Summary collapse
- DESCRIPTION =
Human-readable description of the Slack service context.
"Slack — messaging, channels, files, search, workspace management"- DOCS_URL =
Base URL for Slack Web API methods.
"https://api.slack.com/methods"- OPENAPI_URL =
URL for the Slack OpenAPI specification.
"https://api.slack.com/specs/openapi"- AUTH_NAME =
Credential name used with Ask::Auth.resolve.
:slack_token- AUTH_HOW =
Instructions for obtaining a Slack Bot User OAuth Token.
"Create a Slack app at https://api.slack.com/apps — get a Bot User OAuth Token (xoxb-). Scopes: chat:write, channels:read, users:read, files:read"- GEM_NAME =
Gem name for the Slack API client.
"slack-ruby-client"- GEM_VERSION =
Required gem version constraint.
"~> 3.1"- GEM_DOCS =
URL for slack-ruby-client library documentation.
"https://rubydoc.info/gems/slack-ruby-client"- QUICK_START =
Quick-start Ruby code snippet for agents to copy-paste.
<<~RUBY client = Ask::Slack.client client.channels_list client.conversations_list client.chat_postMessage(channel: "#general", text: "Hello from ask-rb!") client.users_list client.conversations_history(channel: "C123456") RUBY
- VERSION =
'0.1.2'
Class Method Summary collapse
-
.client(base_delay: nil) ⇒ ::Slack::Web::Client
Returns an authenticated Slack Web API client configured for an AI agent.
Class Method Details
.client(base_delay: nil) ⇒ ::Slack::Web::Client
Returns an authenticated Slack Web API client configured for an AI agent.
Resolves the Slack token via Ask::Auth.resolve(:slack_token) and configures the client with sensible defaults:
-
timeout: 30 seconds for HTTP requests -
open_timeout: 10 seconds for TCP connection
Retry behaviour: ClientProxy retries transient Faraday and network errors up to 3 times with exponential backoff before raising Ask::Auth::InvalidCredential.
The client is wrapped in a ClientProxy that:
-
Converts auth errors (
NotAuthed,InvalidAuth, etc.) intoAsk::Auth::InvalidCredential -
Retries transient network failures with exponential backoff
33 34 35 36 37 38 39 40 41 |
# File 'lib/ask/slack/client.rb', line 33 def self.client(base_delay: nil) token = Ask::Auth.resolve(:slack_token) ClientProxy.new(::Slack::Web::Client.new( token: token, timeout: 30, open_timeout: 10 ), base_delay: base_delay) end |