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 の作成
- Slack applications landing page に移動します。
- Create New App をクリックし、意味のある App Name と対応する Slack workspace を指定します。
Squid Application に Slack Connector を追加する
-
Squid Console に移動し、Connectors tab を選択します。
-
Available Connectors tab に切り替え、Slack connector を追加します。
-
configuration detail はすべて、作成した Slack application の settings page で確認できます。
Connector ID: code 内で connector を一意に識別する意味のある string。
App ID: Slack application の ID。Slack app settings の
Basic Informationtab にあります。Client ID: Slack application の Client ID。
Basic Informationtab にあります。Verification Token: Slack app の Verification Token。
Basic Informationtab にあります。Client Secret: Slack app の Client Secret。
Basic Informationtab にあります。Signing Secret: Slack app の Signing Secret。
Basic Informationtab にあります。
Bot User OAuth Token: Slack application の Bot User OAuth token。
OAuth & Permissionstab にあります。この token は Slack API への request の authentication に使用されます。
Index Channels: Squid が intelligent search と summary を提供するため、bot が追加された channel の全 message を read するかどうか。
Message History Limit: Slack 経由で Squid に message を送信する場合、Squid が user に最適な answer を提供するために read する prior message の数。
-
OAuth & Permissions tab に移動し、以下の Bot Token Scope が追加されていることを確認します。
app_mentions:readchannels:historychannels:joinchannels:readchat:writechat:write.publicfiles:readfiles:writegroups:historygroups:readim:historyim:readim:writempim:historympim:readmpim:writeusers:readusers:read.email
Application で Slack Connector を使用する
application で Slack connector を使用する方法は 3 つあります。
-
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 userPost "The deployment was successful!" to the #devops channelSearch Slack for conversations about the product launchShow me all discussions in the Engineering team about API designFind messages in the Finance channel about budget planning
-
Squid SDK を使用する: Squid SDK を使用して AI agent を作成する場合は、
squid.ai().agent('AGENT_ID').ask()function を使用して agent と chat できます。詳細はこちら。ask()function のconnectedIntegrationsoption に追加して 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);
- 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 します。
- Slack application settings で Event Subscriptions tab に移動します。
- Enable Events を ON に toggle します
- 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
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 します。