メインコンテンツまでスキップ

Slack

Slack を Squid に接続して、AI を活用したメッセージを送信する

Slack コネクタの機能

Slack コネクタは次をサポートします。

  • チャンネル、グループ、個々のユーザーへのメッセージ送信
  • SlackBot 経由で、Slack 内から Squid AI agents と直接やり取り
  • 会話をナレッジベースに取り込み、インテリジェント検索と要約を実現

Slack コネクタの設定

Squid は Slack application に接続して、Slack workspace 内のメッセージを送受信(送信と読み取り)します。

Slack application の作成

  1. Slack applications のランディングページに移動します。
  2. Create New App をクリックし、意味のある App Name と、対応する Slack workspace を指定します。

Squid application への Slack コネクタ追加

  1. Squid Console に移動し、Connectors タブを選択します。

  2. Available Connectors タブに切り替え、Slack コネクタを追加します。

  3. 設定の詳細はすべて、先ほど作成した Slack application の settings ページで確認できます。

    Connector ID: コード内でコネクタを一意に識別する、意味のある文字列。

    App ID: Slack application の ID。Slack app 設定の Basic Information タブで確認できます。

    Client ID: Slack application の Client ID。Basic Information タブで確認できます。

    Verification Token: Slack app の Verification Token。Basic Information タブで確認できます。

    Client Secret: Slack app の Client Secret。Basic Information タブで確認できます。

    Signing Secret: Slack app の Signing Secret。Basic Information タブで確認できます。

    Squid Console API overview

    Bot User OAuth Token: Slack application の Bot User OAuth token。OAuth & Permissions タブで確認できます。このトークンは Slack API へのリクエスト認証に使用されます。

    Squid Console API overview

    Index Channels: Squid が(ボットが追加されているチャンネルの)すべてのメッセージを読み取り、インテリジェント検索と要約を提供するかどうか。

    Message History Limit: Slack 経由で Squid にメッセージを送る際、ユーザーに最適な回答をするためのコンテキストとして、Squid が読み取る直前のメッセージ数。

  4. OAuth & Permissions タブに移動し、次の Bot Token Scopes が追加されていることを確認します。

    • app_mentions:read
    • channels:history
    • channels:join
    • channels:read
    • chat:write
    • chat:write.public
    • files:read
    • files:write
    • groups:history
    • groups:read
    • im:history
    • im:read
    • im:write
    • mpim:history
    • mpim:read
    • mpim:write
    • users:read
    • users:read.email

アプリケーションで Slack コネクタを使用する

アプリケーションで Slack コネクタを使用する方法は 3 つあります。

  1. Agent Studio を使用する: Agent Studio で Add Abilities > Slack から Slack コネクタを追加します。abilities の詳細。その後、Test Agent タブでメッセージ送信をテストできます。メッセージ検索については、Squid が Slack メッセージをインデックスするまで数時間かかる場合があります。メッセージ例:

    • Send a slack message saying "Hello!" to James - 「James」は Slack ユーザー
    • Post "The deployment was successful!" to the #devops channel
    • Search Slack for conversations about the product launch
    • Show me all discussions in the Engineering team about API design
    • Find messages in the Finance channel about budget planning
  2. Squid SDK を使用する: Squid SDK を使って AI agent を作成している場合、squid.ai().agent('AGENT_ID').ask() 関数で agent とチャットできます。詳細はこちらask() 関数の connectedIntegrations オプションで追加することで、Slack コネクタを使用できます。

// Configuration to let the agent be aware of the Slack connector.
const config = {
connectedIntegrations: [
{
integrationId: 'SLACK_CONNECTOR_ID',
integrationType: 'slack',
description: 'Call this connector whenever a user asks to send or search Slack messages',
},
],
};

// Send a message.
await this.squid.ai().agent('AGENT_ID').ask('Send a slack message saying "Hello!" to the general channel', config);

// Search messages related to your search.
await this.squid.ai().agent('AGENT_ID').ask('Find messages in the Finance channel about budget planning.', config);
  1. NPM package を使用する: @squidcloud/slack-client を使用する場合、次のようにできます。
// Initialize the client.
const slackClient = SquidSlackClient(this.squid, 'SLACK_CONNECTOR_ID');

// Send a message.
await slackClient.sendMessage({
recipient: 'general',
recipientType: 'channel',
message: 'Hello!',
});

// Find messages related to your search.
await slackClient.searchMessages({
channelNames: 'general,random',
prompt: 'need help',
});

SlackBot 経由で AI Agents とやり取りする

Slack 内で AI agents と直接やり取りするには、Slack application で次のように SlackBot 機能を設定します。

  1. Slack application の settings で Event Subscriptions タブに移動します。
  2. Enable Events を ON に切り替えます
  3. Request URL に、Slack notification 用の Webhook URL を入力します。URL は次の形式です。

https://[APP_ID]-[ENV_ID]-[DEVELOPER_ID].[REGION].squid.cloud/webhooks/slackNotification?agentId=[AGENT_ID]

Note

[DEVELOPER-ID] はバックエンドをローカルで実行している場合にのみ必要です。squid にデプロイする場合は省略され、例えば次のようになります。

https://9kxp2nvqtcfflwazoe-dev.us-east-1.aws.squid.cloud/webhooks/slackNotification?agentId=quote-agent
Squid Console API overview


4. Subscribe to Bot Events の下に、次のイベントを追加します。

  • message.im - ボットに送られたダイレクトメッセージを受信するため
  • app_mention - チャンネル内でボットがメンションされたメッセージを受信するため

以上です。ユーザーが SlackBot にメッセージを送信すると、Squid はその prompt を指定された agent に転送し、Slack 内で直接返信します。