次の方法で共有


カスタム コンテンツ ソースを使用してコパイロットを拡張する

Copilot for Service は、Web サイト、SharePoint、オフライン ファイル、サードパーティのナレッジ ベースからコパイロットにリアルタイム応答を生成させるための、すぐに使用できるサポートを提供します。 ただし、企業では、そのままではサポートされていない他のサードパーティまたは独自のナレッジ ベースを使用する場合があります。 コパイロットを拡張することで、これらの知識ソースを Microsoft Copilot Studio でコパイロットに追加できます。

Copilot Studio にカスタム コンテンツ ソースを追加する

カスタム コンテンツ ソースを追加するには、フォールバック トリガーを使用する新しい トピック を Microsoft Copilot Studio に追加する必要があります。 次の手順を実行します :

  1. 左側のナビゲーションから Microsoft Copilot Studio で拡張 を起動します。
  2. 左側のナビゲーションの Copilot Studio から、トピック に移動します。
  3. 追加トピック>空欄からを選択します。
  4. 右上のメニューの省略記号から コード エディターを開く を選択します。
  5. 次の YAML コードをコピーしてトピックに貼り付けます。
kind: AdaptiveDialog
beginDialog:
  kind: OnUnknownIntent
  id: main
  priority: -7
  actions:
    - kind: HttpRequestAction
      id: nXJfks
      method: Post
      url: https://cheetah-facts.me/rest-api-examples/
      body:
        kind: JsonRequestContent
        content: "={query: System.Activity.Text}"

      errorHandling:
        kind: ContinueOnErrorBehavior
        statusCode: Topic.StatusCode
        errorResponseBody: Topic.ErrorResponse

      response: Topic.ServiceResponse
      responseSchema:
        kind: Record
        properties:
          results:
            type:
              kind: Table
              properties:
                dataSource: String
                ID: Number
                link: String
                text: String
                title: String

    - kind: ConditionGroup
      id: lk8b4S
      conditions:
        - id: zTRi0k
          condition: =Topic.StatusCode >= 300
          actions:
            - kind: ParseValue
              id: wqVAK5
              variable: Topic.ParsedError
              valueType:
                kind: Record
                properties:
                  error:
                    type:
                      kind: Record
                      properties:
                        detail: Blank
                        message: String

                  status: String

              value: =Topic.ErrorResponse

            - kind: ConditionGroup
              id: jwQV1G
              conditions:
                - id: ssVMlZ
                  condition: =Topic.ParsedError.error.message = "Requested URI does not represent any resource"
                  actions:
                    - kind: SetVariable
                      id: setVariable_7w8AeR
                      variable: Topic.ErrorCode
                      value: ServiceNotAccessible

                    - kind: SetVariable
                      id: setVariable_ZSqujW
                      variable: Topic.ErrorMessage
                      value: The Service is not accessible

                - id: S6SU02
                  condition: =Topic.StatusCode = 502
                  actions:
                    - kind: SetVariable
                      id: H2xDBa
                      variable: Topic.ErrorCode
                      value: ServerError

                    - kind: SetVariable
                      id: uyFvpV
                      variable: Topic.ErrorMessage
                      value: Unable to search knowledge articles from rest service

              elseActions:
                - kind: SetVariable
                  id: Vke6RY
                  variable: Topic.ErrorCode
                  value: GenericServiceError

                - kind: SetVariable
                  id: setVariable_pQ40KX
                  variable: Topic.ErrorMessage
                  value: =$"The REST service returned status code {Topic.StatusCode} with error message '{Topic.ParsedError.error.message}'"

            - kind: BeginDialog
              id: OiJHUY
              input:
                binding:
                  Details: "=$\"Status code: {Topic.StatusCode}, message: {Topic.ParsedError.error.message}\""
                  ErrorCode: =Topic.ErrorCode
                  ErrorText: =Topic.ErrorMessage
                  Title: Error accessing Service

              dialog: msdyn_AgentCopilot.topic.ShowError

            - kind: EndDialog
              id: prQKRD

      elseActions:
        - kind: BeginDialog
          id: Ahf09m
          input:
            binding:
              Answers: |-
                =ForAll(Topic.ServiceResponse.results As Article,
                  {
                    Content: Article.text,
                    Title: Article.title,
                    ContentLocation: Article.link,
                    SourceName: "CustomRestService"
                  }
                )

          dialog: msdyn_AgentCopilot.topic.AppendAnswers
          output: {}
  1. トピックをペーストした後は、次の画像のようになります。

カスタム コンテンツ ソース サンプルのスクリーンショット

  1. HTTP 呼び出しの例と、受け入れられる形式の JSON スキーマを確認してください。 カスタム コンテンツ ソースに接続するノードに置き換えます。 これは、Power Automate フロー、コネクタ、または直接の HTTP 応答からのものです。

  2. カスタム コンテンツ ソースの結果がサンプルで定義されたスキーマと一致することを確認してください。

カスタム コンテンツ ソース スキーマのスクリーンショット

  1. システムのステータス コードに基づいてエラー処理ロジックを確認し、更新します。

  2. テスト チャットで質問してテストすると、カスタム コンテンツ ソースが結果を返します。