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 権限
セットアップ
Section titled “セットアップ”-
Slack 設定トークンのペアを作成する
api.slack.com/apps に移動し、app configuration token pair を作成します。次の 2 つの値をコピーします:
- Configuration access token (
xoxe.xoxp-...) - Configuration refresh token (
xoxe-1-...)
- Configuration access token (
-
provider を設定する
answers.json {"setup_answers": {"messaging-slack": {"slack_configuration_access_token": "xoxe.xoxp-xxx","slack_configuration_refresh_token": "xoxe-1-xxx"}}} -
setup を実行する
Terminal window gtc setup --answers answers.json ./my-bundle -
Add to Slack をクリックする
setup は Slack app を登録または更新し、Add to Slack アクションを表示します。生成された Slack authorization URL を開き、workspace を選択し、要求された scopes を確認して install を承認します。
OAuth redirect が setup に戻ると、Greentic は tenant 用に Slack app id、client id、client secret、runtime OAuth answers を保存します。callback が自動処理されなかった場合は、install 承認後に
gtc setup --answers answers.json ./my-bundleをもう一度実行します。 -
Slack で app を追加する
Slack を開き、app が workspace にインストールされていることを確認します。channel の会話では、worker が応答する channel に app を追加します。channel の integration settings から、または channel で app を mention/invite して追加できます。
-
runtime を開始または再起動する
Terminal window gtc start ./my-bundle起動時には、保存済みの
slack_app_idと設定トークンペアを使って、現在の webhook URL で Slack app manifest を更新します。 -
channel をテストする
app に direct message を送るか、追加した Slack channel で app を mention します。channel events は、app がメンバーであり、インストール済み scopes がその event を許可している channel でのみ届きます。
設定オプション
Section titled “設定オプション”| オプション | 必須 | 説明 |
|---|---|---|
slack_configuration_access_token | はい | app manifest の更新に使う短命の Slack configuration token |
slack_configuration_refresh_token | はい | configuration access token をローテーションするための refresh token |
slack_app_id | 生成 | setup が作成または返す Slack app id |
slack_client_id | 生成 | app registration が返す Slack OAuth client id |
client_secret | 生成された secret | app registration が返す Slack OAuth client secret |
テキストメッセージ
Section titled “テキストメッセージ”- id: reply type: reply config: message: "Hello! How can I help you?"Markdown Formatting
Section titled “Markdown Formatting”Slack は mrkdwn format を使います:
- id: formatted type: reply config: message: | *Bold* _Italic_ `code` >Blockquote • Bullet pointBlock Kit メッセージ
Section titled “Block Kit メッセージ”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"Interactive Buttons
Section titled “Interactive Buttons”- 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"Select Menus
Section titled “Select Menus”- 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 Reply
Section titled “Thread Reply”thread に返信します:
- id: thread_reply type: reply config: message: "This replies in the thread" thread_ts: "{{original_message.thread_ts}}"File Upload
Section titled “File Upload”Slack の file API は時間とともに変わります。インストール済みの messaging-slack pack が対象バージョンの file support を公開している場合にのみ使用してください。それ以外の場合はリンクを送るか、Slack の現在の external upload flow を使用してください。
- id: upload_file type: reply config: files: - url: "https://example.com/report.pdf" filename: "report.pdf" title: "Monthly Report"Ephemeral Message
Section titled “Ephemeral Message”1人の user にだけ見えるメッセージです:
- id: ephemeral type: reply config: message: "Only you can see this" ephemeral: true user: "{{user_id}}"Interaction の処理
Section titled “Interaction の処理”Button Clicks
Section titled “Button Clicks”name: handle_interactionversion: "1.0"
nodes: - id: route_action type: branch config: conditions: - expression: "action_id == 'help_clicked'" to: show_help - expression: "action_id == 'create_ticket'" to: create_ticket default: unknown_action
- id: show_help type: reply config: message: "Here's how I can help..."
triggers: - type: block_action target: route_actionSelect Menu の変更
Section titled “Select Menu の変更”- id: handle_select type: branch config: conditions: - expression: "selected_value == 'technical'" to: technical_flow - expression: "selected_value == 'billing'" to: billing_flowSlash Commands
Section titled “Slash Commands”- app 設定の Slash Commands に移動する
- command を作成する(例:
/support) - Request URL を webhook に設定する
flow では次のように処理します:
name: slash_commandversion: "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_commandChannel 設定
Section titled “Channel 設定”単一 channel
Section titled “単一 channel”tenants: demo: teams: support: channels: slack: provider: messaging-slack config: channel_id: "C1234567890"複数 channel
Section titled “複数 channel”tenants: demo: teams: support: channels: slack-general: provider: messaging-slack config: channel_id: "C1234567890" slack-vip: provider: messaging-slack config: channel_id: "C0987654321"トラブルシューティング
Section titled “トラブルシューティング”App がメッセージを受信しない
Section titled “App がメッセージを受信しない”-
Event Subscriptions を確認する:
- Request URL が正しいことを確認する
- event が有効になっていることを確認する
- bot が正しい event を購読していることを確認する
-
Bot の権限を確認する:
- scope を追加した後は app を再インストールする
- bot が channel に参加していることを確認する
-
Webhook をテストする:
Terminal window curl https://your-domain.com/v1/messaging/ingress/messaging-slack/demo/default
“not_authed” Error
Section titled ““not_authed” Error”bot token が無効か期限切れです。OAuth & Permissions から新しい token を取得してください。
“channel_not_found” Error
Section titled ““channel_not_found” Error”- channel ID が正しいことを確認する
- bot が channel に追加されていることを確認する
- channel が archived されていないことを確認する
Rate Limiting
Section titled “Rate Limiting”Slack の rate limit は method ごとに異なります。適切に処理してください:
- id: reply type: reply config: message: "Response" retry_on_rate_limit: true max_retries: 3セキュリティ
Section titled “セキュリティ”Greentic は次を自動検証します:
- Request timestamp
- signing secret を使った signature
- token verification
次のステップ
Section titled “次のステップ”- Block Kit Builder - rich message を設計する
- Teams Provider - Teams integration を追加する
- Flows Guide - 複雑な workflow を構築する