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.0'

Class Method Summary collapse

Class Method Details

.client::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 wraps the client in a proxy that converts ::Slack::Web::Api::Errors::SlackError authentication errors into Ask::Auth::InvalidCredential.

Configuration:

  • Uses the resolved token for authentication

  • Default user agent is set by slack-ruby-client

Examples:

client = Ask::Slack.client
client.channels_list
client.chat_postMessage(channel: "#general", text: "Hello!")

Returns:

  • (::Slack::Web::Client)

    an authenticated client

Raises:

  • (Ask::Auth::MissingCredential)

    if no Slack token is configured

  • (Ask::Auth::InvalidCredential)

    if the token is rejected



26
27
28
29
30
# File 'lib/ask/slack/client.rb', line 26

def self.client
  token = Ask::Auth.resolve(:slack_token)

  ClientProxy.new(::Slack::Web::Client.new(token: token))
end