Copilot Studioは、企業向けのローコード・ノーコードチャットボット開発プラットフォームです。
複雑なビジネスロジックや外部システムとの連携が必要な場合、カスタムスキルを作成してCopilot Studioから呼び出すことで、より高度な機能を実現できます。
本記事では、Bot Framework SDKとスキルの概要から、実際のスキルボット作成手順まで詳しく解説します。
- Bot Framework SDKとは
- スキルとは
- Copilot Studioでのスキル活用
- サンプルスキルボットの作成
- Azure App Serviceへのデプロイ
- 3. デプロイの確認
- まとめ
Bot Framework SDKとは
Bot Framework SDKは、Microsoftが提供するボット開発用のフレームワークです。以下の特徴があります。
- 複数言語に対応: C#、JavaScript、Python、Javaをサポート
- 豊富なチャンネル対応: Teams、Slack、Web Chat、LINEなど様々なプラットフォームで動作
- Azure Bot Serviceとの連携: クラウドでのスケーラブルな運用が可能
スキルとは
特定の機能を持つボットを他のボットから呼び出して利用できる仕組みです。
スキルの利点として以下があります。
- 再利用性: 一度作成したスキルを複数のボットで利用可能
- モジュール化: 機能ごとにスキルを分割し、保守性を向上
- 専門性: 特定の分野に特化したスキルを開発可能
Copilot Studioでのスキル活用
Copilot Studioでは、特定のトリガーやユーザーの入力に応じてスキルを呼び出しだすことで、エージェント内のアクションや Power Automateフローでは実装できない高度な機能をエージェントに追加できます。
設定方法
Copilot Studioでスキルを利用するには、以下の設定が必要です。
- スキルエンドポイントの登録
- 認証情報の設定
- メッセージフォーマットの定義
サンプルスキルボットの作成
Microsoft提供のBotBuilder-Samplesを使用して、実際にスキルボットを作成してみましょう。
使用するサンプルは以下です。
前提条件
- .NET SDK version 8.0
- Visual Studio 2022またはVS Code
- gitがインストールされていること
- Azure Portalが利用できること
オプション
- Azure portal でEntraIDアプリを作成し、DialogSkillBotのappsettings.json にて AppId とパスワードを更新します。*1
- LUIS を介してメッセージ アクティビティを実行する場合は、DialogSkillBot/appsettings.json で LuisAppId、LuisAPIKey、LuisAPIHostName セクションを構成します。*2
プロジェクトについて
サンプルプロジェクトは以下の構成になっています。
81.skills-skilldialog/ ├── DialogSkillBot/ # スキルボット本体 │ ├── wwwroot/ │ │ └── manifest/ │ │ └── dialogchildbot-manifest-1.0.json # スキルの定義ファイル │ └── (その他必要なファイル…) ├── DialogRootBot/ # スキルを呼び出すルートボット └── README.md # 詳細な説明
リポジトリのクローンは以下のコマンドで取得します。
git clone https://github.com/microsoft/botbuilder-samples.git
Azure App Serviceへのデプロイ
Azure App Serviceの作成
Azure portalにログインし、以下の手順でApp Serviceを作成します。
- リソースの作成 > Web App を選択
基本設定を入力:
- サブスクリプション: 使用するサブスクリプション
- リソースグループ: 新規作成または既存を選択
- 名前:
dialogskillbot-webapp(任意の名前) - ランタイムスタック:
.NET 8 (LTS) - オペレーティングシステム:
Windows - 地域:
Japan East - 価格プラン:
F1(無料)またはB1(Basic)
確認および作成 をクリックしてリソースを作成
Entra IDアプリの作成
- Azure portal > Entra ID > アプリの登録 に移動
- 新規登録 をクリック
- アプリケーション情報を入力:
- 名前:
DialogSkillBot - サポートされているアカウントの種類:
この組織ディレクトリのみ - リダイレクトURI: 空欄のまま
- 名前:
- 登録 をクリック

クライアントシークレットの作成
- 作成したアプリの 証明書とシークレット に移動
- 新しいクライアントシークレット をクリック
- 説明と期間を設定して 追加
- 生成された 値 をコピーして保存(後で使用)
必要な情報の取得
以下の情報をメモしておきます。
- アプリケーション(クライアント)ID
- ディレクトリ(テナント)ID
- クライアントシークレット
Azure Bot リソースの作成
- Azure portal > リソースの作成 > Azure Bot を検索
- 以下の設定でボットを作成:
- ボットハンドル:
dialogskillbot(一意の名前) - サブスクリプション: 使用するサブスクリプション
- リソースグループ: App Serviceと同じグループ
- 価格レベル:
F0(無料) - Microsoft App ID: 作成済みのEntra IDアプリのID
- Microsoft App ID の種類:
既存のアプリ ID を使用する
- ボットハンドル:
メッセージングエンドポイントの設定
作成したAzure Botの 構成 で以下を設定します。
- メッセージングエンドポイント:
https://<webapp名>.azurewebsites.net/api/messages
DialogSkillBotの実装
DialogSkillBotは、親ボットからイベントとメッセージのアクティビティを受信し、要求されたタスクを実行します。
appsettings.json
DialogSkillBotの設定ファイルです。
{ "MicrosoftAppType": "SingleTenant", "MicrosoftAppId": "", // EntraIDに登録したアプリのアプリケーション (クライアント) ID "MicrosoftAppPassword": "", // EntraIDに登録したアプリのシークレット "MicrosoftAppTenantId": "", // AzureテナントID "ConnectionName": "", "LuisAppId": "", "LuisAPIKey": "", "LuisAPIHostName": "", // This is a comma separate list with the App IDs that will have access to the skill. // This setting is used in AllowedCallersClaimsValidator. // Examples: // [ "*" ] allows all callers. // [ "AppId1", "AppId2" ] only allows access to parent bots with "AppId1" and "AppId2". "AllowedCallers": [ "*" ] }
スキルマニフェスト
スキルマニフェストは、スキルの機能や接続方法を定義するJSONファイルです。
サンプルのマニフェストファイルのままだと、Copilot Studioに追加する際にエラーになるため、DialogSkillBotの wwwroot/manifest/dialogchildbot-manifest-1.0.json を以下のように更新します。
{ "$schema": "https://schemas.botframework.com/schemas/skills/v2.0/skill-manifest.json", "$id": "DialogSkillBot", "name": "Skill bot with dialogs", "version": "1.0", "description": "This is a sample skill definition for multiple activity types.", "publisherName": "Microsoft", "privacyUrl": "https://dialogskillbot.contoso.com/privacy.html", "copyright": "Copyright (c) Microsoft Corporation. All rights reserved.", "license": "", "iconUrl": "https://dialogskillbot.contoso.com/icon.png", "tags": [ "sample", "travel", "weather", "luis" ], "endpoints": [ { "name": "default", "protocol": "BotFrameworkV3", "description": "Default endpoint for the skill.", "endpointUrl": "https://<webapp名>/azurewebsites.net/api/messages", // スキルボットのエンドポイントURL "msAppId": "" // EntraIDに登録したアプリのアプリケーション (クライアント) ID } ], "activities": { "bookFlight": { "description": "Books a flight (multi turn).", "type": "event", "name": "BookFlight", "value": { "$ref": "#/definitions/bookingInfo" }, "resultValue": { "$ref": "#/definitions/bookingInfo" } }, "getWeather": { "description": "Retrieves and returns the weather for the user's location.", "type": "event", "name": "GetWeather", "value": { "$ref": "#/definitions/location" }, "resultValue": { "$ref": "#/definitions/weatherReport" } }, "passthroughMessage": { "type": "message", "description": "Receives the user's utterance and attempts to resolve it using the skill's LUIS models.", "value": { "type": "object" } } }, "definitions": { "bookingInfo": { "type": "object", "properties": { "origin": { "type": "string", "description": "This is the origin city for the flight." }, "destination": { "type": "string", "description": "This is the destination city for the flight." }, "travelDate": { "type": "string", "description": "The date for the flight in YYYY-MM-DD format." } } }, "weatherReport": { "type": "object", "description": "An object containing an array of forecasts for the next week.", "properties": { "forecasts": { "type": "array", "items": { "type": "string" } } } }, "location": { "type": "object", "description": "Location metadata.", "properties": { "latitude": { "type": "number", "title": "Latitude" }, "longitude": { "type": "number", "title": "Longitude" }, "postalCode": { "type": "string", "title": "Postal code" } } } } }
DateResolverDialog・BookingDialog
サンプルは英語のメッセージでやり取りされているので、ユーザーに表示するメッセージを日本語に変更します。
- DateResolverDialog
private const string PromptMsgText = "出発日はいつですか?"; // 16行目
- BookingDialog
private const string DestinationStepMsgText = "旅行の目的地はどこですか?"; // 15行目 private const string OriginStepMsgText = "出発地はどこですか?"; // 16行目 ... var messageText = $"以下の内容で正しいですか? <br />目的地:{bookingDetails.Destination}<br />出発地:{bookingDetails.Origin}<br />出発日:{bookingDetails.TravelDate}"; // 87行目
DialogSkillBotのAzureへのデプロイ
DialogSkillBotプロジェクトをVisual Studioで開き、以下の手順でデプロイします。
- ソリューションエクスプローラーでDialogSkillBotプロジェクトを右クリック
- 発行 を選択
- Azure > Azure App Service (Windows) を選択
- 作成したApp Serviceを選択
- 発行 をクリック
3. デプロイの確認
Azure Botの Web チャットでテスト から基本的な動作確認を行います。
正常にデプロイされていれば、ボットのウェルカムメッセージが表示されます。
まとめ
本記事では、Copilot StudioのスキルおよびBot Framework SDKの概要とデプロイまでを解説しました。
次の記事で、作成したスキルボットのエージェントとの連携手順を解説いたします。
参考資料
- Bot Framework SDK Documentation
- BotBuilder-Samples Repository
- Copilot Studio Documentation
- Azure Bot Service Documentation