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

Slack

AI-powered message を送信するため Slack を Squid に接続します​

Slack Connector の Functionality​

Slack connector は以下をサポートします。

  • channel、group、individual user への message の送信
  • SlackBot を介した Slack 内での Squid AI agent との直接 interaction
  • intelligent search と summary のための conversation の knowledge base への読み込み
  • Slack 固有の channel membership を尊重し、agent が chat 中の person が Slack で read できる conversation のみを retrieve する。Respecting source permissionsを参照してください。

Slack Connector の構成​

Squid は Slack application に接続し、Slack workspace 内の message を送受信します。

Slack Application の作成​

  1. Slack applications landing page に移動します。
  2. Create New App をクリックし、意味のある App Name と対応する Slack workspace を指定します。

Squid Application に Slack Connector を追加する​

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

  2. Available Connectors tab に切り替え、Slack connector を追加します。

  3. configuration detail はすべて、作成した Slack application の settings page で確認できます。

    Connector ID: code 内で connector を一意に識別する意味のある string。

    App ID: Slack application の ID。Slack app settings の Basic Information tab にあります。

    Client ID: Slack application の Client ID。Basic Information tab にあります。

    Verification Token: Slack app の Verification Token。Basic Information tab にあります。

    Client Secret: Slack app の Client Secret。Basic Information tab にあります。

    Signing Secret: Slack app の Signing Secret。Basic Information tab にあります。

    Squid Console API overview

    Bot User OAuth Token: Slack application の Bot User OAuth token。OAuth & Permissions tab にあります。この token は Slack API への request の authentication に使用されます。

    Squid Console API overview

    Index Channels: Squid が intelligent search と summary を提供するため、bot が追加された channel の全 message を read するかどうか。

    Message History Limit: Slack 経由で Squid に message を送信する場合、Squid が user に最適な answer を提供するために read する prior message の数。

  4. OAuth & Permissions tab に移動し、以下の Bot Token Scope が追加されていることを確認します。

    • 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

Application で Slack Connector を使用する​

application で Slack connector を使用する方法は 3 つあります。

  1. Agent Studio を使用する: Agent Studio で Add Abilities > Slack を使用して Slack connector を追加します。ability の詳細を確認してください。その後、Test Agent tab で message の送信を test できます。message search を行うには、Squid が Slack message を index 化するまで数時間待ちます。example message:

    • Send a slack message saying "Hello!" to James - "James" は Slack user
    • 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() function を使用して agent と chat できます。詳細はこちら。ask() function の connectedIntegrations option に追加して Slack connector を使用します。

// 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 Agent との Interaction​

Slack で AI agent と直接 interaction するには、以下のように Slack application で SlackBot functionality を setup します。

  1. Slack application settings で Event Subscriptions tab に移動します。
  2. Enable Events を ON に toggle します
  3. Request URL に Slack notification 用 Webhook URL を入力します。URL は次の form です。

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

注記

[DEVELOPER-ID] は backend をローカルで実行している場合にのみ必要です。Squid に deploy する場合は省略します。例:

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


4. Subscribe to Bot Events で、以下の event を追加します。

  • message.im - bot に送信された direct message を受信する
  • app_mention - channel で bot が mention された message を受信する

以上です!user が SlackBot に message を送信すると、Squid は prompt を指定 agent に forward し、Slack 上で直接 response します。