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

Microsoft Teams

Microsoft TeamsをSquidに接続してAI搭載のメッセージングを実現する

Teams connectorの機能

Teams connectorは現在、以下をサポートしています:

  • AI搭載のknowledge base検索を使用して、teamsおよびchannels内の会話を検索すること。
    • これらの機能をAIエージェントに提供することで、ユーザーはAIエージェントに関連する会話の検索を依頼でき、エージェントはインテリジェントな結果を返します。
  • ユーザーはTeamsから(@mentionsまたはdirect messages経由で)AIエージェントにメッセージを送ることができ、Teams connectorはエージェントの応答をTeams内で直接中継します。
  • teamsおよびchannelsの全会話をknowledge baseに読み込み、ユーザーがAIエージェントにインテリジェントな検索やサマリーを依頼できるようにします。
  • このconnectorは現在、only "Single Tenant" アプリケーション設定のみをサポートしており、"Multitenant" はサポートしていません。もしmultitenantのサポートが必要な場合は、let us know!

Teams connectorの設定

Squidは、メッセージの読み取りとTeams workspaceとの連携のために、Microsoft Teams application(Azure App Registration経由)に接続します。

TeamsアプリケーションとAzure App Registrationの作成

  1. Azure Portalにアクセスし、App registrations に移動します。
  2. New registration をクリックし、意味のあるアプリ名を入力します。
  3. Supported account types の下で、Single Tenant を選択します。
  4. 作成後、Application (client) IDDirectory (tenant) ID をメモしておきます。
  5. Certificates & secrets に移動し、新しいclient secretを作成します。この値は再度表示されないため、安全に保存してください。
  6. API permissions に移動し、必要なMicrosoft Graphの権限を追加します:
    • Team.ReadBasic.All - チーム情報の読み取り用
    • Channel.ReadBasic.All - チャネル情報の読み取り用
    • ChannelMessage.Read.All - チャネルからのメッセージの読み取り用
    • Chat.Read.All - チャットメッセージの読み取り用(DMをサポートしている場合)
  7. これらの権限に対してadmin consentを付与します。

SquidアプリケーションにTeams connectorを追加する

  1. Squid Consoleにアクセスし、Connectors タブを選択します。

  2. Available Connectors タブに切り替え、Microsoft Teams connectorを追加します。

  3. 設定の詳細は、Azure App Registrationから確認できます:

    Connector ID: コード内でconnectorを一意に識別するための意味のある文字列です。このIDは後で必要になるため、メモしておいてください。

    Client ID: Azure App RegistrationのOverviewタブにあるApplication (client) IDです。

    Tenant ID: Azure App RegistrationのOverviewタブにあるDirectory (tenant) IDです。

    Client Secret: Certificates & secretsセクションで作成したclient secretの値です。これはMicrosoft Graph APIへのリクエストを認証するために使用されます。

    Index Channels: Squidが、ボットがアクセス可能なteamsおよびchannelsからすべてのメッセージを読み取り、インテリジェントな検索およびサマリーを提供するかどうか。

    Message History Limit: Teams経由でSquidにメッセージを送る際、Squidがユーザーへの最適な回答をするために十分な文脈を得るため、過去のメッセージを何件読み込むかの設定です。

Teamsで使用する対応するAI Agentの作成

  1. Squid Consoleにアクセスし、Agent Studio タブを選択します。
  2. Create New Agent をクリックしてエージェントを作成します。Agent IDは後で必要になるため、メモしておいてください。
  3. 新しいエージェントのOverviewタブで、Add Abilitiesをクリックし、Microsoft Teamsのエントリーを展開して、先ほど作成したTeams connectorを追加します。

Teams Botの作成(インタラクティブなメッセージング用)

  1. Azure Portalにアクセスし、Azure Botを検索します。
  2. 新しいAzure Botリソースを作成します。
  3. Type of AppSingle Tenantに設定します。
  4. Use existing app registrationを選択して、上記で作成したApp Registrationにリンクします。
  5. Botを作成します。
  6. SquidからMessaging endpointのURLを取得します。
    • Squid Consoleにアクセスします。
    • サイドバーでBackendタブを選択します。
    • Webhooksタブを選択します。
    • teamsNotification webhookのURLをコピーします。URLは https://{your-app-id}.{your-region}.squid.cloud:8001/webhooks/teamsNotification のようになります。
    • このURLに ?integrationId={your-teams-connector-id}&agentId={your-squid-agent-id} を追加し、最終的なURLを次のようにします:
      • https://{your-app-id}.{your-region}.squid.cloud:8001/webhooks/teamsNotification?integrationId={your-teams-connector-id}&agentId={your-squid-agent-id}
  7. 作成したAzure Botに移動し、SettingsConfigurationにアクセスします。
  8. Squidのwebhook URLをMessaging endpointフィールドにコピーします。
  9. SettingsChannelsに移動し、Available ChannelsからMicrosoft Teamsを見つけ、Botに追加します。

アプリパッケージの作成とTeamsへのアップロード

  1. Teams app package を作成します。これは、manifest.jsoncolor.png、およびoutline.png の3つのファイルを含むZIPファイルです。

    • このmanifest.jsonから始め、YOUR_APPLICATION_CLIENT_ID の全てをApplication (client) IDに置き換えます。
    • PNGアイコンも利用可能です: color.png および outline.png
    • これら3つのファイルがトップレベルにあるZIPファイルを作成してください。
  2. Teamsにアップロードします。オプションは2通りあります:

    オプション A: Teams Clientを介してアップロード

    1. Microsoft Teamsを開きます。
    2. AppsManage your apps に移動します。
    3. Upload an appUpload a custom app をクリックします。
    4. ZIPファイルを選択します。
    5. Add をクリックして、組織にインストールします。

    オプション B: Teams Admin Centerを介してアップロード

    1. Teams Admin CenterTeams appsManage apps に移動します。
    2. Upload new app をクリックします。
    3. ZIPファイルを選択します。
    4. 必要に応じてアプリの設定と権限を構成します。

アプリケーションでTeams connectorを使用する

アプリケーションでTeams connectorを使用する方法は3つあります:

  1. Using the Agent Studio: Agent Studioを使用してAIエージェントを作成している場合、Add AbilitiesボタンをクリックしてMicrosoft Teams abilityを追加することでTeams connectorを組み込むことができます。Learn more about abilities here。abilityを追加した後、Test AgentタブでエージェントにTeamsメッセージの検索を依頼できます。注意: SquidがTeamsメッセージのインデックスを作成するのに数時間かかる場合があります。

    例:

    • Search Teams 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. Using the Squid SDK: Squid SDKを使用してAIエージェントを作成している場合、squid.ai().agent('AGENT_ID').ask() 関数を使用してエージェントとチャットできます。Learn more hereask()関数のconnectedIntegrationsオプションにTeams connectorを追加することで使用します。

await this.squid.ai().agent('AGENT_ID').ask('Search Teams for discussions about the new feature', {
connectedIntegrations: [{
integrationId: 'TEAMS_CONNECTOR_ID',
integrationType: 'teams',
description: 'Call this connector to search Microsoft Teams messages',
}],
});
  1. Using the NPM package: @squidcloud/teams-client を使用している場合、以下のように実装できます:
  // Initialize the client.
const teamsClient = SquidTeamsClient(this.squid, 'TEAMS_CONNECTOR_ID');

// Search for messages related to your query.
await teamsClient.searchMessages({
teamNames: 'Engineering,Product',
channelNames: 'general,announcements',
prompt: 'API design discussions'
});