コンテンツにスキップ

Slack

Slack provider は digital worker を Slack workspace に統合します。次をサポートします:

  • ダイレクトメッセージ(DM)
  • channel message
  • app mention
  • interactive component(button、menu)
  • Block Kit rich messaging
  • slash command
  • thread reply
  • Slack workspace
  • Slack app を作成できる admin 権限
  1. Slack App を作成する

    api.slack.com/apps にアクセスし、“Create New App” をクリックします:

    • “From scratch” を選ぶ
    • app 名を入力する(例: “My Support Bot”)
    • workspace を選ぶ
  2. Bot Token Scope を設定する

    OAuth & PermissionsScopesBot Token Scopes に移動します:

    必須 scope:

    • chat:write - メッセージを送信する
    • im:history - DM 履歴を読む
    • im:write - DM を開く
    • users:read - user 情報を読む

    任意 scope:

    • channels:history - channel message を読む
    • channels:read - channel を一覧する
    • files:read - file を読む
    • files:write - file を upload する
  3. Event Subscriptions を有効にする

    Event Subscriptions に移動します:

    • Events を有効にする
    • Request URL を設定する: https://your-domain.com/webhook/slack/{tenant}/{team}

    bot event を購読します:

    • message.im - DM message
    • message.channels - channel message
    • app_mention - @mention
  4. Interactivity を有効にする

    Interactivity & Shortcuts に移動します:

    • Interactivity を有効にする
    • Request URL を設定する: https://your-domain.com/webhook/slack/{tenant}/{team}/interactive
  5. App を workspace にインストールする

    Install AppInstall to Workspace に移動します。

    Bot User OAuth Tokenxoxb- で始まる)をコピーします。

  6. App 認証情報を取得する

    Basic Information から次を取得します:

    • App ID
    • Configuration Token(manifest 自動更新用)
  7. provider を設定する

    answers.json
    {
    "messaging-slack": {
    "enabled": true,
    "public_base_url": "https://your-domain.ngrok-free.app",
    "api_base_url": "https://slack.com/api",
    "bot_token": "xoxb-xxx-xxx-xxx",
    "slack_app_id": "A07XXXXXX",
    "slack_configuration_token": "xoxe.xoxp-xxx"
    }
    }
  8. セットアップを実行する

    Terminal window
    gtc setup --answers answers.json ./my-bundle
OptionRequiredDescription
enabledYesprovider を有効/無効にする
public_base_urlYeswebhook 用の公開 URL
bot_tokenYesBot User OAuth Token(xoxb-...
slack_app_idYesBasic Information にある App ID
slack_configuration_tokenNomanifest の自動更新用
api_base_urlNoSlack API URL(デフォルト: https://slack.com/api
- id: reply
type: reply
config:
message: "Hello! How can I help you?"

Slack は mrkdwn format を使います:

- id: formatted
type: reply
config:
message: |
*Bold* _Italic_ `code`
>Blockquote
• Bullet point

rich layout には Slack の Block Kit を使います:

- id: rich_message
type: reply
config:
blocks:
- type: section
text:
type: mrkdwn
text: "*Welcome!*\nHow can I assist you today?"
- type: divider
- type: actions
elements:
- type: button
text:
type: plain_text
text: "Get Help"
action_id: "help_clicked"
value: "help"
- type: button
text:
type: plain_text
text: "View Status"
action_id: "status_clicked"
value: "status"
- id: ask_action
type: reply
config:
message: "What would you like to do?"
blocks:
- type: actions
elements:
- type: button
text:
type: plain_text
text: "Create Ticket"
style: primary
action_id: "create_ticket"
- type: button
text:
type: plain_text
text: "Cancel"
style: danger
action_id: "cancel"
- id: select_option
type: reply
config:
blocks:
- type: section
text:
type: mrkdwn
text: "Select a category:"
accessory:
type: static_select
action_id: "category_select"
options:
- text:
type: plain_text
text: "Technical Support"
value: "technical"
- text:
type: plain_text
text: "Billing"
value: "billing"
- text:
type: plain_text
text: "General"
value: "general"

thread に返信します:

- id: thread_reply
type: reply
config:
message: "This replies in the thread"
thread_ts: "{{original_message.thread_ts}}"
- id: upload_file
type: reply
config:
files:
- url: "https://example.com/report.pdf"
filename: "report.pdf"
title: "Monthly Report"

1人の user にだけ見えるメッセージです:

- id: ephemeral
type: reply
config:
message: "Only you can see this"
ephemeral: true
user: "{{user_id}}"
flows/on_interaction.ygtc
name: handle_interaction
version: "1.0"
nodes:
- id: route_action
type: branch
config:
conditions:
- expression: "action_id == 'help_clicked'"
next: show_help
- expression: "action_id == 'create_ticket'"
next: create_ticket
default: unknown_action
- id: show_help
type: reply
config:
message: "Here's how I can help..."
triggers:
- type: block_action
target: route_action
- id: handle_select
type: branch
config:
conditions:
- expression: "selected_value == 'technical'"
next: technical_flow
- expression: "selected_value == 'billing'"
next: billing_flow
  1. app 設定の Slash Commands に移動する
  2. command を作成する(例: /support
  3. Request URL を webhook に設定する

flow では次のように処理します:

flows/slash_command.ygtc
name: slash_command
version: "1.0"
nodes:
- id: handle_command
type: reply
config:
message: "Support bot at your service!"
response_type: in_channel # or "ephemeral"
triggers:
- type: slash_command
command: "/support"
target: handle_command
greentic.demo.yaml
tenants:
demo:
teams:
support:
channels:
slack:
provider: messaging-slack
config:
channel_id: "C1234567890"
tenants:
demo:
teams:
support:
channels:
slack-general:
provider: messaging-slack
config:
channel_id: "C1234567890"
slack-vip:
provider: messaging-slack
config:
channel_id: "C0987654321"
  1. Event Subscriptions を確認する:

    • Request URL が正しいことを確認する
    • event が有効になっていることを確認する
    • bot が正しい event を購読していることを確認する
  2. Bot の権限を確認する:

    • scope を追加した後は app を再インストールする
    • bot が channel に参加していることを確認する
  3. Webhook をテストする:

    Terminal window
    curl https://your-domain.com/webhook/slack/demo/default

bot token が無効か期限切れです。OAuth & Permissions から新しい token を取得してください。

  • channel ID が正しいことを確認する
  • bot が channel に追加されていることを確認する
  • channel が archived されていないことを確認する

Slack の rate limit は method ごとに異なります。適切に処理してください:

- id: reply
type: reply
config:
message: "Response"
retry_on_rate_limit: true
max_retries: 3

Greentic は次を自動検証します:

  • Request timestamp
  • signing secret を使った signature
  • token verification